org.axonframework.util
Class AbstractAnnotationHandlerBeanPostProcessor

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

public abstract class AbstractAnnotationHandlerBeanPostProcessor
extends Object
implements org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean

Abstract bean post processor that finds candidates for proxying. Typically used to wrap annotated beans with their respective interface implementations.

Since:
0.4
Author:
Allard Buijze

Constructor Summary
AbstractAnnotationHandlerBeanPostProcessor()
           
 
Method Summary
protected abstract  Class<?> getAdapterInterface()
          Returns the interface that the adapter implements to connect the annotated method to the actual interface definition.
protected  org.springframework.context.ApplicationContext getApplicationContext()
          Returns the ApplicationContext this Bean Post Processor is registered in.
protected abstract  Subscribable initializeAdapterFor(Object bean)
          Create an AnnotationEventListenerAdapter instance of the given bean.
protected abstract  boolean isPostProcessingCandidate(Class<?> targetClass)
          Indicates whether an object of the given targetClass should be post processed.
 Object postProcessAfterInitialization(Object bean, String beanName)
          
 void postProcessBeforeDestruction(Object bean, String beanName)
          
 Object postProcessBeforeInitialization(Object bean, String beanName)
          
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
 

Constructor Detail

AbstractAnnotationHandlerBeanPostProcessor

public AbstractAnnotationHandlerBeanPostProcessor()
Method Detail

postProcessBeforeInitialization

public Object postProcessBeforeInitialization(Object bean,
                                              String beanName)
                                       throws org.springframework.beans.BeansException

Specified by:
postProcessBeforeInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
Throws:
org.springframework.beans.BeansException

postProcessAfterInitialization

public Object postProcessAfterInitialization(Object bean,
                                             String beanName)
                                      throws org.springframework.beans.BeansException

Specified by:
postProcessAfterInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
Throws:
org.springframework.beans.BeansException

getAdapterInterface

protected abstract Class<?> getAdapterInterface()
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.

Returns:
the interface that the adapter implements to connect the annotated method to the actual interface definition

isPostProcessingCandidate

protected abstract boolean isPostProcessingCandidate(Class<?> targetClass)
Indicates whether an object of the given targetClass should be post processed.

Parameters:
targetClass - The type of bean
Returns:
true to post process bean of given type, false otherwise

postProcessBeforeDestruction

public void postProcessBeforeDestruction(Object bean,
                                         String beanName)
                                  throws org.springframework.beans.BeansException

Specified by:
postProcessBeforeDestruction in interface org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
Throws:
org.springframework.beans.BeansException

initializeAdapterFor

protected abstract Subscribable 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.

Parameters:
bean - The bean that the EventListenerAdapter has to adapt
Returns:
an event handler adapter for the given bean

getApplicationContext

protected org.springframework.context.ApplicationContext getApplicationContext()
Returns the ApplicationContext this Bean Post Processor is registered in.

Returns:
the ApplicationContext this Bean Post Processor is registered in

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException

Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException


Copyright © 2011. All Rights Reserved.