Class DefaultMessageHandlerMethodFactory
- java.lang.Object
- org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,InitializingBean
,MessageHandlerMethodFactory
public class DefaultMessageHandlerMethodFactory extends Object implements MessageHandlerMethodFactory, BeanFactoryAware, InitializingBean
The defaultMessageHandlerMethodFactory
implementation creating anInvocableHandlerMethod
with the necessaryHandlerMethodArgumentResolver
instances to detect and process most of the use cases defined byMessageMapping
.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. TheConversionService
can be customized in a similar manner to tune how the message payload can be converted- Since:
- 4.1
- Author:
- Stephane Nicoll, Juergen Hoeller
- See Also:
setConversionService(org.springframework.core.convert.ConversionService)
,setValidator(org.springframework.validation.Validator)
,setCustomArgumentResolvers(java.util.List<org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver>)
Constructor Summary
Constructors Constructor Description DefaultMessageHandlerMethodFactory()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.InvocableHandlerMethod
createInvocableHandlerMethod(Object bean, Method method)
Create theInvocableHandlerMethod
that is able to process the specified method endpoint.protected List<HandlerMethodArgumentResolver>
initArgumentResolvers()
void
setArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)
Configure the complete list of supported argument types effectively overriding the ones configured by default.void
setBeanFactory(BeanFactory beanFactory)
ABeanFactory
only needs to be available for placeholder resolution in handler method arguments; it's optional otherwise.void
setConversionService(ConversionService conversionService)
Set theConversionService
to use to convert the original message payload or headers.void
setCustomArgumentResolvers(List<HandlerMethodArgumentResolver> customArgumentResolvers)
Set the list of customHandlerMethodArgumentResolver
s that will be used after resolvers for supported argument type.void
setMessageConverter(MessageConverter messageConverter)
Set theMessageConverter
to use.void
setValidator(Validator validator)
Set the Validator instance used for validating @Payload arguments
Constructor Detail
DefaultMessageHandlerMethodFactory
public DefaultMessageHandlerMethodFactory()
Method Detail
setConversionService
public void setConversionService(ConversionService conversionService)
Set theConversionService
to use to convert the original message payload or headers.
setMessageConverter
public void setMessageConverter(MessageConverter messageConverter)
Set theMessageConverter
to use. By default aGenericMessageConverter
is used.- See Also:
GenericMessageConverter
setValidator
public void setValidator(Validator validator)
Set the Validator instance used for validating @Payload arguments- See Also:
Validated
,PayloadArgumentResolver
setCustomArgumentResolvers
public void setCustomArgumentResolvers(List<HandlerMethodArgumentResolver> customArgumentResolvers)
Set the list of customHandlerMethodArgumentResolver
s that will be used after resolvers for supported argument type.- Parameters:
customArgumentResolvers
- the list of resolvers (nevernull
)
setArgumentResolvers
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 usesetCustomArgumentResolvers(java.util.List)
.
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
ABeanFactory
only needs to be available for placeholder resolution in handler method arguments; it's optional otherwise.- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Parameters:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- See Also:
BeanInitializationException
afterPropertiesSet
public void afterPropertiesSet()
Description copied from interface:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,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.
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
createInvocableHandlerMethod
public InvocableHandlerMethod createInvocableHandlerMethod(Object bean, Method method)
Description copied from interface:MessageHandlerMethodFactory
Create theInvocableHandlerMethod
that is able to process the specified method endpoint.- Specified by:
createInvocableHandlerMethod
in interfaceMessageHandlerMethodFactory
- Parameters:
bean
- the bean instancemethod
- the method to invoke- Returns:
- an
InvocableHandlerMethod
suitable for that method
initArgumentResolvers
protected List<HandlerMethodArgumentResolver> initArgumentResolvers()