|
|
|
@ -86,8 +86,8 @@ import org.springframework.validation.Validator; |
|
|
|
public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHandler<SimpMessageMappingInfo> |
|
|
|
public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHandler<SimpMessageMappingInfo> |
|
|
|
implements EmbeddedValueResolverAware, SmartLifecycle { |
|
|
|
implements EmbeddedValueResolverAware, SmartLifecycle { |
|
|
|
|
|
|
|
|
|
|
|
private static final boolean completableFuturePresent = ClassUtils.isPresent("java.util.concurrent.CompletableFuture", |
|
|
|
private static final boolean completableFuturePresent = ClassUtils.isPresent( |
|
|
|
SimpAnnotationMethodMessageHandler.class.getClassLoader()); |
|
|
|
"java.util.concurrent.CompletableFuture", SimpAnnotationMethodMessageHandler.class.getClassLoader()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final SubscribableChannel clientInboundChannel; |
|
|
|
private final SubscribableChannel clientInboundChannel; |
|
|
|
@ -304,9 +304,8 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected List<HandlerMethodArgumentResolver> initArgumentResolvers() { |
|
|
|
protected List<HandlerMethodArgumentResolver> initArgumentResolvers() { |
|
|
|
ConfigurableBeanFactory beanFactory = |
|
|
|
ConfigurableBeanFactory beanFactory = (getApplicationContext() instanceof ConfigurableApplicationContext ? |
|
|
|
(ClassUtils.isAssignableValue(ConfigurableApplicationContext.class, getApplicationContext())) ? |
|
|
|
((ConfigurableApplicationContext) getApplicationContext()).getBeanFactory() : null); |
|
|
|
((ConfigurableApplicationContext) getApplicationContext()).getBeanFactory() : null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<HandlerMethodArgumentResolver>(); |
|
|
|
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<HandlerMethodArgumentResolver>(); |
|
|
|
|
|
|
|
|
|
|
|
@ -327,7 +326,6 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers() { |
|
|
|
protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers() { |
|
|
|
|
|
|
|
|
|
|
|
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<HandlerMethodReturnValueHandler>(); |
|
|
|
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<HandlerMethodReturnValueHandler>(); |
|
|
|
|
|
|
|
|
|
|
|
// Single-purpose return value types
|
|
|
|
// Single-purpose return value types
|
|
|
|
@ -337,11 +335,13 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Annotation-based return value types
|
|
|
|
// Annotation-based return value types
|
|
|
|
SendToMethodReturnValueHandler sth = new SendToMethodReturnValueHandler(this.brokerTemplate, true); |
|
|
|
SendToMethodReturnValueHandler sth = |
|
|
|
|
|
|
|
new SendToMethodReturnValueHandler(this.brokerTemplate, true); |
|
|
|
sth.setHeaderInitializer(this.headerInitializer); |
|
|
|
sth.setHeaderInitializer(this.headerInitializer); |
|
|
|
handlers.add(sth); |
|
|
|
handlers.add(sth); |
|
|
|
|
|
|
|
|
|
|
|
SubscriptionMethodReturnValueHandler sh = new SubscriptionMethodReturnValueHandler(this.clientMessagingTemplate); |
|
|
|
SubscriptionMethodReturnValueHandler sh = |
|
|
|
|
|
|
|
new SubscriptionMethodReturnValueHandler(this.clientMessagingTemplate); |
|
|
|
sh.setHeaderInitializer(this.headerInitializer); |
|
|
|
sh.setHeaderInitializer(this.headerInitializer); |
|
|
|
handlers.add(sh); |
|
|
|
handlers.add(sh); |
|
|
|
|
|
|
|
|
|
|
|
@ -468,13 +468,15 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan |
|
|
|
protected void handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handlerMethod, |
|
|
|
protected void handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handlerMethod, |
|
|
|
String lookupDestination, Message<?> message) { |
|
|
|
String lookupDestination, Message<?> message) { |
|
|
|
|
|
|
|
|
|
|
|
String matchedPattern = mapping.getDestinationConditions().getPatterns().iterator().next(); |
|
|
|
Set<String> patterns = mapping.getDestinationConditions().getPatterns(); |
|
|
|
Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(matchedPattern, lookupDestination); |
|
|
|
if (!CollectionUtils.isEmpty(patterns)) { |
|
|
|
|
|
|
|
String pattern = patterns.iterator().next(); |
|
|
|
|
|
|
|
Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(pattern, lookupDestination); |
|
|
|
if (!CollectionUtils.isEmpty(vars)) { |
|
|
|
if (!CollectionUtils.isEmpty(vars)) { |
|
|
|
MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class); |
|
|
|
MessageHeaderAccessor mha = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class); |
|
|
|
Assert.state(accessor != null && accessor.isMutable()); |
|
|
|
Assert.state(mha != null && mha.isMutable()); |
|
|
|
accessor.setHeader(DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER, vars); |
|
|
|
mha.setHeader(DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER, vars); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|