Top Description Fields Constructors Methods
org.springframework.context.event

public Class EventPublicationInterceptor

extends Object
implements MethodInterceptor, ApplicationEventPublisherAware, InitializingBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationEventPublisherAware, org.springframework.beans.factory.Aware, org.aopalliance.intercept.MethodInterceptor, org.aopalliance.intercept.Interceptor, org.aopalliance.aop.Advice
Imports
java.lang.reflect.Constructor, org.aopalliance.intercept.MethodInterceptor, .MethodInvocation, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationEvent, .ApplicationEventPublisher, .ApplicationEventPublisherAware, org.springframework.lang.Nullable, org.springframework.util.Assert

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.

Authors
Dmitriy Kopylenko, Juergen Hoeller, Rick Evans
See Also
setApplicationEventClass, org.springframework.context.ApplicationEvent, org.springframework.context.ApplicationListener, org.springframework.context.ApplicationEventPublisher, org.springframework.context.ApplicationContext

Field Summary

Modifier and TypeField and Description
private Constructor<?>
private ApplicationEventPublisher

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, 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.

public Object
invoke(MethodInvocation
the method invocation joinpoint
invocation
)

Implements org.aopalliance.intercept.MethodInterceptor.invoke.

Implement this method to perform extra treatments before and after the invocation.

public void
setApplicationEventClass(Class<?> applicationEventClass)

Set the application event class to publish.

public void
setApplicationEventPublisher(ApplicationEventPublisher
event publisher to be used by this object
applicationEventPublisher
)

Implements org.springframework.context.ApplicationEventPublisherAware.setApplicationEventPublisher.

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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applicationEventClassConstructorback to summary
private Constructor<?> applicationEventClassConstructor
Annotations
@Nullable
applicationEventPublisherback to summary
private ApplicationEventPublisher applicationEventPublisher
Annotations
@Nullable

Constructor Detail

EventPublicationInterceptorback to summary
public EventPublicationInterceptor()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet() throws Exception

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Doc from org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, 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.

Annotations
@Override
Exceptions
Exception:
in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
invokeback to summary
public Object invoke(MethodInvocation invocation) throws Throwable

Implements org.aopalliance.intercept.MethodInterceptor.invoke.

Doc from org.aopalliance.intercept.MethodInterceptor.invoke.

Implement this method to perform extra treatments before and after the invocation. Polite implementations would certainly like to invoke Joinpoint#proceed().

Parameters
invocation:MethodInvocation

the method invocation joinpoint

Returns:Object

the result of the call to Joinpoint#proceed(); might be intercepted by the interceptor

Annotations
@Override
@Nullable
Exceptions
Throwable:
if the interceptors or the target object throws an exception
setApplicationEventClassback to summary
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.

Exceptions
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
setApplicationEventPublisherback to summary
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)

Implements org.springframework.context.ApplicationEventPublisherAware.setApplicationEventPublisher.

Doc from org.springframework.context.ApplicationEventPublisherAware.setApplicationEventPublisher.

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.

Parameters
applicationEventPublisher:ApplicationEventPublisher

event publisher to be used by this object

Annotations
@Override