Introduced createMethodJmsListenerEndpoint template method
Issue: SPR-13774
This commit is contained in:
parent
b3115fcd85
commit
9589749fb2
|
|
@ -226,10 +226,19 @@ public class JmsListenerAnnotationBeanPostProcessor
|
||||||
return bean;
|
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) {
|
protected void processJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean) {
|
||||||
Method invocableMethod = MethodIntrospector.selectInvocableMethod(mostSpecificMethod, bean.getClass());
|
Method invocableMethod = MethodIntrospector.selectInvocableMethod(mostSpecificMethod, bean.getClass());
|
||||||
|
|
||||||
MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint();
|
MethodJmsListenerEndpoint endpoint = createMethodJmsListenerEndpoint();
|
||||||
endpoint.setBean(bean);
|
endpoint.setBean(bean);
|
||||||
endpoint.setMethod(invocableMethod);
|
endpoint.setMethod(invocableMethod);
|
||||||
endpoint.setMostSpecificMethod(mostSpecificMethod);
|
endpoint.setMostSpecificMethod(mostSpecificMethod);
|
||||||
|
|
@ -264,6 +273,17 @@ public class JmsListenerAnnotationBeanPostProcessor
|
||||||
this.registrar.registerEndpoint(endpoint, factory);
|
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) {
|
private String getEndpointId(JmsListener jmsListener) {
|
||||||
if (StringUtils.hasText(jmsListener.id())) {
|
if (StringUtils.hasText(jmsListener.id())) {
|
||||||
return resolve(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) {
|
public void setBean(Object bean) {
|
||||||
this.bean = 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) {
|
public void setMethod(Method method) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
|
|
@ -146,6 +146,7 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an empty {@link MessagingMessageListenerAdapter} instance.
|
* Create an empty {@link MessagingMessageListenerAdapter} instance.
|
||||||
|
* @return a new {@code MessagingMessageListenerAdapter} or subclass thereof
|
||||||
*/
|
*/
|
||||||
protected MessagingMessageListenerAdapter createMessageListenerInstance() {
|
protected MessagingMessageListenerAdapter createMessageListenerInstance() {
|
||||||
return new MessagingMessageListenerAdapter();
|
return new MessagingMessageListenerAdapter();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue