org.springframework.messaging.simp.SimpSessionScope Java Examples

The following examples show how to use org.springframework.messaging.simp.SimpSessionScope. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebSocketMessageBrokerConfigurationSupport.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Bean
public static CustomScopeConfigurer webSocketScopeConfigurer() {
	CustomScopeConfigurer configurer = new CustomScopeConfigurer();
	configurer.addScope("websocket", new SimpSessionScope());
	return configurer;
}
 
Example #2
Source File: MessageBrokerBeanDefinitionParser.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public BeanDefinition parse(Element element, ParserContext context) {
	Object source = context.extractSource(element);
	CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
	context.pushContainingComponent(compDefinition);

	Element channelElem = DomUtils.getChildElementByTagName(element, "client-inbound-channel");
	RuntimeBeanReference inChannel = getMessageChannel("clientInboundChannel", channelElem, context, source);

	channelElem = DomUtils.getChildElementByTagName(element, "client-outbound-channel");
	RuntimeBeanReference outChannel = getMessageChannel("clientOutboundChannel", channelElem, context, source);

	channelElem = DomUtils.getChildElementByTagName(element, "broker-channel");
	RuntimeBeanReference brokerChannel = getMessageChannel("brokerChannel", channelElem, context, source);

	RuntimeBeanReference userRegistry = registerUserRegistry(element, context, source);
	Object userDestHandler = registerUserDestHandler(element, userRegistry, inChannel, brokerChannel, context, source);

	RuntimeBeanReference converter = registerMessageConverter(element, context, source);
	RuntimeBeanReference template = registerMessagingTemplate(element, brokerChannel, converter, context, source);
	registerAnnotationMethodMessageHandler(element, inChannel, outChannel,converter, template, context, source);

	RootBeanDefinition broker = registerMessageBroker(element, inChannel, outChannel, brokerChannel,
			userDestHandler, template, userRegistry, context, source);

	// WebSocket and sub-protocol handling

	ManagedMap<String, Object> urlMap = registerHandlerMapping(element, context, source);
	RuntimeBeanReference stompHandler = registerStompHandler(element, inChannel, outChannel, context, source);
	for (Element endpointElem : DomUtils.getChildElementsByTagName(element, "stomp-endpoint")) {
		RuntimeBeanReference requestHandler = registerRequestHandler(endpointElem, stompHandler, context, source);
		String pathAttribute = endpointElem.getAttribute("path");
		Assert.hasText(pathAttribute, "Invalid <stomp-endpoint> (no path mapping)");
		for (String path : StringUtils.tokenizeToStringArray(pathAttribute, ",")) {
			path = path.trim();
			Assert.hasText(path, () -> "Invalid <stomp-endpoint> path attribute: " + pathAttribute);
			if (DomUtils.getChildElementByTagName(endpointElem, "sockjs") != null) {
				path = (path.endsWith("/") ? path + "**" : path + "/**");
			}
			urlMap.put(path, requestHandler);
		}
	}

	Map<String, Object> scopeMap = Collections.singletonMap("websocket", new SimpSessionScope());
	RootBeanDefinition scopeConfigurer = new RootBeanDefinition(CustomScopeConfigurer.class);
	scopeConfigurer.getPropertyValues().add("scopes", scopeMap);
	registerBeanDefByName("webSocketScopeConfigurer", scopeConfigurer, context, source);

	registerWebSocketMessageBrokerStats(broker, inChannel, outChannel, context, source);

	context.popAndRegisterContainingComponent();
	return null;
}
 
Example #3
Source File: WebSocketMessageBrokerConfigurationSupport.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public static CustomScopeConfigurer webSocketScopeConfigurer() {
	CustomScopeConfigurer configurer = new CustomScopeConfigurer();
	configurer.addScope("websocket", new SimpSessionScope());
	return configurer;
}
 
Example #4
Source File: MessageBrokerBeanDefinitionParser.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public BeanDefinition parse(Element element, ParserContext context) {
	Object source = context.extractSource(element);
	CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
	context.pushContainingComponent(compDefinition);

	Element channelElem = DomUtils.getChildElementByTagName(element, "client-inbound-channel");
	RuntimeBeanReference inChannel = getMessageChannel("clientInboundChannel", channelElem, context, source);

	channelElem = DomUtils.getChildElementByTagName(element, "client-outbound-channel");
	RuntimeBeanReference outChannel = getMessageChannel("clientOutboundChannel", channelElem, context, source);

	channelElem = DomUtils.getChildElementByTagName(element, "broker-channel");
	RuntimeBeanReference brokerChannel = getMessageChannel("brokerChannel", channelElem, context, source);

	RuntimeBeanReference userRegistry = registerUserRegistry(element, context, source);
	Object userDestHandler = registerUserDestHandler(element, userRegistry, inChannel, brokerChannel, context, source);

	RuntimeBeanReference converter = registerMessageConverter(element, context, source);
	RuntimeBeanReference template = registerMessagingTemplate(element, brokerChannel, converter, context, source);
	registerAnnotationMethodMessageHandler(element, inChannel, outChannel,converter, template, context, source);

	RootBeanDefinition broker = registerMessageBroker(element, inChannel, outChannel, brokerChannel,
			userDestHandler, template, userRegistry, context, source);

	// WebSocket and sub-protocol handling

	ManagedMap<String, Object> urlMap = registerHandlerMapping(element, context, source);
	RuntimeBeanReference stompHandler = registerStompHandler(element, inChannel, outChannel, context, source);
	for (Element endpointElem : DomUtils.getChildElementsByTagName(element, "stomp-endpoint")) {
		RuntimeBeanReference requestHandler = registerRequestHandler(endpointElem, stompHandler, context, source);
		String pathAttribute = endpointElem.getAttribute("path");
		Assert.hasText(pathAttribute, "Invalid <stomp-endpoint> (no path mapping)");
		for (String path : StringUtils.tokenizeToStringArray(pathAttribute, ",")) {
			path = path.trim();
			Assert.hasText(path, () -> "Invalid <stomp-endpoint> path attribute: " + pathAttribute);
			if (DomUtils.getChildElementByTagName(endpointElem, "sockjs") != null) {
				path = (path.endsWith("/") ? path + "**" : path + "/**");
			}
			urlMap.put(path, requestHandler);
		}
	}

	Map<String, Object> scopeMap = Collections.singletonMap("websocket", new SimpSessionScope());
	RootBeanDefinition scopeConfigurer = new RootBeanDefinition(CustomScopeConfigurer.class);
	scopeConfigurer.getPropertyValues().add("scopes", scopeMap);
	registerBeanDefByName("webSocketScopeConfigurer", scopeConfigurer, context, source);

	registerWebSocketMessageBrokerStats(broker, inChannel, outChannel, context, source);

	context.popAndRegisterContainingComponent();
	return null;
}
 
Example #5
Source File: WebSocketMessageBrokerConfigurationSupport.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public static CustomScopeConfigurer webSocketScopeConfigurer() {
	CustomScopeConfigurer configurer = new CustomScopeConfigurer();
	configurer.addScope("websocket", new SimpSessionScope());
	return configurer;
}
 
Example #6
Source File: MessageBrokerBeanDefinitionParser.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public BeanDefinition parse(Element element, ParserContext context) {

	Object source = context.extractSource(element);
	CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
	context.pushContainingComponent(compDefinition);

	Element channelElem = DomUtils.getChildElementByTagName(element, "client-inbound-channel");
	RuntimeBeanReference inChannel = getMessageChannel("clientInboundChannel", channelElem, context, source);

	channelElem = DomUtils.getChildElementByTagName(element, "client-outbound-channel");
	RuntimeBeanReference outChannel = getMessageChannel("clientOutboundChannel", channelElem, context, source);

	channelElem = DomUtils.getChildElementByTagName(element, "broker-channel");
	RuntimeBeanReference brokerChannel = getMessageChannel("brokerChannel", channelElem, context, source);

	RuntimeBeanReference userRegistry = registerUserRegistry(element, context, source);
	Object userDestHandler = registerUserDestHandler(element, userRegistry, inChannel, brokerChannel, context, source);

	RuntimeBeanReference converter = registerMessageConverter(element, context, source);
	RuntimeBeanReference template = registerMessagingTemplate(element, brokerChannel, converter, context, source);
	registerAnnotationMethodMessageHandler(element, inChannel, outChannel,converter, template, context, source);

	RootBeanDefinition broker = registerMessageBroker(element, inChannel, outChannel, brokerChannel,
			userDestHandler, template, userRegistry, context, source);

	// WebSocket and sub-protocol handling

	ManagedMap<String, Object> urlMap = registerHandlerMapping(element, context, source);
	RuntimeBeanReference stompHandler = registerStompHandler(element, inChannel, outChannel, context, source);
	for (Element endpointElem : DomUtils.getChildElementsByTagName(element, "stomp-endpoint")) {
		RuntimeBeanReference requestHandler = registerRequestHandler(endpointElem, stompHandler, context, source);
		String pathAttribute = endpointElem.getAttribute("path");
		Assert.state(StringUtils.hasText(pathAttribute), "Invalid <stomp-endpoint> (no path mapping)");
		List<String> paths = Arrays.asList(StringUtils.tokenizeToStringArray(pathAttribute, ","));
		for (String path : paths) {
			path = path.trim();
			Assert.state(StringUtils.hasText(path), "Invalid <stomp-endpoint> path attribute: " + pathAttribute);
			if (DomUtils.getChildElementByTagName(endpointElem, "sockjs") != null) {
				path = path.endsWith("/") ? path + "**" : path + "/**";
			}
			urlMap.put(path, requestHandler);
		}
	}

	Map<String, Object> scopeMap = Collections.<String, Object>singletonMap("websocket", new SimpSessionScope());
	RootBeanDefinition scopeConfigurer = new RootBeanDefinition(CustomScopeConfigurer.class);
	scopeConfigurer.getPropertyValues().add("scopes", scopeMap);
	registerBeanDefByName("webSocketScopeConfigurer", scopeConfigurer, context, source);

	registerWebSocketMessageBrokerStats(broker, inChannel, outChannel, context, source);

	context.popAndRegisterContainingComponent();
	return null;
}