Top Description Fields Constructors Methods
org.springframework.messaging.handler.annotation.support

public Class DefaultMessageHandlerMethodFactory

extends Object
implements MessageHandlerMethodFactory, BeanFactoryAware, InitializingBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.Aware, org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory
Imports
java.lang.reflect.Method, java.util.ArrayList, .List, org.springframework.beans.factory.BeanFactory, .BeanFactoryAware, .InitializingBean, org.springframework.beans.factory.config.ConfigurableBeanFactory, org.springframework.core.convert.ConversionService, org.springframework.format.support.DefaultFormattingConversionService, org.springframework.lang.Nullable, org.springframework.messaging.converter.GenericMessageConverter, .MessageConverter, org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver, .HandlerMethodArgumentResolverComposite, .InvocableHandlerMethod, org.springframework.util.Assert, org.springframework.validation.Validator

The default 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

Authors
Stephane Nicoll, Juergen Hoeller
Since
4.1
See Also
setConversionService, setValidator, setCustomArgumentResolvers

Field Summary

Modifier and TypeField and Description
private final HandlerMethodArgumentResolverComposite
private BeanFactory
private ConversionService
private List<HandlerMethodArgumentResolver>
private MessageConverter
private Validator

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing 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.

public InvocableHandlerMethod
createInvocableHandlerMethod(Object
the bean instance
bean
,
Method
the method to invoke
method
)

Implements org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory.createInvocableHandlerMethod.

Create the InvocableHandlerMethod that is able to process the specified method endpoint.

protected List<HandlerMethodArgumentResolver>
public void
setArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)

Configure the complete list of supported argument types effectively overriding the ones configured by default.

public void
setBeanFactory(BeanFactory
owning BeanFactory (never null). The bean can immediately call methods on the factory.
beanFactory
)

Implements org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

A BeanFactory only needs to be available for placeholder resolution in handler method arguments; it's optional otherwise.

public void
setConversionService(ConversionService conversionService)

Set the ConversionService to use to convert the original message payload or headers.

public void
setCustomArgumentResolvers(List<HandlerMethodArgumentResolver>
the list of resolvers (never null)
customArgumentResolvers
)

Set the list of custom HandlerMethodArgumentResolvers that will be used after resolvers for supported argument type.

public void
setMessageConverter(MessageConverter messageConverter)

Set the MessageConverter to use.

public void
setValidator(Validator validator)

Set the Validator instance used for validating @Payload arguments.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argumentResolversback to summary
private final HandlerMethodArgumentResolverComposite argumentResolvers
beanFactoryback to summary
private BeanFactory beanFactory
Annotations
@Nullable
conversionServiceback to summary
private ConversionService conversionService
customArgumentResolversback to summary
private List<HandlerMethodArgumentResolver> customArgumentResolvers
Annotations
@Nullable
messageConverterback to summary
private MessageConverter messageConverter
Annotations
@Nullable
validatorback to summary
private Validator validator
Annotations
@Nullable

Constructor Detail

DefaultMessageHandlerMethodFactoryback to summary
public DefaultMessageHandlerMethodFactory()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Doc from org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing 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.

Annotations
@Override
createInvocableHandlerMethodback to summary
public InvocableHandlerMethod createInvocableHandlerMethod(Object bean, Method method)

Implements org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory.createInvocableHandlerMethod.

Doc from org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory.createInvocableHandlerMethod.

Create the InvocableHandlerMethod that is able to process the specified method endpoint.

Parameters
bean:Object

the bean instance

method:Method

the method to invoke

Returns:InvocableHandlerMethod

an InvocableHandlerMethod suitable for that method

Annotations
@Override
initArgumentResolversback to summary
protected List<HandlerMethodArgumentResolver> initArgumentResolvers()
setArgumentResolversback 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(java.util.List).

setBeanFactoryback to summary
public void setBeanFactory(BeanFactory beanFactory)

Implements org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

A BeanFactory only needs to be available for placeholder resolution in handler method arguments; it's optional otherwise.

Parameters
beanFactory:BeanFactory

Doc from org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

owning BeanFactory (never null). The bean can immediately call methods on the factory.

Annotations
@Override
setConversionServiceback to summary
public void setConversionService(ConversionService conversionService)

Set the ConversionService to use to convert the original message payload or headers.

See Also
HeaderMethodArgumentResolver, GenericMessageConverter
setCustomArgumentResolversback to summary
public void setCustomArgumentResolvers(List<HandlerMethodArgumentResolver> customArgumentResolvers)

Set the list of custom HandlerMethodArgumentResolvers that will be used after resolvers for supported argument type.

Parameters
customArgumentResolvers:List<HandlerMethodArgumentResolver>

the list of resolvers (never null)

setMessageConverterback to summary
public void setMessageConverter(MessageConverter messageConverter)

Set the MessageConverter to use. By default a GenericMessageConverter is used.

See Also
GenericMessageConverter
setValidatorback to summary
public void setValidator(Validator validator)

Set the Validator instance used for validating @Payload arguments.

See Also
org.springframework.validation.annotation.Validated, PayloadMethodArgumentResolver