Class EventPublicationInterceptor
java.lang.Object
org.springframework.context.event.EventPublicationInterceptor
- All Implemented Interfaces:
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.
- Author:
- Dmitriy Kopylenko, Juergen Hoeller, Rick Evans
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.
-
Constructor Details
-
EventPublicationInterceptor
public EventPublicationInterceptor()
-
-
Method Details
-
setApplicationEventClass
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.- Throws:
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
Description copied from interface: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.
- Specified by:
setApplicationEventPublisher
in interfaceApplicationEventPublisherAware
- Parameters:
applicationEventPublisher
- event publisher to be used by this object
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
invoke
@Nullable public Object invoke(org.aopalliance.intercept.MethodInvocation invocation) throws Throwable - Specified by:
invoke
in interfaceorg.aopalliance.intercept.MethodInterceptor
- Throws:
Throwable
-