86
86
public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHandler <SimpMessageMappingInfo >
87
87
implements EmbeddedValueResolverAware , SmartLifecycle {
88
88
89
- private static final boolean completableFuturePresent = ClassUtils .isPresent ("java.util.concurrent.CompletableFuture" ,
90
- SimpAnnotationMethodMessageHandler .class .getClassLoader ());
89
+ private static final boolean completableFuturePresent = ClassUtils .isPresent (
90
+ "java.util.concurrent.CompletableFuture" , SimpAnnotationMethodMessageHandler .class .getClassLoader ());
91
91
92
92
93
93
private final SubscribableChannel clientInboundChannel ;
@@ -304,9 +304,8 @@ public final void stop(Runnable callback) {
304
304
305
305
306
306
protected List <HandlerMethodArgumentResolver > initArgumentResolvers () {
307
- ConfigurableBeanFactory beanFactory =
308
- (ClassUtils .isAssignableValue (ConfigurableApplicationContext .class , getApplicationContext ())) ?
309
- ((ConfigurableApplicationContext ) getApplicationContext ()).getBeanFactory () : null ;
307
+ ConfigurableBeanFactory beanFactory = (getApplicationContext () instanceof ConfigurableApplicationContext ?
308
+ ((ConfigurableApplicationContext ) getApplicationContext ()).getBeanFactory () : null );
310
309
311
310
List <HandlerMethodArgumentResolver > resolvers = new ArrayList <HandlerMethodArgumentResolver >();
312
311
@@ -327,7 +326,6 @@ protected List<HandlerMethodArgumentResolver> initArgumentResolvers() {
327
326
328
327
@ Override
329
328
protected List <? extends HandlerMethodReturnValueHandler > initReturnValueHandlers () {
330
-
331
329
List <HandlerMethodReturnValueHandler > handlers = new ArrayList <HandlerMethodReturnValueHandler >();
332
330
333
331
// Single-purpose return value types
@@ -337,11 +335,13 @@ protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandler
337
335
}
338
336
339
337
// Annotation-based return value types
340
- SendToMethodReturnValueHandler sth = new SendToMethodReturnValueHandler (this .brokerTemplate , true );
338
+ SendToMethodReturnValueHandler sth =
339
+ new SendToMethodReturnValueHandler (this .brokerTemplate , true );
341
340
sth .setHeaderInitializer (this .headerInitializer );
342
341
handlers .add (sth );
343
342
344
- SubscriptionMethodReturnValueHandler sh = new SubscriptionMethodReturnValueHandler (this .clientMessagingTemplate );
343
+ SubscriptionMethodReturnValueHandler sh =
344
+ new SubscriptionMethodReturnValueHandler (this .clientMessagingTemplate );
345
345
sh .setHeaderInitializer (this .headerInitializer );
346
346
handlers .add (sh );
347
347
@@ -468,13 +468,15 @@ public int compare(SimpMessageMappingInfo info1, SimpMessageMappingInfo info2) {
468
468
protected void handleMatch (SimpMessageMappingInfo mapping , HandlerMethod handlerMethod ,
469
469
String lookupDestination , Message <?> message ) {
470
470
471
- String matchedPattern = mapping .getDestinationConditions ().getPatterns ().iterator ().next ();
472
- Map <String , String > vars = getPathMatcher ().extractUriTemplateVariables (matchedPattern , lookupDestination );
473
-
474
- if (!CollectionUtils .isEmpty (vars )) {
475
- MessageHeaderAccessor accessor = MessageHeaderAccessor .getAccessor (message , MessageHeaderAccessor .class );
476
- Assert .state (accessor != null && accessor .isMutable ());
477
- accessor .setHeader (DestinationVariableMethodArgumentResolver .DESTINATION_TEMPLATE_VARIABLES_HEADER , vars );
471
+ Set <String > patterns = mapping .getDestinationConditions ().getPatterns ();
472
+ if (!CollectionUtils .isEmpty (patterns )) {
473
+ String pattern = patterns .iterator ().next ();
474
+ Map <String , String > vars = getPathMatcher ().extractUriTemplateVariables (pattern , lookupDestination );
475
+ if (!CollectionUtils .isEmpty (vars )) {
476
+ MessageHeaderAccessor mha = MessageHeaderAccessor .getAccessor (message , MessageHeaderAccessor .class );
477
+ Assert .state (mha != null && mha .isMutable ());
478
+ mha .setHeader (DestinationVariableMethodArgumentResolver .DESTINATION_TEMPLATE_VARIABLES_HEADER , vars );
479
+ }
478
480
}
479
481
480
482
try {
0 commit comments