org.springframework.jms.annotation

## Class JmsListenerAnnotationBeanPostProcessor

- java.lang.Object
- - org.springframework.jms.annotation.JmsListenerAnnotationBeanPostProcessor

All Implemented Interfaces:
  org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.SmartInitializingSingleton, org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor, org.springframework.core.Ordered

    public class JmsListenerAnnotationBeanPostProcessor
    extends Object
    implements org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor, org.springframework.core.Ordered, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.SmartInitializingSingleton

Bean post-processor that registers methods annotated with `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:
  `JmsListener`, `EnableJms`, `JmsListenerConfigurer`, `JmsListenerEndpointRegistrar`, `JmsListenerEndpointRegistry`, `JmsListenerEndpoint`, `MethodJmsListenerEndpoint`

### Field Summary

Fields
`protected Log` `logger`

### Fields inherited from interface org.springframework.core.Ordered

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

### Constructor Summary

Constructors
Constructor and Description
`JmsListenerAnnotationBeanPostProcessor()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `afterSingletonsInstantiated()`
`protected MethodJmsListenerEndpoint` `createMethodJmsListenerEndpoint()` Instantiate an empty `MethodJmsListenerEndpoint` for further configuration with provided parameters in `processJmsListener(org.springframework.jms.annotation.JmsListener, java.lang.reflect.Method, java.lang.Object)`.
`int` `getOrder()`
`Object` `postProcessAfterInitialization(Object bean, String beanName)`
`Object` `postProcessBeforeInitialization(Object bean, String beanName)`
`void` `postProcessMergedBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition beanDefinition, Class<?> beanType, String beanName)`
`protected void` `processJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean)` Process the given `JmsListener` annotation on the given method, registering a corresponding endpoint for the given bean instance.
`void` `setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)` Making a `BeanFactory` available is optional; if not set, `JmsListenerConfigurer` beans won't get autodetected and an `endpoint registry` has to be explicitly configured.
`void` `setContainerFactoryBeanName(String containerFactoryBeanName)` Set the name of the `JmsListenerContainerFactory` to use by default.
`void` `setEndpointRegistry(JmsListenerEndpointRegistry endpointRegistry)` Set the `JmsListenerEndpointRegistry` that will hold the created endpoint and manage the lifecycle of the related listener container.
`void` `setMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory messageHandlerMethodFactory)` Set the `MessageHandlerMethodFactory` to 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, wait`

### Methods inherited from interface org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor

`resetBeanDefinition`

### Field Detail

#### logger

    protected final Log logger

### Constructor Detail

#### JmsListenerAnnotationBeanPostProcessor

    public JmsListenerAnnotationBeanPostProcessor()

### Method Detail

#### getOrder

    public int getOrder()

Specified by:
  `getOrder` in interface `org.springframework.core.Ordered`

#### setContainerFactoryBeanName

    public void setContainerFactoryBeanName(String containerFactoryBeanName)

Set the name of the `JmsListenerContainerFactory` to use by default.

If none is specified, "jmsListenerContainerFactory" is assumed to be defined.

#### setEndpointRegistry

    public void setEndpointRegistry(JmsListenerEndpointRegistry endpointRegistry)

Set the `JmsListenerEndpointRegistry` that will hold the created endpoint and manage the lifecycle of the related listener container.

#### setMessageHandlerMethodFactory

    public void setMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory messageHandlerMethodFactory)

Set the `MessageHandlerMethodFactory` to use to configure the message listener responsible to serve an endpoint detected by this processor.

By default, `DefaultMessageHandlerMethodFactory` is used and it can be configured further to support additional method arguments or to customize conversion and validation support. See `DefaultMessageHandlerMethodFactory` Javadoc for more details.

#### setBeanFactory

    public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)

Making a `BeanFactory` available is optional; if not set, `JmsListenerConfigurer` beans won't get autodetected and an `endpoint registry` has to be explicitly configured.

Specified by:
  `setBeanFactory` in interface `org.springframework.beans.factory.BeanFactoryAware`

#### afterSingletonsInstantiated

    public void afterSingletonsInstantiated()

Specified by:
  `afterSingletonsInstantiated` in interface `org.springframework.beans.factory.SmartInitializingSingleton`

#### postProcessMergedBeanDefinition

    public void postProcessMergedBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition beanDefinition,
                                                Class<?> beanType,
                                                String beanName)

Specified by:
  `postProcessMergedBeanDefinition` in interface `org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor`

#### 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`

#### processJmsListener

    protected void processJmsListener(JmsListener jmsListener,
                                      Method mostSpecificMethod,
                                      Object bean)

Process the given `JmsListener` annotation on the given method, registering a corresponding endpoint for the given bean instance.

Parameters:
  `jmsListener` - the annotation to process
  `mostSpecificMethod` - the annotated method
  `bean` - the instance to invoke the method on
See Also:
  `createMethodJmsListenerEndpoint()`, `JmsListenerEndpointRegistrar.registerEndpoint(org.springframework.jms.config.JmsListenerEndpoint, org.springframework.jms.config.JmsListenerContainerFactory<?>)`

#### createMethodJmsListenerEndpoint

    protected MethodJmsListenerEndpoint createMethodJmsListenerEndpoint()

Instantiate an empty `MethodJmsListenerEndpoint` for further configuration with provided parameters in `processJmsListener(org.springframework.jms.annotation.JmsListener, java.lang.reflect.Method, java.lang.Object)`.

Returns:
  a new `MethodJmsListenerEndpoint` or subclass thereof
Since:
  4.1.9
See Also:
  `MethodJmsListenerEndpoint.createMessageListenerInstance()`