@@ -83,9 +83,17 @@ public abstract class AbstractMethodMessageHandler<T>
83
83
84
84
protected final Log logger = LogFactory .getLog (getClass ());
85
85
86
- private final List <HandlerMethodArgumentResolver > customArgumentResolvers = new ArrayList <HandlerMethodArgumentResolver >(4 );
86
+ private final List <HandlerMethodArgumentResolver > customArgumentResolvers =
87
+ new ArrayList <HandlerMethodArgumentResolver >(4 );
87
88
88
- private final List <HandlerMethodReturnValueHandler > customReturnValueHandlers = new ArrayList <HandlerMethodReturnValueHandler >(4 );
89
+ private final List <HandlerMethodReturnValueHandler > customReturnValueHandlers =
90
+ new ArrayList <HandlerMethodReturnValueHandler >(4 );
91
+
92
+ private final HandlerMethodArgumentResolverComposite argumentResolvers =
93
+ new HandlerMethodArgumentResolverComposite ();
94
+
95
+ private final HandlerMethodReturnValueHandlerComposite returnValueHandlers =
96
+ new HandlerMethodReturnValueHandlerComposite ();
89
97
90
98
private final Map <T , HandlerMethod > handlerMethods = new LinkedHashMap <T , HandlerMethod >();
91
99
@@ -99,10 +107,6 @@ public abstract class AbstractMethodMessageHandler<T>
99
107
100
108
private Collection <String > destinationPrefixes = new ArrayList <String >();
101
109
102
- private HandlerMethodArgumentResolverComposite argumentResolvers = new HandlerMethodArgumentResolverComposite ();
103
-
104
- private HandlerMethodReturnValueHandlerComposite returnValueHandlers =new HandlerMethodReturnValueHandlerComposite ();
105
-
106
110
private ApplicationContext applicationContext ;
107
111
108
112
/**
@@ -140,7 +144,6 @@ public List<HandlerMethodArgumentResolver> getCustomArgumentResolvers() {
140
144
/**
141
145
* Sets the list of custom {@code HandlerMethodArgumentResolver}s that will be used
142
146
* after resolvers for supported argument type.
143
- * @param customArgumentResolvers the list of resolvers; never {@code null}.
144
147
*/
145
148
public void setCustomArgumentResolvers (List <HandlerMethodArgumentResolver > customArgumentResolvers ) {
146
149
this .customArgumentResolvers .clear ();
@@ -159,7 +162,6 @@ public List<HandlerMethodReturnValueHandler> getCustomReturnValueHandlers() {
159
162
/**
160
163
* Set the list of custom {@code HandlerMethodReturnValueHandler}s that will be used
161
164
* after return value handlers for known types.
162
- * @param customReturnValueHandlers the list of custom return value handlers, never {@code null}.
163
165
*/
164
166
public void setCustomReturnValueHandlers (List <HandlerMethodReturnValueHandler > customReturnValueHandlers ) {
165
167
this .customReturnValueHandlers .clear ();
@@ -168,13 +170,16 @@ public void setCustomReturnValueHandlers(List<HandlerMethodReturnValueHandler> c
168
170
}
169
171
}
170
172
173
+ /**
174
+ * Return the complete list of argument resolvers.
175
+ */
171
176
public List <HandlerMethodArgumentResolver > getArgumentResolvers () {
172
177
return this .argumentResolvers .getResolvers ();
173
178
}
174
179
175
180
/**
176
- * Configure the complete list of supported argument types effectively overriding
177
- * the ones configured by default. This is an advanced option. For most use cases
181
+ * Configure the complete list of supported argument types, effectively overriding
182
+ * the ones configured by default. This is an advanced option; for most use cases
178
183
* it should be sufficient to use {@link #setCustomArgumentResolvers}.
179
184
*/
180
185
public void setArgumentResolvers (List <HandlerMethodArgumentResolver > argumentResolvers ) {
@@ -185,13 +190,16 @@ public void setArgumentResolvers(List<HandlerMethodArgumentResolver> argumentRes
185
190
this .argumentResolvers .addResolvers (argumentResolvers );
186
191
}
187
192
193
+ /**
194
+ * Return the complete list of return value handlers.
195
+ */
188
196
public List <HandlerMethodReturnValueHandler > getReturnValueHandlers () {
189
197
return this .returnValueHandlers .getReturnValueHandlers ();
190
198
}
191
199
192
200
/**
193
- * Configure the complete list of supported return value types effectively overriding
194
- * the ones configured by default. This is an advanced option. For most use cases
201
+ * Configure the complete list of supported return value types, effectively overriding
202
+ * the ones configured by default. This is an advanced option; for most use cases
195
203
* it should be sufficient to use {@link #setCustomReturnValueHandlers}.
196
204
*/
197
205
public void setReturnValueHandlers (List <HandlerMethodReturnValueHandler > returnValueHandlers ) {
@@ -202,13 +210,6 @@ public void setReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnV
202
210
this .returnValueHandlers .addHandlers (returnValueHandlers );
203
211
}
204
212
205
- /**
206
- * Return a map with all handler methods and their mappings.
207
- */
208
- public Map <T , HandlerMethod > getHandlerMethods () {
209
- return Collections .unmodifiableMap (this .handlerMethods );
210
- }
211
-
212
213
public ApplicationContext getApplicationContext () {
213
214
return this .applicationContext ;
214
215
}
@@ -360,10 +361,19 @@ protected HandlerMethod createHandlerMethod(Object handler, Method method) {
360
361
* (e.g. to support "global" {@code @MessageExceptionHandler}).
361
362
* @since 4.2
362
363
*/
363
- protected void registerExceptionHandlerAdvice (MessagingAdviceBean bean , AbstractExceptionHandlerMethodResolver resolver ) {
364
+ protected void registerExceptionHandlerAdvice (
365
+ MessagingAdviceBean bean , AbstractExceptionHandlerMethodResolver resolver ) {
366
+
364
367
this .exceptionHandlerAdviceCache .put (bean , resolver );
365
368
}
366
369
370
+ /**
371
+ * Return a map with all handler methods and their mappings.
372
+ */
373
+ public Map <T , HandlerMethod > getHandlerMethods () {
374
+ return Collections .unmodifiableMap (this .handlerMethods );
375
+ }
376
+
367
377
368
378
@ Override
369
379
public void handleMessage (Message <?> message ) throws MessagingException {
@@ -425,7 +435,7 @@ protected void handleMessageInternal(Message<?> message, String lookupDestinatio
425
435
addMatchesToCollection (allMappings , message , matches );
426
436
}
427
437
if (matches .isEmpty ()) {
428
- handleNoMatch (handlerMethods .keySet (), lookupDestination , message );
438
+ handleNoMatch (this . handlerMethods .keySet (), lookupDestination , message );
429
439
return ;
430
440
}
431
441
Comparator <Match > comparator = new MatchComparator (getMappingComparator (message ));
@@ -449,7 +459,6 @@ protected void handleMessageInternal(Message<?> message, String lookupDestinatio
449
459
handleMatch (bestMatch .mapping , bestMatch .handlerMethod , lookupDestination , message );
450
460
}
451
461
452
-
453
462
private void addMatchesToCollection (Collection <T > mappingsToCheck , Message <?> message , List <Match > matches ) {
454
463
for (T mapping : mappingsToCheck ) {
455
464
T match = getMatchingMapping (mapping , message );
@@ -468,7 +477,6 @@ private void addMatchesToCollection(Collection<T> mappingsToCheck, Message<?> me
468
477
*/
469
478
protected abstract T getMatchingMapping (T mapping , Message <?> message );
470
479
471
-
472
480
protected void handleNoMatch (Set <T > ts , String lookupDestination , Message <?> message ) {
473
481
logger .debug ("No matching message handler methods." );
474
482
}
@@ -481,7 +489,6 @@ protected void handleNoMatch(Set<T> ts, String lookupDestination, Message<?> mes
481
489
*/
482
490
protected abstract Comparator <T > getMappingComparator (Message <?> message );
483
491
484
-
485
492
protected void handleMatch (T mapping , HandlerMethod handlerMethod , String lookupDestination , Message <?> message ) {
486
493
if (logger .isDebugEnabled ()) {
487
494
logger .debug ("Invoking " + handlerMethod .getShortLogMessage ());
@@ -579,6 +586,7 @@ protected InvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handler
579
586
protected abstract AbstractExceptionHandlerMethodResolver createExceptionHandlerMethodResolverFor (
580
587
Class <?> beanType );
581
588
589
+
582
590
@ Override
583
591
public String toString () {
584
592
return getClass ().getSimpleName () + "[prefixes=" + getDestinationPrefixes () + "]" ;
0 commit comments