public class DefaultMessageHandlerMethodFactory extends java.lang.Object implements MessageHandlerMethodFactory, BeanFactoryAware, InitializingBean
MessageHandlerMethodFactory
implementation creating an
InvocableHandlerMethod
with the necessary
HandlerMethodArgumentResolver
instances to detect and process
most of the use cases defined by
MessageMapping
.
Extra method argument resolvers can be added to customize the method signature that can be handled.
By default, the validation process redirects to a no-op implementation, see
setValidator(Validator)
to customize it. The ConversionService
can be customized in a similar manner to tune how the message payload
can be converted
setConversionService(org.springframework.core.convert.ConversionService)
,
setValidator(org.springframework.validation.Validator)
,
setCustomArgumentResolvers(java.util.List<org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver>)
Modifier and Type | Field and Description |
---|---|
private HandlerMethodArgumentResolverComposite |
argumentResolvers |
private BeanFactory |
beanFactory |
private ConversionService |
conversionService |
private java.util.List<HandlerMethodArgumentResolver> |
customArgumentResolvers |
private MessageConverter |
messageConverter |
private Validator |
validator |
Constructor and Description |
---|
DefaultMessageHandlerMethodFactory() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , ApplicationContextAware etc. |
InvocableHandlerMethod |
createInvocableHandlerMethod(java.lang.Object bean,
java.lang.reflect.Method method)
Create the
InvocableHandlerMethod that is able to process the specified
method endpoint. |
protected java.util.List<HandlerMethodArgumentResolver> |
initArgumentResolvers() |
void |
setArgumentResolvers(java.util.List<HandlerMethodArgumentResolver> argumentResolvers)
Configure the complete list of supported argument types effectively overriding
the ones configured by default.
|
void |
setBeanFactory(BeanFactory beanFactory)
A
BeanFactory only needs to be available for placeholder resolution
in handler method arguments; it's optional otherwise. |
void |
setConversionService(ConversionService conversionService)
Set the
ConversionService to use to convert the original
message payload or headers. |
void |
setCustomArgumentResolvers(java.util.List<HandlerMethodArgumentResolver> customArgumentResolvers)
Set the list of custom
HandlerMethodArgumentResolver s that will be used
after resolvers for supported argument type. |
void |
setMessageConverter(MessageConverter messageConverter)
Set the
MessageConverter to use. |
void |
setValidator(Validator validator)
Set the Validator instance used for validating
@Payload arguments. |
private ConversionService conversionService
@Nullable private MessageConverter messageConverter
@Nullable private java.util.List<HandlerMethodArgumentResolver> customArgumentResolvers
private final HandlerMethodArgumentResolverComposite argumentResolvers
@Nullable private BeanFactory beanFactory
public void setConversionService(ConversionService conversionService)
ConversionService
to use to convert the original
message payload or headers.public void setMessageConverter(MessageConverter messageConverter)
MessageConverter
to use. By default a GenericMessageConverter
is used.GenericMessageConverter
public void setValidator(Validator validator)
@Payload
arguments.Validated
,
PayloadArgumentResolver
public void setCustomArgumentResolvers(java.util.List<HandlerMethodArgumentResolver> customArgumentResolvers)
HandlerMethodArgumentResolver
s that will be used
after resolvers for supported argument type.customArgumentResolvers
- the list of resolvers (never null
)public void setArgumentResolvers(java.util.List<HandlerMethodArgumentResolver> argumentResolvers)
setCustomArgumentResolvers(java.util.List)
.public void setBeanFactory(BeanFactory beanFactory)
BeanFactory
only needs to be available for placeholder resolution
in handler method arguments; it's optional otherwise.setBeanFactory
in interface BeanFactoryAware
beanFactory
- owning BeanFactory (never null
).
The bean can immediately call methods on the factory.BeanInitializationException
public void afterPropertiesSet()
InitializingBean
BeanFactory
after it has set all bean properties
and satisfied BeanFactoryAware
, ApplicationContextAware
etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
afterPropertiesSet
in interface InitializingBean
public InvocableHandlerMethod createInvocableHandlerMethod(java.lang.Object bean, java.lang.reflect.Method method)
MessageHandlerMethodFactory
InvocableHandlerMethod
that is able to process the specified
method endpoint.createInvocableHandlerMethod
in interface MessageHandlerMethodFactory
bean
- the bean instancemethod
- the method to invokeInvocableHandlerMethod
suitable for that methodprotected java.util.List<HandlerMethodArgumentResolver> initArgumentResolvers()