Search in sources :

Example 1 with MessageHandlerMethodFactory

use of org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory in project spring-framework by spring-projects.

the class JmsListenerAnnotationBeanPostProcessor method afterSingletonsInstantiated.

@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> instances = ((ListableBeanFactory) this.beanFactory).getBeansOfType(JmsListenerConfigurer.class);
        for (JmsListenerConfigurer configurer : instances.values()) {
            configurer.configureJmsListeners(this.registrar);
        }
    }
    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();
}
Also used : JmsListenerEndpointRegistry(org.springframework.jms.config.JmsListenerEndpointRegistry) DefaultMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory) MessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory) ListableBeanFactory(org.springframework.beans.factory.ListableBeanFactory)

Aggregations

ListableBeanFactory (org.springframework.beans.factory.ListableBeanFactory)1 JmsListenerEndpointRegistry (org.springframework.jms.config.JmsListenerEndpointRegistry)1 DefaultMessageHandlerMethodFactory (org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory)1 MessageHandlerMethodFactory (org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory)1