类 EventPublicationInterceptor
- java.lang.Object
- org.springframework.context.event.EventPublicationInterceptor
- 所有已实现的接口:
Advice
,Interceptor
,MethodInterceptor
,Aware
,InitializingBean
,ApplicationEventPublisherAware
public class EventPublicationInterceptor extends Object implements MethodInterceptor, ApplicationEventPublisherAware, InitializingBean
Interceptor
that publishes anApplicationEvent
to allApplicationListeners
registered with anApplicationEventPublisher
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()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.Object
invoke(MethodInvocation invocation)
Implement this method to perform extra treatments before and after the invocation.void
setApplicationEventClass(Class<?> applicationEventClass)
Set the application event class to publish.void
setApplicationEventPublisher(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
Object
argument for the event source. The interceptor will pass in the invoked object.- 抛出:
IllegalArgumentException
- if the suppliedClass
isnull
or if it is not anApplicationEvent
subclass or if it does not expose a constructor that takes a singleObject
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
从接口复制的说明:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.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
从接口复制的说明:MethodInterceptor
Implement 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