org.springframework.context.event
Class EventPublicationInterceptor

java.lang.Object
  extended by org.springframework.context.event.EventPublicationInterceptor
All Implemented Interfaces:
Advice, Interceptor, MethodInterceptor, InitializingBean, ApplicationEventPublisherAware

public class EventPublicationInterceptor
extends Object
implements MethodInterceptor, ApplicationEventPublisherAware, InitializingBean

Interceptor that publishes an ApplicationEvent to all ApplicationListeners registered with an ApplicationEventPublisher (typically an ApplicationContext), after each successful method invocation.

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

Author:
Dmitriy Kopylenko, Juergen Hoeller
See Also:
setApplicationEventClass(java.lang.Class), ApplicationEvent, ApplicationListener, ApplicationEventPublisher, ApplicationContext

Constructor Summary
EventPublicationInterceptor()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
 Object invoke(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventPublicationInterceptor

public EventPublicationInterceptor()
Method Detail

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.


setApplicationEventPublisher

public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
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 interface ApplicationEventPublisherAware
Parameters:
applicationEventPublisher - event publisher to be used by this object

afterPropertiesSet

public void afterPropertiesSet()
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean

invoke

public Object invoke(MethodInvocation invocation)
              throws Throwable
Specified by:
invoke in interface MethodInterceptor
Throws:
Throwable


Copyright (c) 2002-2007 The Spring Framework Project.