Skip to content

Commit 9589749

Browse files
committed
Introduced createMethodJmsListenerEndpoint template method
Issue: SPR-13774
1 parent b3115fc commit 9589749

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,19 @@ public Set<JmsListener> inspect(Method method) {
226226
return bean;
227227
}
228228

229+
/**
230+
* Process the given {@link JmsListener} annotation on the given method,
231+
* registering a corresponding endpoint for the given bean instance.
232+
* @param jmsListener the annotation to process
233+
* @param mostSpecificMethod the annotated method
234+
* @param bean the instance to invoke the method on
235+
* @see #createMethodJmsListenerEndpoint()
236+
* @see JmsListenerEndpointRegistrar#registerEndpoint
237+
*/
229238
protected void processJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean) {
230239
Method invocableMethod = MethodIntrospector.selectInvocableMethod(mostSpecificMethod, bean.getClass());
231240

232-
MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint();
241+
MethodJmsListenerEndpoint endpoint = createMethodJmsListenerEndpoint();
233242
endpoint.setBean(bean);
234243
endpoint.setMethod(invocableMethod);
235244
endpoint.setMostSpecificMethod(mostSpecificMethod);
@@ -264,6 +273,17 @@ protected void processJmsListener(JmsListener jmsListener, Method mostSpecificMe
264273
this.registrar.registerEndpoint(endpoint, factory);
265274
}
266275

276+
/**
277+
* Instantiate an empty {@link MethodJmsListenerEndpoint} for further
278+
* configuration with provided parameters in {@link #processJmsListener}.
279+
* @return a new {@code MethodJmsListenerEndpoint} or subclass thereof
280+
* @since 4.1.9
281+
* @see MethodJmsListenerEndpoint#createMessageListenerInstance()
282+
*/
283+
protected MethodJmsListenerEndpoint createMethodJmsListenerEndpoint() {
284+
return new MethodJmsListenerEndpoint();
285+
}
286+
267287
private String getEndpointId(JmsListener jmsListener) {
268288
if (StringUtils.hasText(jmsListener.id())) {
269289
return resolve(jmsListener.id());

spring-jms/src/main/java/org/springframework/jms/config/MethodJmsListenerEndpoint.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint {
5656

5757

5858
/**
59-
* Set the object instance that should manage this endpoint.
59+
* Set the actual bean instance to invoke this endpoint method on.
6060
*/
6161
public void setBean(Object bean) {
6262
this.bean = bean;
@@ -67,7 +67,7 @@ public Object getBean() {
6767
}
6868

6969
/**
70-
* Set the method to invoke to process a message managed by this endpoint.
70+
* Set the method to invoke for processing a message managed by this endpoint.
7171
*/
7272
public void setMethod(Method method) {
7373
this.method = method;
@@ -146,6 +146,7 @@ protected MessagingMessageListenerAdapter createMessageListener(MessageListenerC
146146

147147
/**
148148
* Create an empty {@link MessagingMessageListenerAdapter} instance.
149+
* @return a new {@code MessagingMessageListenerAdapter} or subclass thereof
149150
*/
150151
protected MessagingMessageListenerAdapter createMessageListenerInstance() {
151152
return new MessagingMessageListenerAdapter();

0 commit comments

Comments
 (0)