Class JmsListenerAnnotationBeanPostProcessor
- All Implemented Interfaces:
Aware,BeanFactoryAware,BeanPostProcessor,SmartInitializingSingleton,MergedBeanDefinitionPostProcessor,Ordered
JmsListener
to be invoked by a JMS message listener container created under the cover
by a JmsListenerContainerFactory
according to the attributes of the annotation.
Annotated methods can use flexible arguments as defined by JmsListener.
This post-processor is automatically registered by Spring's
<jms:annotation-driven> XML element, and also by the EnableJms
annotation.
Autodetects any JmsListenerConfigurer instances in the container,
allowing for customization of the registry to be used, the default container
factory or for fine-grained control over endpoints registration. See the
EnableJms javadocs for complete usage details.
- Since:
- 4.1
- Author:
- Stephane Nicoll, Juergen Hoeller
- See Also:
-
Field Summary
FieldsFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.protected MethodJmsListenerEndpointInstantiate an emptyMethodJmsListenerEndpointfor further configuration with provided parameters inprocessJmsListener(org.springframework.jms.annotation.JmsListener, java.lang.reflect.Method, java.lang.Object).intgetOrder()Get the order value of this object.postProcessAfterInitialization(Object bean, String beanName) Apply thisBeanPostProcessorto the given new bean instance after any bean initialization callbacks (like InitializingBean'safterPropertiesSetor a custom init-method).postProcessBeforeInitialization(Object bean, String beanName) Apply thisBeanPostProcessorto the given new bean instance before any bean initialization callbacks (like InitializingBean'safterPropertiesSetor a custom init-method).voidpostProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) Post-process the given merged bean definition for the specified bean.protected voidprocessJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean) Process the givenJmsListenerannotation on the given method, registering a corresponding endpoint for the given bean instance.voidsetBeanFactory(BeanFactory beanFactory) Making aBeanFactoryavailable is optional; if not set,JmsListenerConfigurerbeans won't get autodetected and anendpoint registryhas to be explicitly configured.voidsetContainerFactoryBeanName(String containerFactoryBeanName) Set the name of theJmsListenerContainerFactoryto use by default.voidsetEndpointRegistry(JmsListenerEndpointRegistry endpointRegistry) Set theJmsListenerEndpointRegistrythat will hold the created endpoint and manage the lifecycle of the related listener container.voidsetMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) Set theMessageHandlerMethodFactoryto use to configure the message listener responsible to serve an endpoint detected by this processor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor
resetBeanDefinition
-
Field Details
-
logger
-
-
Constructor Details
-
JmsListenerAnnotationBeanPostProcessor
public JmsListenerAnnotationBeanPostProcessor()
-
-
Method Details
-
getOrder
public int getOrder()Description copied from interface:OrderedGet the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet
load-on-startupvalues).Same order values will result in arbitrary sort positions for the affected objects.
-
setContainerFactoryBeanName
Set the name of theJmsListenerContainerFactoryto use by default.If none is specified, "jmsListenerContainerFactory" is assumed to be defined.
-
setEndpointRegistry
Set theJmsListenerEndpointRegistrythat will hold the created endpoint and manage the lifecycle of the related listener container. -
setMessageHandlerMethodFactory
Set theMessageHandlerMethodFactoryto use to configure the message listener responsible to serve an endpoint detected by this processor.By default,
DefaultMessageHandlerMethodFactoryis used and it can be configured further to support additional method arguments or to customize conversion and validation support. SeeDefaultMessageHandlerMethodFactoryJavadoc for more details. -
setBeanFactory
Making aBeanFactoryavailable is optional; if not set,JmsListenerConfigurerbeans won't get autodetected and anendpoint registryhas to be explicitly configured.- Specified by:
setBeanFactoryin interfaceBeanFactoryAware- Parameters:
beanFactory- owning BeanFactory (nevernull). The bean can immediately call methods on the factory.- See Also:
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()Description copied from interface:SmartInitializingSingletonInvoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.ListableBeanFactory.getBeansOfType(java.lang.Class<T>)calls within this method won't trigger accidental side effects during bootstrap.NOTE: This callback won't be triggered for singleton beans lazily initialized on demand after
BeanFactorybootstrap, and not for any other bean scope either. Carefully use it for beans with the intended bootstrap semantics only.- Specified by:
afterSingletonsInstantiatedin interfaceSmartInitializingSingleton
-
postProcessMergedBeanDefinition
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) Description copied from interface:MergedBeanDefinitionPostProcessorPost-process the given merged bean definition for the specified bean.- Specified by:
postProcessMergedBeanDefinitionin interfaceMergedBeanDefinitionPostProcessor- Parameters:
beanDefinition- the merged bean definition for the beanbeanType- the actual type of the managed bean instancebeanName- the name of the bean- See Also:
-
postProcessBeforeInitialization
Description copied from interface:BeanPostProcessorApply thisBeanPostProcessorto the given new bean instance before any bean initialization callbacks (like InitializingBean'safterPropertiesSetor a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.The default implementation returns the given
beanas-is.- Specified by:
postProcessBeforeInitializationin interfaceBeanPostProcessor- Parameters:
bean- the new bean instancebeanName- the name of the bean- Returns:
- the bean instance to use, either the original or a wrapped one;
if
null, no subsequent BeanPostProcessors will be invoked - Throws:
BeansException- in case of errors- See Also:
-
postProcessAfterInitialization
Description copied from interface:BeanPostProcessorApply thisBeanPostProcessorto the given new bean instance after any bean initialization callbacks (like InitializingBean'safterPropertiesSetor a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.In case of a FactoryBean, this callback will be invoked for both the FactoryBean instance and the objects created by the FactoryBean (as of Spring 2.0). The post-processor can decide whether to apply to either the FactoryBean or created objects or both through corresponding
bean instanceof FactoryBeanchecks.This callback will also be invoked after a short-circuiting triggered by a
InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation(java.lang.Class<?>, java.lang.String)method, in contrast to all otherBeanPostProcessorcallbacks.The default implementation returns the given
beanas-is.- Specified by:
postProcessAfterInitializationin interfaceBeanPostProcessor- Parameters:
bean- the new bean instancebeanName- the name of the bean- Returns:
- the bean instance to use, either the original or a wrapped one;
if
null, no subsequent BeanPostProcessors will be invoked - Throws:
BeansException- in case of errors- See Also:
-
processJmsListener
Process the givenJmsListenerannotation on the given method, registering a corresponding endpoint for the given bean instance.- Parameters:
jmsListener- the annotation to processmostSpecificMethod- the annotated methodbean- the instance to invoke the method on- See Also:
-
createMethodJmsListenerEndpoint
Instantiate an emptyMethodJmsListenerEndpointfor further configuration with provided parameters inprocessJmsListener(org.springframework.jms.annotation.JmsListener, java.lang.reflect.Method, java.lang.Object).- Returns:
- a new
MethodJmsListenerEndpointor subclass thereof - Since:
- 4.1.9
- See Also:
-