类 EventPublicationInterceptor
- java.lang.Object
- org.springframework.context.event.EventPublicationInterceptor
- 所有已实现的接口:
Advice,Interceptor,MethodInterceptor,Aware,InitializingBean,ApplicationEventPublisherAware
public class EventPublicationInterceptor extends Object implements MethodInterceptor, ApplicationEventPublisherAware, InitializingBean
Interceptorthat publishes anApplicationEventto allApplicationListenersregistered with anApplicationEventPublisherafter 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()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.Objectinvoke(MethodInvocation invocation)Implement this method to perform extra treatments before and after the invocation.voidsetApplicationEventClass(Class<?> applicationEventClass)Set the application event class to publish.voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)Set the ApplicationEventPublisher that this object runs in.
构造器详细资料
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
Objectargument for the event source. The interceptor will pass in the invoked object.- 抛出:
IllegalArgumentException- if the suppliedClassisnullor if it is not anApplicationEventsubclass or if it does not expose a constructor that takes a singleObjectargument
setApplicationEventPublisher
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
从接口复制的说明:ApplicationEventPublisherAwareSet 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
从接口复制的说明:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- 指定者:
afterPropertiesSet在接口中InitializingBean- 抛出:
Exception- in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
invoke
public Object invoke(MethodInvocation invocation) throws Throwable
从接口复制的说明:MethodInterceptorImplement this method to perform extra treatments before and after the invocation. Polite implementations would certainly like to invokeJoinpoint.proceed().- 指定者:
invoke在接口中MethodInterceptor- 参数:
invocation- the method invocation joinpoint- 返回:
- the result of the call to
Joinpoint.proceed(); might be intercepted by the interceptor - 抛出:
Throwable- if the interceptors or the target object throws an exception