org.springframework.context.event

## 类 EventPublicationInterceptor

- java.lang.Object
- - org.springframework.context.event.EventPublicationInterceptor

- 所有已实现的接口:
    org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, ApplicationEventPublisherAware

      public class EventPublicationInterceptor
      extends Object
      implements org.aopalliance.intercept.MethodInterceptor, ApplicationEventPublisherAware, org.springframework.beans.factory.InitializingBean

  `Interceptor` that publishes an `ApplicationEvent` to all `ApplicationListeners` registered with an `ApplicationEventPublisher` after each successful method invocation.

  Note that this interceptor is only capable of publishing stateless events configured via the `"applicationEventClass"` property.

  作者:
    Dmitriy Kopylenko, Juergen Hoeller, Rick Evans
  另请参阅:
    `setApplicationEventClass(java.lang.Class<?>)`, `ApplicationEvent`, `ApplicationListener`, `ApplicationEventPublisher`, `ApplicationContext`

- - ### 构造器概要

    构造器
    构造器和说明
    `EventPublicationInterceptor()`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `afterPropertiesSet()`
    `Object` | `invoke(org.aopalliance.intercept.MethodInvocation invocation)`
    `void` | `setApplicationEventClass(Class<?> applicationEventClass)` Set the application event class to publish.
    `void` | `setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)` Set the ApplicationEventPublisher that this object runs in.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### EventPublicationInterceptor

          public EventPublicationInterceptor()

  - ### 方法详细资料

    - #### setApplicationEventClass

          public void setApplicationEventClass(Class<?> applicationEventClass)

      Set the application event class to publish.

      The event class must have a constructor with a single `Object` argument for the event source. The interceptor will pass in the invoked object.

      抛出:
        `IllegalArgumentException` - if the supplied `Class` is `null` or if it is not an `ApplicationEvent` subclass or if it does not expose a constructor that takes a single `Object` argument

    - #### setApplicationEventPublisher

          public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)

      从接口复制的说明: `ApplicationEventPublisherAware`
      Set the ApplicationEventPublisher that this object runs in.

      Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked before ApplicationContextAware's setApplicationContext.

      指定者:
        `setApplicationEventPublisher` 在接口中 `ApplicationEventPublisherAware`
      参数:
        `applicationEventPublisher` - event publisher to be used by this object

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws Exception

      指定者:
        `afterPropertiesSet` 在接口中 `org.springframework.beans.factory.InitializingBean`
      抛出:
        `Exception`

    - #### invoke

          public Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
                        throws Throwable

      指定者:
        `invoke` 在接口中 `org.aopalliance.intercept.MethodInterceptor`
      抛出:
        `Throwable`