Example usage for org.springframework.jms.annotation JmsListenerConfigurer configureJmsListeners

List of usage examples for org.springframework.jms.annotation JmsListenerConfigurer configureJmsListeners

Introduction

In this page you can find the example usage for org.springframework.jms.annotation JmsListenerConfigurer configureJmsListeners.

Prototype

void configureJmsListeners(JmsListenerEndpointRegistrar registrar);

Source Link

Document

Callback allowing a org.springframework.jms.config.JmsListenerEndpointRegistry JmsListenerEndpointRegistry and specific org.springframework.jms.config.JmsListenerEndpoint JmsListenerEndpoint instances to be registered against the given JmsListenerEndpointRegistrar .

Usage

From source file:org.springframework.jms.annotation.JmsListenerAnnotationBeanPostProcessor.java

@Override
public void afterSingletonsInstantiated() {
    // Remove resolved singleton classes from cache
    this.nonAnnotatedClasses.clear();

    if (this.beanFactory instanceof ListableBeanFactory) {
        // Apply JmsListenerConfigurer beans from the BeanFactory, if any
        Map<String, JmsListenerConfigurer> beans = ((ListableBeanFactory) this.beanFactory)
                .getBeansOfType(JmsListenerConfigurer.class);
        List<JmsListenerConfigurer> configurers = new ArrayList<>(beans.values());
        AnnotationAwareOrderComparator.sort(configurers);
        for (JmsListenerConfigurer configurer : configurers) {
            configurer.configureJmsListeners(this.registrar);
        }/*  w  w w  .  j a va 2  s .c  om*/
    }

    if (this.registrar.getEndpointRegistry() == null) {
        // Determine JmsListenerEndpointRegistry bean from the BeanFactory
        if (this.endpointRegistry == null) {
            Assert.state(this.beanFactory != null,
                    "BeanFactory must be set to find endpoint registry by bean name");
            this.endpointRegistry = this.beanFactory.getBean(
                    JmsListenerConfigUtils.JMS_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME,
                    JmsListenerEndpointRegistry.class);
        }
        this.registrar.setEndpointRegistry(this.endpointRegistry);
    }

    if (this.containerFactoryBeanName != null) {
        this.registrar.setContainerFactoryBeanName(this.containerFactoryBeanName);
    }

    // Set the custom handler method factory once resolved by the configurer
    MessageHandlerMethodFactory handlerMethodFactory = this.registrar.getMessageHandlerMethodFactory();
    if (handlerMethodFactory != null) {
        this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(handlerMethodFactory);
    }

    // Actually register all listeners
    this.registrar.afterPropertiesSet();
}