org.axonframework.eventhandling.annotation
Class AnnotationEventListenerBeanPostProcessor

java.lang.Object
  extended by org.axonframework.util.AbstractAnnotationHandlerBeanPostProcessor
      extended by org.axonframework.eventhandling.annotation.AnnotationEventListenerBeanPostProcessor
All Implemented Interfaces:
org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

public class AnnotationEventListenerBeanPostProcessor
extends AbstractAnnotationHandlerBeanPostProcessor

Spring Bean post processor that automatically generates an adapter for each bean containing EventHandler annotated methods.

Since:
0.3
Author:
Allard Buijze

Constructor Summary
AnnotationEventListenerBeanPostProcessor()
           
 
Method Summary
 void afterPropertiesSet()
          
protected  Class<?> getAdapterInterface()
          Returns the interface that the adapter implements to connect the annotated method to the actual interface definition.
protected  AnnotationEventListenerAdapter initializeAdapterFor(Object bean)
          Create an AnnotationEventListenerAdapter instance of the given bean.
protected  boolean isPostProcessingCandidate(Class<?> targetClass)
          Indicates whether an object of the given targetClass should be post processed.
 void setEventBus(EventBus eventBus)
          Sets the event bus to which detected event listeners should be subscribed.
 void setExecutor(Executor executor)
          Sets the Executor to use when the AnnotationEventListenerBeanPostProcessor encounters event listeners with the AsynchronousEventListener annotation.
 
Methods inherited from class org.axonframework.util.AbstractAnnotationHandlerBeanPostProcessor
getApplicationContext, postProcessAfterInitialization, postProcessBeforeDestruction, postProcessBeforeInitialization, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationEventListenerBeanPostProcessor

public AnnotationEventListenerBeanPostProcessor()
Method Detail

getAdapterInterface

protected Class<?> getAdapterInterface()
Description copied from class: AbstractAnnotationHandlerBeanPostProcessor
Returns the interface that the adapter implements to connect the annotated method to the actual interface definition. Calls to methods declared on this interface are passed to the adapter, while other method calls will be forwarded to the annotated object itself.

Note: this *must* be an interface. It may not be an (abstract) class.

Specified by:
getAdapterInterface in class AbstractAnnotationHandlerBeanPostProcessor
Returns:
the interface that the adapter implements to connect the annotated method to the actual interface definition

initializeAdapterFor

protected AnnotationEventListenerAdapter initializeAdapterFor(Object bean)
Create an AnnotationEventListenerAdapter instance of the given bean. This adapter will receive all event handler calls to be handled by this bean.

Specified by:
initializeAdapterFor in class AbstractAnnotationHandlerBeanPostProcessor
Parameters:
bean - The bean that the EventListenerAdapter has to adapt
Returns:
an event handler adapter for the given bean

isPostProcessingCandidate

protected boolean isPostProcessingCandidate(Class<?> targetClass)
Description copied from class: AbstractAnnotationHandlerBeanPostProcessor
Indicates whether an object of the given targetClass should be post processed.

Specified by:
isPostProcessingCandidate in class AbstractAnnotationHandlerBeanPostProcessor
Parameters:
targetClass - The type of bean
Returns:
true to post process bean of given type, false otherwise

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception

Throws:
Exception

setExecutor

public void setExecutor(Executor executor)
Sets the Executor to use when the AnnotationEventListenerBeanPostProcessor encounters event listeners with the AsynchronousEventListener annotation.

Parameters:
executor - the Executor to use for asynchronous event listeners

setEventBus

public void setEventBus(EventBus eventBus)
Sets the event bus to which detected event listeners should be subscribed. If none is provided, the event bus will be automatically detected in the application context.

Parameters:
eventBus - the event bus to subscribe detected event listeners to


Copyright © 2011. All Rights Reserved.