提交 9589749f 编写于 作者: J Juergen Hoeller

Introduced createMethodJmsListenerEndpoint template method

Issue: SPR-13774
上级 b3115fcd
......@@ -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());
......
......@@ -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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册