11/*
2- * Copyright 2002-2015 the original author or authors.
2+ * Copyright 2002-2016 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -83,18 +83,10 @@ public abstract class AbstractMethodMessageHandler<T>
8383
8484 protected final Log logger = LogFactory .getLog (getClass ());
8585
86- private Collection <String > destinationPrefixes = new ArrayList <String >();
87-
8886 private final List <HandlerMethodArgumentResolver > customArgumentResolvers = new ArrayList <HandlerMethodArgumentResolver >(4 );
8987
9088 private final List <HandlerMethodReturnValueHandler > customReturnValueHandlers = new ArrayList <HandlerMethodReturnValueHandler >(4 );
9189
92- private HandlerMethodArgumentResolverComposite argumentResolvers = new HandlerMethodArgumentResolverComposite ();
93-
94- private HandlerMethodReturnValueHandlerComposite returnValueHandlers =new HandlerMethodReturnValueHandlerComposite ();
95-
96- private ApplicationContext applicationContext ;
97-
9890 private final Map <T , HandlerMethod > handlerMethods = new LinkedHashMap <T , HandlerMethod >();
9991
10092 private final MultiValueMap <String , T > destinationLookup = new LinkedMultiValueMap <String , T >();
@@ -105,6 +97,20 @@ public abstract class AbstractMethodMessageHandler<T>
10597 private final Map <MessagingAdviceBean , AbstractExceptionHandlerMethodResolver > exceptionHandlerAdviceCache =
10698 new LinkedHashMap <MessagingAdviceBean , AbstractExceptionHandlerMethodResolver >(64 );
10799
100+ private Collection <String > destinationPrefixes = new ArrayList <String >();
101+
102+ private HandlerMethodArgumentResolverComposite argumentResolvers = new HandlerMethodArgumentResolverComposite ();
103+
104+ private HandlerMethodReturnValueHandlerComposite returnValueHandlers =new HandlerMethodReturnValueHandlerComposite ();
105+
106+ private ApplicationContext applicationContext ;
107+
108+ /**
109+ * Return the configured destination prefixes.
110+ */
111+ public Collection <String > getDestinationPrefixes () {
112+ return this .destinationPrefixes ;
113+ }
108114
109115 /**
110116 * When this property is configured only messages to destinations matching
@@ -125,10 +131,10 @@ public void setDestinationPrefixes(Collection<String> prefixes) {
125131 }
126132
127133 /**
128- * Return the configured destination prefixes .
134+ * Return the configured custom argument resolvers, if any .
129135 */
130- public Collection < String > getDestinationPrefixes () {
131- return this .destinationPrefixes ;
136+ public List < HandlerMethodArgumentResolver > getCustomArgumentResolvers () {
137+ return this .customArgumentResolvers ;
132138 }
133139
134140 /**
@@ -144,10 +150,10 @@ public void setCustomArgumentResolvers(List<HandlerMethodArgumentResolver> custo
144150 }
145151
146152 /**
147- * Return the configured custom argument resolvers , if any.
153+ * Return the configured custom return value handlers , if any.
148154 */
149- public List <HandlerMethodArgumentResolver > getCustomArgumentResolvers () {
150- return this .customArgumentResolvers ;
155+ public List <HandlerMethodReturnValueHandler > getCustomReturnValueHandlers () {
156+ return this .customReturnValueHandlers ;
151157 }
152158
153159 /**
@@ -162,11 +168,8 @@ public void setCustomReturnValueHandlers(List<HandlerMethodReturnValueHandler> c
162168 }
163169 }
164170
165- /**
166- * Return the configured custom return value handlers, if any.
167- */
168- public List <HandlerMethodReturnValueHandler > getCustomReturnValueHandlers () {
169- return this .customReturnValueHandlers ;
171+ public List <HandlerMethodArgumentResolver > getArgumentResolvers () {
172+ return this .argumentResolvers .getResolvers ();
170173 }
171174
172175 /**
@@ -182,8 +185,8 @@ public void setArgumentResolvers(List<HandlerMethodArgumentResolver> argumentRes
182185 this .argumentResolvers .addResolvers (argumentResolvers );
183186 }
184187
185- public List <HandlerMethodArgumentResolver > getArgumentResolvers () {
186- return this .argumentResolvers . getResolvers ();
188+ public List <HandlerMethodReturnValueHandler > getReturnValueHandlers () {
189+ return this .returnValueHandlers . getReturnValueHandlers ();
187190 }
188191
189192 /**
@@ -199,26 +202,21 @@ public void setReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnV
199202 this .returnValueHandlers .addHandlers (returnValueHandlers );
200203 }
201204
202- public List <HandlerMethodReturnValueHandler > getReturnValueHandlers () {
203- return this .returnValueHandlers .getReturnValueHandlers ();
204- }
205-
206205 /**
207206 * Return a map with all handler methods and their mappings.
208207 */
209208 public Map <T , HandlerMethod > getHandlerMethods () {
210209 return Collections .unmodifiableMap (this .handlerMethods );
211210 }
212211
213- @ Override
214- public void setApplicationContext (ApplicationContext applicationContext ) {
215- this .applicationContext = applicationContext ;
216- }
217-
218212 public ApplicationContext getApplicationContext () {
219213 return this .applicationContext ;
220214 }
221215
216+ @ Override
217+ public void setApplicationContext (ApplicationContext applicationContext ) {
218+ this .applicationContext = applicationContext ;
219+ }
222220
223221 @ Override
224222 public void afterPropertiesSet () {
@@ -434,7 +432,7 @@ protected void handleMessageInternal(Message<?> message, String lookupDestinatio
434432 Collections .sort (matches , comparator );
435433
436434 if (logger .isTraceEnabled ()) {
437- logger .trace ("Found " + matches .size () + " methods: " + matches );
435+ logger .trace ("Found " + matches .size () + " handler methods: " + matches );
438436 }
439437
440438 Match bestMatch = matches .get (0 );
@@ -472,7 +470,7 @@ private void addMatchesToCollection(Collection<T> mappingsToCheck, Message<?> me
472470
473471
474472 protected void handleNoMatch (Set <T > ts , String lookupDestination , Message <?> message ) {
475- logger .debug ("No matching methods." );
473+ logger .debug ("No matching message handler methods." );
476474 }
477475
478476 /**
@@ -520,7 +518,7 @@ protected void handleMatch(T mapping, HandlerMethod handlerMethod, String lookup
520518 protected void processHandlerMethodException (HandlerMethod handlerMethod , Exception ex , Message <?> message ) {
521519 InvocableHandlerMethod invocable = getExceptionHandlerMethod (handlerMethod , ex );
522520 if (invocable == null ) {
523- logger .error ("Unhandled exception" , ex );
521+ logger .error ("Unhandled exception from message handler method " , ex );
524522 return ;
525523 }
526524 invocable .setMessageMethodArgumentResolvers (this .argumentResolvers );
@@ -598,7 +596,7 @@ private class Match {
598596
599597 private final HandlerMethod handlerMethod ;
600598
601- private Match (T mapping , HandlerMethod handlerMethod ) {
599+ public Match (T mapping , HandlerMethod handlerMethod ) {
602600 this .mapping = mapping ;
603601 this .handlerMethod = handlerMethod ;
604602 }
@@ -631,7 +629,6 @@ private class ReturnValueListenableFutureCallback implements ListenableFutureCal
631629
632630 private final Message <?> message ;
633631
634-
635632 public ReturnValueListenableFutureCallback (InvocableHandlerMethod handlerMethod , Message <?> message ) {
636633 this .handlerMethod = handlerMethod ;
637634 this .message = message ;
@@ -654,7 +651,7 @@ public void onFailure(Throwable ex) {
654651 }
655652
656653 private void handleFailure (Throwable ex ) {
657- Exception cause = (ex instanceof Exception ? (Exception ) ex : new RuntimeException (ex ));
654+ Exception cause = (ex instanceof Exception ? (Exception ) ex : new IllegalStateException (ex ));
658655 processHandlerMethodException (this .handlerMethod , cause , this .message );
659656 }
660657 }
0 commit comments