diff --git a/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java b/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java index b902a486e5a..bda5965ed6e 100644 --- a/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java +++ b/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java @@ -226,10 +226,19 @@ public class JmsListenerAnnotationBeanPostProcessor return bean; } + /** + * 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 + */ protected void processJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean) { Method invocableMethod = MethodIntrospector.selectInvocableMethod(mostSpecificMethod, bean.getClass()); - MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint(); + MethodJmsListenerEndpoint endpoint = createMethodJmsListenerEndpoint(); endpoint.setBean(bean); endpoint.setMethod(invocableMethod); endpoint.setMostSpecificMethod(mostSpecificMethod); @@ -264,6 +273,17 @@ public class JmsListenerAnnotationBeanPostProcessor this.registrar.registerEndpoint(endpoint, factory); } + /** + * Instantiate an empty {@link MethodJmsListenerEndpoint} for further + * configuration with provided parameters in {@link #processJmsListener}. + * @return a new {@code MethodJmsListenerEndpoint} or subclass thereof + * @since 4.1.9 + * @see MethodJmsListenerEndpoint#createMessageListenerInstance() + */ + protected MethodJmsListenerEndpoint createMethodJmsListenerEndpoint() { + return new MethodJmsListenerEndpoint(); + } + private String getEndpointId(JmsListener jmsListener) { if (StringUtils.hasText(jmsListener.id())) { return resolve(jmsListener.id()); diff --git a/spring-jms/src/main/java/org/springframework/jms/config/MethodJmsListenerEndpoint.java b/spring-jms/src/main/java/org/springframework/jms/config/MethodJmsListenerEndpoint.java index 8d61641790f..8bde24d0280 100644 --- a/spring-jms/src/main/java/org/springframework/jms/config/MethodJmsListenerEndpoint.java +++ b/spring-jms/src/main/java/org/springframework/jms/config/MethodJmsListenerEndpoint.java @@ -56,7 +56,7 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint { /** - * Set the object instance that should manage this endpoint. + * Set the actual bean instance to invoke this endpoint method on. */ public void setBean(Object bean) { this.bean = bean; @@ -67,7 +67,7 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint { } /** - * Set the method to invoke to process a message managed by this endpoint. + * Set the method to invoke for processing a message managed by this endpoint. */ public void setMethod(Method method) { this.method = method; @@ -146,6 +146,7 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint { /** * Create an empty {@link MessagingMessageListenerAdapter} instance. + * @return a new {@code MessagingMessageListenerAdapter} or subclass thereof */ protected MessagingMessageListenerAdapter createMessageListenerInstance() { return new MessagingMessageListenerAdapter();