public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHandler<SimpMessageMappingInfo> implements SmartLifecycle
@MessageMapping
and @SubscribeMapping annotated methods.
Supports Ant-style path patterns with template variables.
logger| Constructor and Description |
|---|
SimpAnnotationMethodMessageHandler(SubscribableChannel clientInboundChannel,
MessageChannel clientOutboundChannel,
SimpMessageSendingOperations brokerTemplate)
Create an instance of SimpAnnotationMethodMessageHandler with the given
message channels and broker messaging template.
|
| Modifier and Type | Method and Description |
|---|---|
protected AbstractExceptionHandlerMethodResolver |
createExceptionHandlerMethodResolverFor(Class<?> beanType) |
ConversionService |
getConversionService()
The configured
ConversionService. |
protected String |
getDestination(Message<?> message) |
protected Set<String> |
getDirectLookupDestinations(SimpMessageMappingInfo mapping)
Return destinations contained in the mapping that are not patterns and are
therefore suitable for direct lookups.
|
protected Comparator<SimpMessageMappingInfo> |
getMappingComparator(Message<?> message)
Return a comparator for sorting matching mappings.
|
protected SimpMessageMappingInfo |
getMappingForMethod(Method method,
Class<?> handlerType)
Provide the mapping for a handler method.
|
protected SimpMessageMappingInfo |
getMatchingMapping(SimpMessageMappingInfo mapping,
Message<?> message)
Check if a mapping matches the current message and return a possibly
new mapping with conditions relevant to the current request.
|
MessageConverter |
getMessageConverter()
Return the configured
MessageConverter. |
PathMatcher |
getPathMatcher()
Return the PathMatcher implementation to use for matching destinations
|
int |
getPhase()
Return the phase value of this object.
|
Validator |
getValidator()
The configured Validator instance
|
protected void |
handleMatch(SimpMessageMappingInfo mapping,
HandlerMethod handlerMethod,
String lookupDestination,
Message<?> message) |
protected List<HandlerMethodArgumentResolver> |
initArgumentResolvers()
Return the list of argument resolvers to use.
|
protected List<? extends HandlerMethodReturnValueHandler> |
initReturnValueHandlers()
Return the list of return value handlers to use.
|
boolean |
isAutoStartup()
Return whether this Lifecycle component should be started automatically
by the container when the ApplicationContext is refreshed.
|
protected boolean |
isHandler(Class<?> beanType)
Whether the given bean type should be introspected for messaging handling methods.
|
boolean |
isRunning()
Check whether this component is currently running.
|
void |
setConversionService(ConversionService conversionService)
Configure a
ConversionService to use when resolving method arguments, for
example message header values. |
void |
setMessageConverter(MessageConverter converter)
Configure a
MessageConverter to use to convert the payload of a message
from serialize form with a specific MIME type to an Object matching the target
method parameter. |
void |
setPathMatcher(PathMatcher pathMatcher)
Set the PathMatcher implementation to use for matching destinations
against configured destination patterns.
|
void |
setValidator(Validator validator)
Set the Validator instance used for validating @Payload arguments
|
void |
start()
Start this component.
|
void |
stop()
Stop this component, typically in a synchronous fashion, such that
the component is fully stopped upon return of this method.
|
void |
stop(Runnable callback)
Indicates that a Lifecycle component must stop if it is currently running.
|
afterPropertiesSet, createHandlerMethod, detectHandlerMethods, getApplicationContext, getArgumentResolvers, getCustomArgumentResolvers, getCustomReturnValueHandlers, getDestinationPrefixes, getHandlerMethods, getLookupDestination, getReturnValueHandlers, handleMessage, handleMessageInternal, handleNoMatch, processHandlerMethodException, registerHandlerMethod, setApplicationContext, setArgumentResolvers, setCustomArgumentResolvers, setCustomReturnValueHandlers, setDestinationPrefixes, setReturnValueHandlerspublic SimpAnnotationMethodMessageHandler(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel, SimpMessageSendingOperations brokerTemplate)
clientInboundChannel - the channel for receiving messages from clients (e.g. WebSocket clients)clientOutboundChannel - the channel for messages to clients (e.g. WebSocket clients)brokerTemplate - a messaging template to send application messages to the brokerpublic void setMessageConverter(MessageConverter converter)
MessageConverter to use to convert the payload of a message
from serialize form with a specific MIME type to an Object matching the target
method parameter. The converter is also used when sending message to the message
broker.CompositeMessageConverterpublic MessageConverter getMessageConverter()
MessageConverter.public void setConversionService(ConversionService conversionService)
ConversionService to use when resolving method arguments, for
example message header values.
By default an instance of DefaultFormattingConversionService is used.
public ConversionService getConversionService()
ConversionService.public void setPathMatcher(PathMatcher pathMatcher)
By default AntPathMatcher is used
public PathMatcher getPathMatcher()
public Validator getValidator()
public void setValidator(Validator validator)
Validated,
PayloadArgumentResolverpublic boolean isAutoStartup()
SmartLifecycleisAutoStartup in interface SmartLifecyclepublic int getPhase()
Phasedpublic final boolean isRunning()
LifecycleIn the case of a container, this will return true
only if all components that apply are currently running.
public final void start()
LifecycleIn the case of a container, this will propagate the start signal to all components that apply.
public final void stop()
LifecycleSmartLifecycle and its stop(Runnable)
variant in cases where asynchronous stop behavior is necessary.
Should not throw an exception if the component isn't started yet.
In the case of a container, this will propagate the stop signal to all components that apply.
stop in interface LifecycleSmartLifecycle.stop(Runnable)public final void stop(Runnable callback)
SmartLifecycleThe provided callback is used by the LifecycleProcessor to support an
ordered, and potentially concurrent, shutdown of all components having a
common shutdown order value. The callback must be executed after
the SmartLifecycle component does indeed stop.
The LifecycleProcessor will call only this variant of the
stop method; i.e. Lifecycle.stop() will not be called for
SmartLifecycle implementations unless explicitly delegated to within
this method.
stop in interface SmartLifecycleprotected List<HandlerMethodArgumentResolver> initArgumentResolvers()
AbstractMethodMessageHandlerAbstractMethodMessageHandler.setArgumentResolvers(java.util.List).
Sub-classes should also take into account custom argument types configured via
AbstractMethodMessageHandler.setCustomArgumentResolvers(java.util.List).
initArgumentResolvers in class AbstractMethodMessageHandler<SimpMessageMappingInfo>protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers()
AbstractMethodMessageHandlerAbstractMethodMessageHandler.setReturnValueHandlers(java.util.List).
Sub-classes should also take into account custom return value types configured
via AbstractMethodMessageHandler.setCustomReturnValueHandlers(java.util.List).
initReturnValueHandlers in class AbstractMethodMessageHandler<SimpMessageMappingInfo>protected boolean isHandler(Class<?> beanType)
AbstractMethodMessageHandlerisHandler in class AbstractMethodMessageHandler<SimpMessageMappingInfo>protected SimpMessageMappingInfo getMappingForMethod(Method method, Class<?> handlerType)
AbstractMethodMessageHandlergetMappingForMethod in class AbstractMethodMessageHandler<SimpMessageMappingInfo>method - the method to provide a mapping forhandlerType - the handler type, possibly a sub-type of the method's declaring classnull if the method is not mappedprotected Set<String> getDirectLookupDestinations(SimpMessageMappingInfo mapping)
AbstractMethodMessageHandlergetDirectLookupDestinations in class AbstractMethodMessageHandler<SimpMessageMappingInfo>protected String getDestination(Message<?> message)
getDestination in class AbstractMethodMessageHandler<SimpMessageMappingInfo>protected SimpMessageMappingInfo getMatchingMapping(SimpMessageMappingInfo mapping, Message<?> message)
AbstractMethodMessageHandlergetMatchingMapping in class AbstractMethodMessageHandler<SimpMessageMappingInfo>mapping - the mapping to get a match formessage - the message being handlednull if there is no matchprotected Comparator<SimpMessageMappingInfo> getMappingComparator(Message<?> message)
AbstractMethodMessageHandlergetMappingComparator in class AbstractMethodMessageHandler<SimpMessageMappingInfo>message - the current Messagenullprotected void handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handlerMethod, String lookupDestination, Message<?> message)
handleMatch in class AbstractMethodMessageHandler<SimpMessageMappingInfo>protected AbstractExceptionHandlerMethodResolver createExceptionHandlerMethodResolverFor(Class<?> beanType)
createExceptionHandlerMethodResolverFor in class AbstractMethodMessageHandler<SimpMessageMappingInfo>