Example usage for org.springframework.jms.config MethodJmsListenerEndpoint setMostSpecificMethod

List of usage examples for org.springframework.jms.config MethodJmsListenerEndpoint setMostSpecificMethod

Introduction

In this page you can find the example usage for org.springframework.jms.config MethodJmsListenerEndpoint setMostSpecificMethod.

Prototype

public void setMostSpecificMethod(@Nullable Method mostSpecificMethod) 

Source Link

Document

Set the most specific method known for this endpoint's declaration.

Usage

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

/**
 * Process the given {@link JmsListener} annotation on the given method,
 * registering a corresponding endpoint for the given bean instance.
 * @param jmsListener the annotation to process
 * @param mostSpecificMethod the annotated method
 * @param bean the instance to invoke the method on
 * @see #createMethodJmsListenerEndpoint()
 * @see JmsListenerEndpointRegistrar#registerEndpoint
 *//*from  ww w. j  a va2 s .  c  om*/
protected void processJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean) {
    Method invocableMethod = AopUtils.selectInvocableMethod(mostSpecificMethod, bean.getClass());

    MethodJmsListenerEndpoint endpoint = createMethodJmsListenerEndpoint();
    endpoint.setBean(bean);
    endpoint.setMethod(invocableMethod);
    endpoint.setMostSpecificMethod(mostSpecificMethod);
    endpoint.setMessageHandlerMethodFactory(this.messageHandlerMethodFactory);
    endpoint.setEmbeddedValueResolver(this.embeddedValueResolver);
    endpoint.setBeanFactory(this.beanFactory);
    endpoint.setId(getEndpointId(jmsListener));
    endpoint.setDestination(resolve(jmsListener.destination()));
    if (StringUtils.hasText(jmsListener.selector())) {
        endpoint.setSelector(resolve(jmsListener.selector()));
    }
    if (StringUtils.hasText(jmsListener.subscription())) {
        endpoint.setSubscription(resolve(jmsListener.subscription()));
    }
    if (StringUtils.hasText(jmsListener.concurrency())) {
        endpoint.setConcurrency(resolve(jmsListener.concurrency()));
    }

    JmsListenerContainerFactory<?> factory = null;
    String containerFactoryBeanName = resolve(jmsListener.containerFactory());
    if (StringUtils.hasText(containerFactoryBeanName)) {
        Assert.state(this.beanFactory != null,
                "BeanFactory must be set to obtain container factory by bean name");
        try {
            factory = this.beanFactory.getBean(containerFactoryBeanName, JmsListenerContainerFactory.class);
        } catch (NoSuchBeanDefinitionException ex) {
            throw new BeanInitializationException("Could not register JMS listener endpoint on ["
                    + mostSpecificMethod + "], no " + JmsListenerContainerFactory.class.getSimpleName()
                    + " with id '" + containerFactoryBeanName + "' was found in the application context", ex);
        }
    }

    this.registrar.registerEndpoint(endpoint, factory);
}