@ -41,6 +41,7 @@ import org.springframework.messaging.support.converter.DefaultContentTypeResolve
@@ -41,6 +41,7 @@ import org.springframework.messaging.support.converter.DefaultContentTypeResolve
import org.springframework.messaging.support.converter.MappingJackson2MessageConverter ;
import org.springframework.messaging.support.converter.StringMessageConverter ;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor ;
import org.springframework.util.Assert ;
import org.springframework.util.ClassUtils ;
import org.springframework.util.MimeTypeUtils ;
import org.springframework.util.StringUtils ;
@ -111,41 +112,45 @@ public class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
@@ -111,41 +112,45 @@ public class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
handlerMappingDef . getPropertyValues ( ) . add ( "order" , order ) ;
handlerMappingDef . getPropertyValues ( ) . add ( "urlMap" , urlMap ) ;
String channel Name = "clientInboundChannel" ;
String bean Name = "clientInboundChannel" ;
Element channelElem = DomUtils . getChildElementByTagName ( element , "client-inbound-channel" ) ;
RuntimeBeanReference clientInChannel = getMessageChannel ( channel Name, channelElem , parserCxt , source ) ;
RuntimeBeanReference clientInChannel = getMessageChannel ( bean Name, channelElem , parserCxt , source ) ;
channel Name = "clientOutboundChannel" ;
bean Name = "clientOutboundChannel" ;
channelElem = DomUtils . getChildElementByTagName ( element , "client-outbound-channel" ) ;
RuntimeBeanReference clientOutChannel = getMessageChannel ( channel Name, channelElem , parserCxt , source ) ;
RuntimeBeanReference clientOutChannel = getMessageChannel ( bean Name, channelElem , parserCxt , source ) ;
RootBeanDefinition userSessionRegistry Def = new RootBeanDefinition ( DefaultUserSessionRegistry . class ) ;
String userSessionRegistry Name = registerBeanDef ( userSessionRegistry Def, parserCxt , source ) ;
RuntimeBeanReference userSessionRegistry = new RuntimeBeanReference ( userSessionRegistry Name) ;
RootBeanDefinition bean Def = new RootBeanDefinition ( DefaultUserSessionRegistry . class ) ;
bean Name = registerBeanDef ( bean Def, parserCxt , source ) ;
RuntimeBeanReference userSessionRegistry = new RuntimeBeanReference ( bean Name) ;
RuntimeBeanReference subProtocolWebSocket Handler = registerSubProtocolWebSocketHandler (
RuntimeBeanReference subProtocolWs Handler = registerSubProtocolWebSocketHandler (
clientInChannel , clientOutChannel , userSessionRegistry , parserCxt , source ) ;
List < Element > stompEndpointElements = DomUtils . getChildElementsByTagName ( element , "stomp-endpoint" ) ;
for ( Element stompEndpointElement : stompEndpointElements ) {
for ( Element stompEndpointElem : DomUtils . getChildElementsByTagName ( element , "stomp-endpoint" ) ) {
RuntimeBeanReference r equestHandler = registerHttpRequestHandler (
stompEndpointElement , subProtocolWebSocket Handler , parserCxt , source ) ;
RuntimeBeanReference httpR equestHandler = registerHttpRequestHandler (
stompEndpointElem , subProtocolWs Handler , parserCxt , source ) ;
List < String > paths = Arrays . asList ( stompEndpointElement . getAttribute ( "path" ) . split ( "," ) ) ;
String pathAttribute = stompEndpointElem . getAttribute ( "path" ) ;
Assert . state ( StringUtils . hasText ( pathAttribute ) , "Invalid <stomp-endpoint> (no path mapping)" ) ;
List < String > paths = Arrays . asList ( pathAttribute . split ( "," ) ) ;
for ( String path : paths ) {
if ( DomUtils . getChildElementByTagName ( stompEndpointElement , "sockjs" ) ! = null ) {
path = path . trim ( ) ;
Assert . state ( StringUtils . hasText ( path ) , "Invalid <stomp-endpoint> path attribute: " + pathAttribute ) ;
if ( DomUtils . getChildElementByTagName ( stompEndpointElem , "sockjs" ) ! = null ) {
path = path . endsWith ( "/" ) ? path + "**" : path + "/**" ;
}
urlMap . put ( path , r equestHandler) ;
urlMap . put ( path , httpR equestHandler) ;
}
}
registerBeanDef ( handlerMappingDef , parserCxt , source ) ;
channel Name = "brokerChannel" ;
bean Name = "brokerChannel" ;
channelElem = DomUtils . getChildElementByTagName ( element , "broker-channel" ) ;
RuntimeBeanReference brokerChannel = getMessageChannel ( channel Name, channelElem , parserCxt , source ) ;
RuntimeBeanReference brokerChannel = getMessageChannel ( bean Name, channelElem , parserCxt , source ) ;
registerMessageBroker ( element , clientInChannel , clientOutChannel , brokerChannel , parserCxt , source ) ;
RuntimeBeanReference messageConverter = registerBrokerMessageConverter ( parserCxt , source ) ;
@ -156,7 +161,7 @@ public class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
@@ -156,7 +161,7 @@ public class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
messageConverter , messagingTemplate , parserCxt , source ) ;
RuntimeBeanReference userDestinationResolver = registerUserDestinationResolver ( element ,
userSessionRegistryDef , parserCxt , source ) ;
userSessionRegistry , parserCxt , source ) ;
registerUserDestinationMessageHandler ( clientInChannel , clientOutChannel , brokerChannel ,
userDestinationResolver , parserCxt , source ) ;
@ -320,7 +325,8 @@ public class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
@@ -320,7 +325,8 @@ public class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
mpvs . add ( "virtualHost" , virtualHost ) ;
}
RootBeanDefinition messageBrokerDef = new RootBeanDefinition ( StompBrokerRelayMessageHandler . class , cavs , mpvs ) ;
Class < ? > handlerType = StompBrokerRelayMessageHandler . class ;
RootBeanDefinition messageBrokerDef = new RootBeanDefinition ( handlerType , cavs , mpvs ) ;
registerBeanDef ( messageBrokerDef , parserCxt , source ) ;
}
@ -386,10 +392,10 @@ public class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
@@ -386,10 +392,10 @@ public class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
}
private RuntimeBeanReference registerUserDestinationResolver ( Element messageBrokerElement ,
BeanDefinition userSessionRegistryDef , ParserContext parserCxt , Object source ) {
RuntimeBeanReference userSessionRegistry , ParserContext parserCxt , Object source ) {
ConstructorArgumentValues cavs = new ConstructorArgumentValues ( ) ;
cavs . addIndexedArgumentValue ( 0 , userSessionRegistryDef ) ;
cavs . addIndexedArgumentValue ( 0 , userSessionRegistry ) ;
RootBeanDefinition userDestinationResolverDef =
new RootBeanDefinition ( DefaultUserDestinationResolver . class , cavs , null ) ;
String prefix = messageBrokerElement . getAttribute ( "user-destination-prefix" ) ;