org.springframework.messaging.handler.HandlerMethod to incoming messages
Also supports discovering and invoking exception handling methods to process exceptions raised during message handling.
| Modifier and Type | Class and Description |
|---|---|
| private class | AbstractMethodMessageHandler.
A thin wrapper around a matched HandlerMethod and its matched mapping for the purpose of comparing the best match with a comparator in the context of a message. |
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private ApplicationContext | |
| private final HandlerMethodArgumentResolverComposite | |
| private final List | |
| private final List | |
| private final MultiValueMap | |
| private final List | |
| private final Map | |
| private final Map | |
| private Log | |
| private final Map | |
| protected final Log | |
| private final HandlerMethodReturnValueHandlerComposite | |
| private static final String | SCOPED_TARGET_NAME_PREFIX
Bean name prefix for target beans behind scoped proxies. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | addMatchesToCollection(Collection<T> mappingsToCheck, Message<?> message, List<AbstractMethodMessageHandler<T>.
|
| public void | afterPropertiesSet()
Implements org. Invoked by the containing This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. |
| protected abstract AbstractExceptionHandlerMethodResolver | |
| protected HandlerMethod | createHandlerMethod(Object handler, Method method)
Create a HandlerMethod instance from an Object handler that is either a handler instance or a String-based bean name. |
| protected final void | detectHandlerMethods(final Object
the handler to check, either an instance of a Spring bean name handler)Detect if the given handler has any methods that can handle messages and if so register it with the extracted mapping information. |
| private String | |
| public ApplicationContext | |
| public List | |
| public List | |
| public List | |
| protected abstract String | |
| public Collection | |
| protected abstract Set | getDirectLookupDestinations(T mapping)
Return destinations contained in the mapping that are not patterns and are therefore suitable for direct lookups. |
| protected InvocableHandlerMethod | Returns: a method to handle the exception, ornullthe method where the exception was raised handlerMethod, Exception the raised exception exception)Find an |
| protected Log | |
| public Map | |
| protected String | getLookupDestination(String destination)
Check whether the given destination (of an incoming message) matches to one of the configured destination prefixes and if so return the remaining portion of the destination after the matched prefix. |
| protected abstract Comparator | Returns: the comparator, nevernullthe current Message message)Return a comparator for sorting matching mappings. |
| protected abstract T | Returns: the mapping, ornull if the method is not mappedthe method to provide a mapping for method, Class<?> the handler type, possibly a subtype of the method's declaring class handlerType)Provide the mapping for a handler method. |
| protected abstract T | Returns: the match ornull if there is no matchthe mapping to get a match for mapping, Message<?> the message being handled message)Check if a mapping matches the current message and return a possibly new mapping with conditions relevant to the current request. |
| protected Log | |
| public List | |
| protected void | |
| public void | handleMessage(Message<?>
the message to be handled message)Implements org. Handle the given message. |
| protected void | |
| protected void | |
| protected abstract List | |
| protected abstract List | |
| protected abstract boolean | |
| protected void | |
| protected void | registerExceptionHandlerAdvice(MessagingAdviceBean bean, AbstractExceptionHandlerMethodResolver resolver)
Subclasses can invoke this method to populate the MessagingAdviceBean cache
(e.g. to support "global" |
| protected void | registerHandlerMethod(Object
the bean name of the handler or the handler instance handler, Method the method to register method, T the mapping conditions associated with the handler method mapping)Register a handler method and its unique mapping. |
| public void | setApplicationContext(ApplicationContext
the ApplicationContext object to be used by this object applicationContext)Implements org. Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object. |
| public void | setArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)
Configure the complete list of supported argument types, effectively overriding the ones configured by default. |
| public void | setCustomArgumentResolvers(List<HandlerMethodArgumentResolver> customArgumentResolvers)
Sets the list of custom |
| public void | setCustomReturnValueHandlers(List<HandlerMethodReturnValueHandler> customReturnValueHandlers)
Set the list of custom |
| public void | setDestinationPrefixes(Collection<String> prefixes)
When this property is configured only messages to destinations matching one of the configured prefixes are eligible for handling. |
| public void | setReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)
Configure the complete list of supported return value types, effectively overriding the ones configured by default. |
| public String |
| applicationContext | back to summary |
|---|---|
| private ApplicationContext applicationContext
| |
| argumentResolvers | back to summary |
|---|---|
| private final HandlerMethodArgumentResolverComposite argumentResolvers | |
| customArgumentResolvers | back to summary |
|---|---|
| private final List<HandlerMethodArgumentResolver> customArgumentResolvers | |
| customReturnValueHandlers | back to summary |
|---|---|
| private final List<HandlerMethodReturnValueHandler> customReturnValueHandlers | |
| destinationLookup | back to summary |
|---|---|
| private final MultiValueMap<String, T> destinationLookup | |
| destinationPrefixes | back to summary |
|---|---|
| private final List<String> destinationPrefixes | |
| exceptionHandlerAdviceCache | back to summary |
|---|---|
| private final Map<MessagingAdviceBean, AbstractExceptionHandlerMethodResolver> exceptionHandlerAdviceCache | |
| exceptionHandlerCache | back to summary |
|---|---|
| private final Map<Class<?>, AbstractExceptionHandlerMethodResolver> exceptionHandlerCache | |
| handlerMethodLogger | back to summary |
|---|---|
| private Log handlerMethodLogger
| |
| handlerMethods | back to summary |
|---|---|
| private final Map<T, HandlerMethod> handlerMethods | |
| logger | back to summary |
|---|---|
| protected final Log logger | |
| returnValueHandlers | back to summary |
|---|---|
| private final HandlerMethodReturnValueHandlerComposite returnValueHandlers | |
| SCOPED_TARGET_NAME_PREFIX | back to summary |
|---|---|
| private static final String SCOPED_TARGET_NAME_PREFIX Bean name prefix for target beans behind scoped proxies. Used to exclude those targets from handler method detection, in favor of the corresponding proxies. We're not checking the autowire-candidate status here, which is how the
proxy target filtering problem is being handled at the autowiring level,
since autowire-candidate may have been turned to Originally defined in | |
| AbstractMethodMessageHandler | back to summary |
|---|---|
| public AbstractMethodMessageHandler() | |
| addMatchesToCollection | back to summary |
|---|---|
| private void addMatchesToCollection(Collection<T> mappingsToCheck, Message<?> message, List<AbstractMethodMessageHandler<T>. | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() Implements org. Doc from org. Invoked by the containing This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
| |
| createExceptionHandlerMethodResolverFor | back to summary |
|---|---|
| protected abstract AbstractExceptionHandlerMethodResolver createExceptionHandlerMethodResolverFor(Class<?> beanType) | |
| createHandlerMethod | back to summary |
|---|---|
| protected HandlerMethod createHandlerMethod(Object handler, Method method) Create a HandlerMethod instance from an Object handler that is either a handler instance or a String-based bean name. | |
| detectHandlerMethods | back to summary |
|---|---|
| protected final void detectHandlerMethods(final Object handler) Detect if the given handler has any methods that can handle messages and if so register it with the extracted mapping information.
| |
| formatMappings | back to summary |
|---|---|
| private String formatMappings(Class<?> userType, Map<Method, T> methods) | |
| getApplicationContext | back to summary |
|---|---|
public ApplicationContext getApplicationContext()
| |
| getArgumentResolvers | back to summary |
|---|---|
| public List Return the complete list of argument resolvers. | |
| getCustomArgumentResolvers | back to summary |
|---|---|
| public List Return the configured custom argument resolvers, if any. | |
| getCustomReturnValueHandlers | back to summary |
|---|---|
| public List Return the configured custom return value handlers, if any. | |
| getDestination | back to summary |
|---|---|
protected abstract String getDestination(Message<?> message)
| |
| getDestinationPrefixes | back to summary |
|---|---|
| public Collection Return the configured destination prefixes, if any. | |
| getDirectLookupDestinations | back to summary |
|---|---|
| protected abstract Set Return destinations contained in the mapping that are not patterns and are therefore suitable for direct lookups. | |
| getExceptionHandlerMethod | back to summary |
|---|---|
| protected InvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) Find an
| |
| getHandlerMethodLogger | back to summary |
|---|---|
| protected Log getHandlerMethodLogger() Return a logger to set on
| |
| getHandlerMethods | back to summary |
|---|---|
| public Map Return a map with all handler methods and their mappings. | |
| getLookupDestination | back to summary |
|---|---|
| protected String getLookupDestination(String destination) Check whether the given destination (of an incoming message) matches to one of the configured destination prefixes and if so return the remaining portion of the destination after the matched prefix. If there are no matching prefixes, return If there are no destination prefixes, return the destination as is.
| |
| getMappingComparator | back to summary |
|---|---|
| protected abstract Comparator Return a comparator for sorting matching mappings. The returned comparator should sort 'better' matches higher.
| |
| getMappingForMethod | back to summary |
|---|---|
| protected abstract T getMappingForMethod(Method method, Class<?> handlerType) Provide the mapping for a handler method. | |
| getMatchingMapping | back to summary |
|---|---|
| protected abstract T getMatchingMapping(T mapping, Message<?> message) Check if a mapping matches the current message and return a possibly new mapping with conditions relevant to the current request. | |
| getReturnValueHandlerLogger | back to summary |
|---|---|
| protected Log getReturnValueHandlerLogger() Return a logger to set on
| |
| getReturnValueHandlers | back to summary |
|---|---|
| public List Return the complete list of return value handlers. | |
| handleMatch | back to summary |
|---|---|
| protected void handleMatch(T mapping, HandlerMethod handlerMethod, String lookupDestination, Message<?> message) | |
| handleMessage | back to summary |
|---|---|
| public void handleMessage(Message<?> message) throws MessagingException Implements org. Doc from org. Handle the given message.
| |
| handleMessageInternal | back to summary |
|---|---|
| protected void handleMessageInternal(Message<?> message, String lookupDestination) | |
| handleNoMatch | back to summary |
|---|---|
| protected void handleNoMatch(Set<T> ts, String lookupDestination, Message<?> message) | |
| initArgumentResolvers | back to summary |
|---|---|
| protected abstract List Return the list of argument resolvers to use. Invoked only if the resolvers
have not already been set via Subclasses should also take into account custom argument types configured via
| |
| initReturnValueHandlers | back to summary |
|---|---|
| protected abstract List Return the list of return value handlers to use. Invoked only if the return
value handlers have not already been set via Subclasses should also take into account custom return value types configured
via | |
| isHandler | back to summary |
|---|---|
| protected abstract boolean isHandler(Class<?> beanType) Whether the given bean type should be introspected for messaging handling methods. | |
| processHandlerMethodException | back to summary |
|---|---|
| protected void processHandlerMethodException(HandlerMethod handlerMethod, Exception exception, Message<?> message) | |
| registerExceptionHandlerAdvice | back to summary |
|---|---|
| protected void registerExceptionHandlerAdvice(MessagingAdviceBean bean, AbstractExceptionHandlerMethodResolver resolver) Subclasses can invoke this method to populate the MessagingAdviceBean cache
(e.g. to support "global"
| |
| registerHandlerMethod | back to summary |
|---|---|
| protected void registerHandlerMethod(Object handler, Method method, T mapping) Register a handler method and its unique mapping.
| |
| setApplicationContext | back to summary |
|---|---|
| public void setApplicationContext(ApplicationContext applicationContext) Implements org. Doc from org. Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object. Invoked after population of normal bean properties but before an init callback such
as
| |
| setArgumentResolvers | back to summary |
|---|---|
| public void setArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) Configure the complete list of supported argument types, effectively overriding
the ones configured by default. This is an advanced option; for most use cases
it should be sufficient to use | |
| setCustomArgumentResolvers | back to summary |
|---|---|
| public void setCustomArgumentResolvers(List<HandlerMethodArgumentResolver> customArgumentResolvers) Sets the list of custom | |
| setCustomReturnValueHandlers | back to summary |
|---|---|
| public void setCustomReturnValueHandlers(List<HandlerMethodReturnValueHandler> customReturnValueHandlers) Set the list of custom | |
| setDestinationPrefixes | back to summary |
|---|---|
| public void setDestinationPrefixes(Collection<String> prefixes) When this property is configured only messages to destinations matching one of the configured prefixes are eligible for handling. When there is a match the prefix is removed and only the remaining part of the destination is used for method-mapping purposes. By default, no prefixes are configured in which case all messages are eligible for handling. | |
| setReturnValueHandlers | back to summary |
|---|---|
| public void setReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) Configure the complete list of supported return value types, effectively overriding
the ones configured by default. This is an advanced option; for most use cases
it should be sufficient to use | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Modifier and Type | Field and Description |
|---|---|
| private final HandlerMethod | |
| private final T |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String |
| handlerMethod | back to summary |
|---|---|
| private final HandlerMethod handlerMethod | |
| mapping | back to summary |
|---|---|
| private final T mapping | |
| Match | back to summary |
|---|---|
| public Match(T mapping, HandlerMethod handlerMethod) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Modifier and Type | Field and Description |
|---|---|
| private final Comparator |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | compare(AbstractMethodMessageHandler<T>.
the first object to be compared. match1,the second object to be compared. match2Implements java. Compares its two arguments for order. |
| comparator | back to summary |
|---|---|
| private final Comparator<T> comparator | |
| MatchComparator | back to summary |
|---|---|
| public MatchComparator(Comparator<T> comparator) | |
| compare | back to summary |
|---|---|
| public int compare(AbstractMethodMessageHandler<T>. Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| Modifier and Type | Field and Description |
|---|---|
| private final InvocableHandlerMethod | |
| private final Message |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | accept(Object
the first input argument result, Throwable the second input argument ex)Implements java. Performs this operation on the given arguments. |
| private void |
| handlerMethod | back to summary |
|---|---|
| private final InvocableHandlerMethod handlerMethod | |
| message | back to summary |
|---|---|
| private final Message<?> message | |
| ReturnValueListenableFutureCallback | back to summary |
|---|---|
| public ReturnValueListenableFutureCallback(InvocableHandlerMethod handlerMethod, Message<?> message) | |
| accept | back to summary |
|---|---|
| public void accept(Object result, Throwable ex) Implements java. Doc from java. Performs this operation on the given arguments. | |
| handleFailure | back to summary |
|---|---|
| private void handleFailure(Throwable throwable) | |