Top Description Inners Fields Constructors Methods
org.springframework.web.socket.config

pack-priv Class MessageBrokerBeanDefinitionParser

extends Object
implements BeanDefinitionParser
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.xml.BeanDefinitionParser
Imports
java.util.Arrays, .Collections, .List, .Map, org.w3c.dom.Element, org.springframework.beans.MutablePropertyValues, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.config.BeanDefinition, .ConstructorArgumentValues, .CustomScopeConfigurer, .RuntimeBeanReference, org.springframework.beans.factory.parsing.BeanComponentDefinition, .CompositeComponentDefinition, org.springframework.beans.factory.support.GenericBeanDefinition, .ManagedList, .ManagedMap, .RootBeanDefinition, org.springframework.beans.factory.xml.BeanDefinitionParser, .ParserContext, org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean, org.springframework.lang.Nullable, org.springframework.messaging.converter.ByteArrayMessageConverter, .CompositeMessageConverter, .DefaultContentTypeResolver, .GsonMessageConverter, .JsonbMessageConverter, .MappingJackson2MessageConverter, .StringMessageConverter, org.springframework.messaging.simp.SimpMessagingTemplate, .SimpSessionScope, org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler, org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler, org.springframework.messaging.simp.user.DefaultUserDestinationResolver, .MultiServerUserRegistry, .UserDestinationMessageHandler, .UserRegistryMessageHandler, org.springframework.messaging.support.ExecutorSubscribableChannel, .ImmutableMessageChannelInterceptor, org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor, org.springframework.util.Assert, .ClassUtils, .MimeTypeUtils, .ObjectUtils, .StringUtils, org.springframework.util.xml.DomUtils, org.springframework.web.socket.WebSocketHandler, org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory, org.springframework.web.socket.messaging.DefaultSimpUserRegistry, .StompSubProtocolHandler, .SubProtocolWebSocketHandler, .WebSocketAnnotationMethodMessageHandler, org.springframework.web.socket.server.support.OriginHandshakeInterceptor, .WebSocketHandlerMapping, .WebSocketHttpRequestHandler, org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler

A org.springframework.beans.factory.xml.BeanDefinitionParser that provides the configuration for the <websocket:message-broker/> XML namespace element.

Registers a Spring MVC org.springframework.web.servlet.HandlerMapping with order 1 to map HTTP WebSocket handshake requests from STOMP/WebSocket clients.

Registers the following MessageChannels:

Registers one of the following based on the selected message broker options:

Registers a UserDestinationMessageHandler for handling user destinations.

Authors
Brian Clozel, Rossen Stoyanchev
Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final int
private static final boolean
private static final boolean
private static final boolean
private static final boolean
public static final String
public static final String
public static final String
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private ManagedList<Object>
private RootBeanDefinition
private RuntimeBeanReference
getMessageChannel(String name, Element element, ParserContext context, Object source)

private RuntimeBeanReference
getValidator(Element messageBrokerElement, Object source, ParserContext context)

public BeanDefinition
parse(Element
the element that is to be parsed into one or more BeanDefinitions
element
,
ParserContext
the object encapsulating the current state of the parsing process; provides access to a org.springframework.beans.factory.support.BeanDefinitionRegistry
context
)

Implements org.springframework.beans.factory.xml.BeanDefinitionParser.parse.

Parse the specified Element and register the resulting BeanDefinition(s) with the BeanDefinitionRegistry embedded in the supplied ParserContext.

private void
registerAnnotationMethodMessageHandler(Element messageBrokerElement, RuntimeBeanReference inChannel, RuntimeBeanReference outChannel, RuntimeBeanReference converter, RuntimeBeanReference messagingTemplate, ParserContext context, Object source)

private static String
private static void
private ManagedMap<String, Object>
private RootBeanDefinition
registerMessageBroker(Element brokerElement, RuntimeBeanReference inChannel, RuntimeBeanReference outChannel, RuntimeBeanReference brokerChannel, Object userDestHandler, RuntimeBeanReference brokerTemplate, RuntimeBeanReference userRegistry, ParserContext context, Object source)

private RuntimeBeanReference
private RuntimeBeanReference
registerMessagingTemplate(Element element, RuntimeBeanReference brokerChannel, RuntimeBeanReference messageConverter, ParserContext context, Object source)

private RuntimeBeanReference
private RuntimeBeanReference
private RuntimeBeanReference
registerUserDestHandler(Element brokerElem, RuntimeBeanReference userRegistry, RuntimeBeanReference inChannel, RuntimeBeanReference brokerChannel, ParserContext context, Object source)

private RuntimeBeanReference
registerUserDestResolver(Element brokerElem, RuntimeBeanReference userRegistry, ParserContext context, Object source)

private RuntimeBeanReference
private RuntimeBeanReference
registerUserRegistryMessageHandler(RuntimeBeanReference userRegistry, RuntimeBeanReference brokerTemplate, String destination, ParserContext context, Object source)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_MAPPING_ORDERback to summary
private static final int DEFAULT_MAPPING_ORDER
gsonPresentback to summary
private static final boolean gsonPresent
jackson2Presentback to summary
private static final boolean jackson2Present
javaxValidationPresentback to summary
private static final boolean javaxValidationPresent
jsonbPresentback to summary
private static final boolean jsonbPresent
MESSAGE_CONVERTER_BEAN_NAMEback to summary
public static final String MESSAGE_CONVERTER_BEAN_NAME
MESSAGING_TEMPLATE_BEAN_NAMEback to summary
public static final String MESSAGING_TEMPLATE_BEAN_NAME
SCHEDULER_BEAN_NAMEback to summary
public static final String SCHEDULER_BEAN_NAME
SOCKJS_SCHEDULER_BEAN_NAMEback to summary
public static final String SOCKJS_SCHEDULER_BEAN_NAME
WEB_SOCKET_HANDLER_BEAN_NAMEback to summary
public static final String WEB_SOCKET_HANDLER_BEAN_NAME

Constructor Detail

MessageBrokerBeanDefinitionParserback to summary
pack-priv MessageBrokerBeanDefinitionParser()

Method Detail

extractBeanSubElementsback to summary
private ManagedList<Object> extractBeanSubElements(Element parentElement, ParserContext context)
getDefaultExecutorBeanDefinitionback to summary
private RootBeanDefinition getDefaultExecutorBeanDefinition(String channelName)
Annotations
@Nullable
getMessageChannelback to summary
private RuntimeBeanReference getMessageChannel(String name, Element element, ParserContext context, Object source)
getValidatorback to summary
private RuntimeBeanReference getValidator(Element messageBrokerElement, Object source, ParserContext context)
Annotations
@Nullable
parseback to summary
public BeanDefinition parse(Element element, ParserContext context)

Implements org.springframework.beans.factory.xml.BeanDefinitionParser.parse.

Doc from org.springframework.beans.factory.xml.BeanDefinitionParser.parse.

Parse the specified Element and register the resulting BeanDefinition(s) with the BeanDefinitionRegistry embedded in the supplied ParserContext.

Implementations must return the primary BeanDefinition that results from the parse if they will ever be used in a nested fashion (for example as an inner tag in a <property/> tag). Implementations may return null if they will not be used in a nested fashion.

Parameters
element:Element

the element that is to be parsed into one or more BeanDefinitions

context:ParserContext

the object encapsulating the current state of the parsing process; provides access to a org.springframework.beans.factory.support.BeanDefinitionRegistry

Returns:BeanDefinition

the primary BeanDefinition

Annotations
@Override
registerAnnotationMethodMessageHandlerback to summary
private void registerAnnotationMethodMessageHandler(Element messageBrokerElement, RuntimeBeanReference inChannel, RuntimeBeanReference outChannel, RuntimeBeanReference converter, RuntimeBeanReference messagingTemplate, ParserContext context, Object source)
registerBeanDefback to summary
private static String registerBeanDef(RootBeanDefinition beanDef, ParserContext context, Object source)
registerBeanDefByNameback to summary
private static void registerBeanDefByName(String name, RootBeanDefinition beanDef, ParserContext context, Object source)
registerHandlerMappingback to summary
private ManagedMap<String, Object> registerHandlerMapping(Element element, ParserContext context, Object source)
registerMessageBrokerback to summary
private RootBeanDefinition registerMessageBroker(Element brokerElement, RuntimeBeanReference inChannel, RuntimeBeanReference outChannel, RuntimeBeanReference brokerChannel, Object userDestHandler, RuntimeBeanReference brokerTemplate, RuntimeBeanReference userRegistry, ParserContext context, Object source)
registerMessageConverterback to summary
private RuntimeBeanReference registerMessageConverter(Element element, ParserContext context, Object source)
registerMessagingTemplateback to summary
private RuntimeBeanReference registerMessagingTemplate(Element element, RuntimeBeanReference brokerChannel, RuntimeBeanReference messageConverter, ParserContext context, Object source)
registerRequestHandlerback to summary
private RuntimeBeanReference registerRequestHandler(Element element, RuntimeBeanReference subProtoHandler, ParserContext ctx, Object source)
registerStompHandlerback to summary
private RuntimeBeanReference registerStompHandler(Element element, RuntimeBeanReference inChannel, RuntimeBeanReference outChannel, ParserContext context, Object source)
registerUserDestHandlerback to summary
private RuntimeBeanReference registerUserDestHandler(Element brokerElem, RuntimeBeanReference userRegistry, RuntimeBeanReference inChannel, RuntimeBeanReference brokerChannel, ParserContext context, Object source)
registerUserDestResolverback to summary
private RuntimeBeanReference registerUserDestResolver(Element brokerElem, RuntimeBeanReference userRegistry, ParserContext context, Object source)
registerUserRegistryback to summary
private RuntimeBeanReference registerUserRegistry(Element element, ParserContext context, Object source)
registerUserRegistryMessageHandlerback to summary
private RuntimeBeanReference registerUserRegistryMessageHandler(RuntimeBeanReference userRegistry, RuntimeBeanReference brokerTemplate, String destination, ParserContext context, Object source)
registerWebSocketMessageBrokerStatsback to summary
private void registerWebSocketMessageBrokerStats(RootBeanDefinition broker, RuntimeBeanReference inChannel, RuntimeBeanReference outChannel, ParserContext context, Object source)
org.springframework.web.socket.config back to summary

private final Class MessageBrokerBeanDefinitionParser.DecoratingFactoryBean

extends Object
implements FactoryBean<WebSocketHandler>
Class Inheritance
  • java.lang.Object
  • org.springframework.web.socket.config.MessageBrokerBeanDefinitionParser.DecoratingFactoryBean
All Implemented Interfaces
org.springframework.beans.factory.FactoryBean

Field Summary

Modifier and TypeField and Description
private final List<WebSocketHandlerDecoratorFactory>
private final WebSocketHandler

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public WebSocketHandler
getObject()

Implements org.springframework.beans.factory.FactoryBean.getObject.

Return an instance (possibly shared or independent) of the object managed by this factory.

public Class<?>
getObjectType()

Implements org.springframework.beans.factory.FactoryBean.getObjectType.

Return the type of object that this FactoryBean creates, or null if not known in advance.

public boolean
isSingleton()

Overrides default org.springframework.beans.factory.FactoryBean.isSingleton.

Is the object managed by this factory a singleton?

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

factoriesback to summary
private final List<WebSocketHandlerDecoratorFactory> factories
handlerback to summary
private final WebSocketHandler handler

Constructor Detail

DecoratingFactoryBeanback to summary
public DecoratingFactoryBean(WebSocketHandler handler, List<WebSocketHandlerDecoratorFactory> factories)
Annotations
@SuppressWarnings:unused

Method Detail

getObjectback to summary
public WebSocketHandler getObject()

Implements org.springframework.beans.factory.FactoryBean.getObject.

Doc from org.springframework.beans.factory.FactoryBean.getObject.

Return an instance (possibly shared or independent) of the object managed by this factory.

As with a BeanFactory, this allows support for both the Singleton and Prototype design pattern.

If this FactoryBean is not fully initialized yet at the time of the call (for example because it is involved in a circular reference), throw a corresponding FactoryBeanNotInitializedException.

As of Spring 2.0, FactoryBeans are allowed to return null objects. The factory will consider this as normal value to be used; it will not throw a FactoryBeanNotInitializedException in this case anymore. FactoryBean implementations are encouraged to throw FactoryBeanNotInitializedException themselves now, as appropriate.

Returns:WebSocketHandler

an instance of the bean (can be null)

Annotations
@Override
getObjectTypeback to summary
public Class<?> getObjectType()

Implements org.springframework.beans.factory.FactoryBean.getObjectType.

Doc from org.springframework.beans.factory.FactoryBean.getObjectType.

Return the type of object that this FactoryBean creates, or null if not known in advance.

This allows one to check for specific types of beans without instantiating objects, for example on autowiring.

In the case of implementations that are creating a singleton object, this method should try to avoid singleton creation as far as possible; it should rather estimate the type in advance. For prototypes, returning a meaningful type here is advisable too.

This method can be called before this FactoryBean has been fully initialized. It must not rely on state created during initialization; of course, it can still use such state if available.

Note

Autowiring will simply ignore FactoryBeans that return null here. Therefore, it is highly recommended to implement this method properly, using the current state of the FactoryBean.

Returns:Class<?>

the type of object that this FactoryBean creates, or null if not known at the time of the call

Annotations
@Override
isSingletonback to summary
public boolean isSingleton()

Overrides default org.springframework.beans.factory.FactoryBean.isSingleton.

Doc from org.springframework.beans.factory.FactoryBean.isSingleton.

Is the object managed by this factory a singleton? That is, will getObject() always return the same object (a reference that can be cached)?

Note

If a FactoryBean indicates to hold a singleton object, the object returned from getObject() might get cached by the owning BeanFactory. Hence, do not return true unless the FactoryBean always exposes the same reference.

The singleton status of the FactoryBean itself will generally be provided by the owning BeanFactory; usually, it has to be defined as singleton there.

Note

This method returning false does not necessarily indicate that returned objects are independent instances. An implementation of the extended SmartFactoryBean interface may explicitly indicate independent instances through its SmartFactoryBean#isPrototype() method. Plain FactoryBean implementations which do not implement this extended interface are simply assumed to always return independent instances if the isSingleton() implementation returns false.

The default implementation returns true, since a FactoryBean typically manages a singleton instance.

Returns:boolean

whether the exposed object is a singleton

Annotations
@Override