public class EventPublicationInterceptor extends ObjectSE implements MethodInterceptor, ApplicationEventPublisherAware, InitializingBean
ApplicationEventPublisher
で登録されたすべての ApplicationListeners
に ApplicationEvent
を発行する Interceptor
は、各メソッド呼び出しが成功した後。 このインターセプターは、"applicationEventClass"
プロパティを介して構成されたステートレスイベントのみを発行できることに注意してください。
setApplicationEventClass(java.lang.Class<?>)
, ApplicationEvent
, ApplicationListener
, ApplicationEventPublisher
, ApplicationContext
コンストラクターと説明 |
---|
EventPublicationInterceptor() |
修飾子と型 | メソッドと説明 |
---|---|
void | afterPropertiesSet() |
ObjectSE | invoke(MethodInvocation invocation) このメソッドを実装して、呼び出しの前後に追加の処理を実行します。 |
void | setApplicationEventClass(ClassSE<?> applicationEventClass) 公開するアプリケーションイベントクラスを設定します。 |
void | setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) このオブジェクトが実行される ApplicationEventPublisher を設定します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public void setApplicationEventClass(ClassSE<?> applicationEventClass)
イベントクラスに は、イベントソースの単一の Object
引数を持つコンストラクターが必要です。インターセプターは、呼び出されたオブジェクトを渡します。
IllegalArgumentExceptionSE
- 指定された Class
が null
である場合、または ApplicationEvent
サブクラスではない場合、単一の Object
引数を取るコンストラクターを公開していない場合 public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
ApplicationEventPublisherAware
通常の Bean プロパティの設定後、InitializingBean の afterPropertiesSet などの init コールバックやカスタム init メソッドの前に呼び出されます。ApplicationContextAware の setApplicationContext の前に呼び出されます。
ApplicationEventPublisherAware
の setApplicationEventPublisher
applicationEventPublisher
- このオブジェクトによって使用されるイベント発行元 public void afterPropertiesSet() throws ExceptionSE
InitializingBean
BeanFactoryAware
、ApplicationContextAware
などを満たした後、包含 BeanFactory
によって呼び出されます。このメソッドにより、Bean インスタンスは、すべての Bean プロパティが設定されたときに、その全体的な構成の検証と最終的な初期化を実行できます。
InitializingBean
の afterPropertiesSet
ExceptionSE
- 構成の誤り(必須プロパティの設定の失敗など)の場合、またはその他の理由で初期化が失敗した場合 public ObjectSE invoke(MethodInvocation invocation) throws ThrowableSE
MethodInterceptor
Joinpoint.proceed()
を呼び出すようにします。MethodInterceptor
の invoke
invocation
- メソッド呼び出しジョインポイント Joinpoint.proceed()
の呼び出しの結果。インターセプターによってインターセプトされる可能性があります ThrowableSE
- インターセプターまたはターゲットオブジェクトが例外をスローする場合