|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2015 the original author or authors. |
|
|
|
|
* Copyright 2002-2016 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -83,18 +83,10 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -83,18 +83,10 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
|
|
|
|
|
protected final Log logger = LogFactory.getLog(getClass()); |
|
|
|
|
|
|
|
|
|
private Collection<String> destinationPrefixes = new ArrayList<String>(); |
|
|
|
|
|
|
|
|
|
private final List<HandlerMethodArgumentResolver> customArgumentResolvers = new ArrayList<HandlerMethodArgumentResolver>(4); |
|
|
|
|
|
|
|
|
|
private final List<HandlerMethodReturnValueHandler> customReturnValueHandlers = new ArrayList<HandlerMethodReturnValueHandler>(4); |
|
|
|
|
|
|
|
|
|
private HandlerMethodArgumentResolverComposite argumentResolvers = new HandlerMethodArgumentResolverComposite(); |
|
|
|
|
|
|
|
|
|
private HandlerMethodReturnValueHandlerComposite returnValueHandlers =new HandlerMethodReturnValueHandlerComposite(); |
|
|
|
|
|
|
|
|
|
private ApplicationContext applicationContext; |
|
|
|
|
|
|
|
|
|
private final Map<T, HandlerMethod> handlerMethods = new LinkedHashMap<T, HandlerMethod>(); |
|
|
|
|
|
|
|
|
|
private final MultiValueMap<String, T> destinationLookup = new LinkedMultiValueMap<String, T>(); |
|
|
|
|
@ -105,6 +97,20 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -105,6 +97,20 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
private final Map<MessagingAdviceBean, AbstractExceptionHandlerMethodResolver> exceptionHandlerAdviceCache = |
|
|
|
|
new LinkedHashMap<MessagingAdviceBean, AbstractExceptionHandlerMethodResolver>(64); |
|
|
|
|
|
|
|
|
|
private Collection<String> destinationPrefixes = new ArrayList<String>(); |
|
|
|
|
|
|
|
|
|
private HandlerMethodArgumentResolverComposite argumentResolvers = new HandlerMethodArgumentResolverComposite(); |
|
|
|
|
|
|
|
|
|
private HandlerMethodReturnValueHandlerComposite returnValueHandlers =new HandlerMethodReturnValueHandlerComposite(); |
|
|
|
|
|
|
|
|
|
private ApplicationContext applicationContext; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the configured destination prefixes. |
|
|
|
|
*/ |
|
|
|
|
public Collection<String> getDestinationPrefixes() { |
|
|
|
|
return this.destinationPrefixes; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* When this property is configured only messages to destinations matching |
|
|
|
|
@ -125,10 +131,10 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -125,10 +131,10 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the configured destination prefixes. |
|
|
|
|
* Return the configured custom argument resolvers, if any. |
|
|
|
|
*/ |
|
|
|
|
public Collection<String> getDestinationPrefixes() { |
|
|
|
|
return this.destinationPrefixes; |
|
|
|
|
public List<HandlerMethodArgumentResolver> getCustomArgumentResolvers() { |
|
|
|
|
return this.customArgumentResolvers; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -144,10 +150,10 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -144,10 +150,10 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the configured custom argument resolvers, if any. |
|
|
|
|
* Return the configured custom return value handlers, if any. |
|
|
|
|
*/ |
|
|
|
|
public List<HandlerMethodArgumentResolver> getCustomArgumentResolvers() { |
|
|
|
|
return this.customArgumentResolvers; |
|
|
|
|
public List<HandlerMethodReturnValueHandler> getCustomReturnValueHandlers() { |
|
|
|
|
return this.customReturnValueHandlers; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -162,11 +168,8 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -162,11 +168,8 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the configured custom return value handlers, if any. |
|
|
|
|
*/ |
|
|
|
|
public List<HandlerMethodReturnValueHandler> getCustomReturnValueHandlers() { |
|
|
|
|
return this.customReturnValueHandlers; |
|
|
|
|
public List<HandlerMethodArgumentResolver> getArgumentResolvers() { |
|
|
|
|
return this.argumentResolvers.getResolvers(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -182,8 +185,8 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -182,8 +185,8 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
this.argumentResolvers.addResolvers(argumentResolvers); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<HandlerMethodArgumentResolver> getArgumentResolvers() { |
|
|
|
|
return this.argumentResolvers.getResolvers(); |
|
|
|
|
public List<HandlerMethodReturnValueHandler> getReturnValueHandlers() { |
|
|
|
|
return this.returnValueHandlers.getReturnValueHandlers(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -199,10 +202,6 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -199,10 +202,6 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
this.returnValueHandlers.addHandlers(returnValueHandlers); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<HandlerMethodReturnValueHandler> getReturnValueHandlers() { |
|
|
|
|
return this.returnValueHandlers.getReturnValueHandlers(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return a map with all handler methods and their mappings. |
|
|
|
|
*/ |
|
|
|
|
@ -210,15 +209,14 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -210,15 +209,14 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
return Collections.unmodifiableMap(this.handlerMethods); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setApplicationContext(ApplicationContext applicationContext) { |
|
|
|
|
this.applicationContext = applicationContext; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ApplicationContext getApplicationContext() { |
|
|
|
|
return this.applicationContext; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setApplicationContext(ApplicationContext applicationContext) { |
|
|
|
|
this.applicationContext = applicationContext; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void afterPropertiesSet() { |
|
|
|
|
@ -434,7 +432,7 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -434,7 +432,7 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
Collections.sort(matches, comparator); |
|
|
|
|
|
|
|
|
|
if (logger.isTraceEnabled()) { |
|
|
|
|
logger.trace("Found " + matches.size() + " methods: " + matches); |
|
|
|
|
logger.trace("Found " + matches.size() + " handler methods: " + matches); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Match bestMatch = matches.get(0); |
|
|
|
|
@ -472,7 +470,7 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -472,7 +470,7 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void handleNoMatch(Set<T> ts, String lookupDestination, Message<?> message) { |
|
|
|
|
logger.debug("No matching methods."); |
|
|
|
|
logger.debug("No matching message handler methods."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -520,7 +518,7 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -520,7 +518,7 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
protected void processHandlerMethodException(HandlerMethod handlerMethod, Exception ex, Message<?> message) { |
|
|
|
|
InvocableHandlerMethod invocable = getExceptionHandlerMethod(handlerMethod, ex); |
|
|
|
|
if (invocable == null) { |
|
|
|
|
logger.error("Unhandled exception", ex); |
|
|
|
|
logger.error("Unhandled exception from message handler method", ex); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
invocable.setMessageMethodArgumentResolvers(this.argumentResolvers); |
|
|
|
|
@ -598,7 +596,7 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -598,7 +596,7 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
|
|
|
|
|
private final HandlerMethod handlerMethod; |
|
|
|
|
|
|
|
|
|
private Match(T mapping, HandlerMethod handlerMethod) { |
|
|
|
|
public Match(T mapping, HandlerMethod handlerMethod) { |
|
|
|
|
this.mapping = mapping; |
|
|
|
|
this.handlerMethod = handlerMethod; |
|
|
|
|
} |
|
|
|
|
@ -631,7 +629,6 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -631,7 +629,6 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
|
|
|
|
|
private final Message<?> message; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ReturnValueListenableFutureCallback(InvocableHandlerMethod handlerMethod, Message<?> message) { |
|
|
|
|
this.handlerMethod = handlerMethod; |
|
|
|
|
this.message = message; |
|
|
|
|
@ -654,7 +651,7 @@ public abstract class AbstractMethodMessageHandler<T>
@@ -654,7 +651,7 @@ public abstract class AbstractMethodMessageHandler<T>
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleFailure(Throwable ex) { |
|
|
|
|
Exception cause = (ex instanceof Exception ? (Exception) ex : new RuntimeException(ex)); |
|
|
|
|
Exception cause = (ex instanceof Exception ? (Exception) ex : new IllegalStateException(ex)); |
|
|
|
|
processHandlerMethodException(this.handlerMethod, cause, this.message); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|