类 AbstractMessageBrokerConfiguration
- java.lang.Object
- org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration
- 所有已实现的接口:
Aware
,ApplicationContextAware
public abstract class AbstractMessageBrokerConfiguration extends Object implements ApplicationContextAware
Provides essential configuration for handling messages with simple messaging protocols such as STOMP.clientInboundChannel()
andclientOutboundChannel()
deliver messages to and from remote clients to several message handlers such as the following.simpAnnotationMethodMessageHandler()
simpleBrokerMessageHandler()
stompBrokerRelayMessageHandler()
userDestinationMessageHandler()
brokerChannel()
delivers messages from within the application to the the respective message handlers.brokerMessagingTemplate()
can be injected into any application component to send messages.Subclasses are responsible for the parts of the configuration that feed messages to and from the client inbound/outbound channels (e.g. STOMP over WebSocket).
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Brian Clozel
构造器概要
构造器 限定符 构造器 说明 protected
AbstractMessageBrokerConfiguration()
Protected constructor.
方法概要
构造器详细资料
AbstractMessageBrokerConfiguration
protected AbstractMessageBrokerConfiguration()
Protected constructor.
方法详细资料
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext)
从接口复制的说明:ApplicationContextAware
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
InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
andMessageSourceAware
, if applicable.- 指定者:
setApplicationContext
在接口中ApplicationContextAware
- 参数:
applicationContext
- the ApplicationContext object to be used by this object- 另请参阅:
BeanInitializationException
getApplicationContext
public ApplicationContext getApplicationContext()
clientInboundChannel
@Bean public AbstractSubscribableChannel clientInboundChannel()
clientInboundChannelExecutor
@Bean public ThreadPoolTaskExecutor clientInboundChannelExecutor()
getClientInboundChannelRegistration
protected final ChannelRegistration getClientInboundChannelRegistration()
configureClientInboundChannel
protected void configureClientInboundChannel(ChannelRegistration registration)
A hook for subclasses to customize the message channel for inbound messages from WebSocket clients.
clientOutboundChannel
@Bean public AbstractSubscribableChannel clientOutboundChannel()
clientOutboundChannelExecutor
@Bean public ThreadPoolTaskExecutor clientOutboundChannelExecutor()
getClientOutboundChannelRegistration
protected final ChannelRegistration getClientOutboundChannelRegistration()
configureClientOutboundChannel
protected void configureClientOutboundChannel(ChannelRegistration registration)
A hook for subclasses to customize the message channel for messages from the application or message broker to WebSocket clients.
brokerChannel
@Bean public AbstractSubscribableChannel brokerChannel()
brokerChannelExecutor
@Bean public ThreadPoolTaskExecutor brokerChannelExecutor()
getBrokerRegistry
protected final MessageBrokerRegistry getBrokerRegistry()
An accessor for theMessageBrokerRegistry
that ensures its one-time creation and initialization throughconfigureMessageBroker(MessageBrokerRegistry)
.
configureMessageBroker
protected void configureMessageBroker(MessageBrokerRegistry registry)
A hook for subclasses to customize message broker configuration through the providedMessageBrokerRegistry
instance.
getPathMatcher
public final PathMatcher getPathMatcher()
Provide access to the configured PatchMatcher for access from other configuration classes.
simpAnnotationMethodMessageHandler
@Bean public SimpAnnotationMethodMessageHandler simpAnnotationMethodMessageHandler()
createAnnotationMethodMessageHandler
protected SimpAnnotationMethodMessageHandler createAnnotationMethodMessageHandler()
Protected method for plugging in a custom subclass ofSimpAnnotationMethodMessageHandler
.- 从以下版本开始:
- 4.2
addArgumentResolvers
protected void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)
addReturnValueHandlers
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)
simpleBrokerMessageHandler
@Bean public AbstractBrokerMessageHandler simpleBrokerMessageHandler()
stompBrokerRelayMessageHandler
@Bean public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler()
userDestinationMessageHandler
@Bean public UserDestinationMessageHandler userDestinationMessageHandler()
userRegistryMessageHandler
@Bean public MessageHandler userRegistryMessageHandler()
messageBrokerTaskScheduler
@Bean(name={"messageBrokerTaskScheduler","messageBrokerSockJsTaskScheduler"}) public ThreadPoolTaskScheduler messageBrokerTaskScheduler()
brokerMessagingTemplate
@Bean public SimpMessagingTemplate brokerMessagingTemplate()
brokerMessageConverter
@Bean public CompositeMessageConverter brokerMessageConverter()
createJacksonConverter
protected MappingJackson2MessageConverter createJacksonConverter()
configureMessageConverters
protected boolean configureMessageConverters(List<MessageConverter> messageConverters)
Override this method to add custom message converters.- 参数:
messageConverters
- the list to add converters to, initially empty- 返回:
true
if default message converters should be added to list,false
if no more converters should be added
userDestinationResolver
@Bean public UserDestinationResolver userDestinationResolver()
userRegistry
@Bean public SimpUserRegistry userRegistry()
createLocalUserRegistry
protected abstract SimpUserRegistry createLocalUserRegistry()
Create the user registry that provides access to local users.
userSessionRegistry
@Deprecated protected UserSessionRegistry userSessionRegistry()
已过时。As of 4.2,UserSessionRegistry
is deprecated in favor ofSimpUserRegistry
exposing information about all connected users. TheMultiServerUserRegistry
implementation in combination withUserRegistryMessageHandler
can be used to share user registries across multiple servers.
simpValidator
protected Validator simpValidator()
Return aValidator
s instance for validating@Payload
method arguments.In order, this method tries to get a Validator instance:
- delegating to getValidator() first
- if none returned, getting an existing instance with its well-known name "mvcValidator", created by an MVC configuration
- if none returned, checking the classpath for the presence of a JSR-303 implementation before creating a
OptionalValidatorFactoryBean
- returning a no-op Validator instance
getValidator
public Validator getValidator()
Override this method to provide a customValidator
.- 从以下版本开始:
- 4.0.1