com.atlassian.event.spring
Class EventListenerRegistrarBeanProcessor

java.lang.Object
  extended by com.atlassian.event.spring.EventListenerRegistrarBeanProcessor
All Implemented Interfaces:
java.util.EventListener, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, org.springframework.context.ApplicationListener, org.springframework.core.Ordered

public class EventListenerRegistrarBeanProcessor
extends java.lang.Object
implements org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, org.springframework.beans.factory.BeanFactoryAware, org.springframework.core.Ordered, org.springframework.context.ApplicationListener

Convenience class that registers/unregisters beans that implement the EventListener interfaces, or has method(s) annotated with the EventListener annotation with the EventListenerRegistrar on bean creation and bean destruction.

EventListenerRegistrarBeanProcessor is implemented as a Spring BeanPostProcessor, which means that it gets called whenever a bean is created or destroyed in the application context. Because we need to get callbacks for all beans that get created, it is important to inject the minimum of dependencies through CI, as the EventListenerRegistrarBeanProcessor can only be created AFTER all of its dependencies have been created.

For this reason, the name of the EventListenerRegistrar bean is injected, not the EventListenerRegistrar instance itself. While the EventListenerRegistrarBeanProcessor does not have the EventListenerRegistrar yet, all beans that should be registered are stored in the listenersToBeRegistered map. When the EventListenerRegistrarBeanProcessor gets hold of the EventListenerRegistrar, all beans in listenersToBeRegistered are registered and the map is cleared.

Since:
2.3.0

Field Summary
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
EventListenerRegistrarBeanProcessor(java.lang.String eventListenerRegistrarBeanName, ListenerHandlersConfiguration listenerHandlersConfiguration)
           
 
Method Summary
 int getOrder()
           
 void onApplicationEvent(org.springframework.context.ApplicationEvent applicationEvent)
           
 void onPluginDisabled(com.atlassian.plugin.event.events.PluginDisabledEvent event)
           
 void onPluginModuleDisabled(com.atlassian.plugin.event.events.PluginModuleDisabledEvent event)
           
 void onPluginModuleEnabled(com.atlassian.plugin.event.events.PluginModuleEnabledEvent event)
           
 java.lang.Object postProcessAfterInitialization(java.lang.Object bean, java.lang.String beanName)
           
 void postProcessBeforeDestruction(java.lang.Object bean, java.lang.String beanName)
           
 java.lang.Object postProcessBeforeInitialization(java.lang.Object bean, java.lang.String beanName)
           
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventListenerRegistrarBeanProcessor

public EventListenerRegistrarBeanProcessor(java.lang.String eventListenerRegistrarBeanName,
                                           ListenerHandlersConfiguration listenerHandlersConfiguration)
Method Detail

getOrder

public int getOrder()
Specified by:
getOrder in interface org.springframework.core.Ordered

onPluginModuleEnabled

public void onPluginModuleEnabled(com.atlassian.plugin.event.events.PluginModuleEnabledEvent event)

onPluginDisabled

public void onPluginDisabled(com.atlassian.plugin.event.events.PluginDisabledEvent event)

onPluginModuleDisabled

public void onPluginModuleDisabled(com.atlassian.plugin.event.events.PluginModuleDisabledEvent event)

onApplicationEvent

public void onApplicationEvent(org.springframework.context.ApplicationEvent applicationEvent)
Specified by:
onApplicationEvent in interface org.springframework.context.ApplicationListener

postProcessAfterInitialization

public java.lang.Object postProcessAfterInitialization(java.lang.Object bean,
                                                       java.lang.String beanName)
                                                throws org.springframework.beans.BeansException
Specified by:
postProcessAfterInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
Throws:
org.springframework.beans.BeansException

postProcessBeforeDestruction

public void postProcessBeforeDestruction(java.lang.Object bean,
                                         java.lang.String beanName)
                                  throws org.springframework.beans.BeansException
Specified by:
postProcessBeforeDestruction in interface org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
Throws:
org.springframework.beans.BeansException

postProcessBeforeInitialization

public java.lang.Object postProcessBeforeInitialization(java.lang.Object bean,
                                                        java.lang.String beanName)
                                                 throws org.springframework.beans.BeansException
Specified by:
postProcessBeforeInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
Throws:
org.springframework.beans.BeansException

setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
                    throws org.springframework.beans.BeansException
Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
Throws:
org.springframework.beans.BeansException


Copyright © 2006-2012 Atlassian. All Rights Reserved.