org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory Java Examples

The following examples show how to use org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory. 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: WebSocketMessageBrokerConfigurationSupportTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureWebSocketTransport(WebSocketTransportRegistration registry) {
	registry.addDecoratorFactory(new WebSocketHandlerDecoratorFactory() {
		@Override
		public WebSocketHandlerDecorator decorate(WebSocketHandler handler) {
			return new WebSocketHandlerDecorator(handler) {
				@Override
				public void afterConnectionEstablished(WebSocketSession session) throws Exception {
					session.getAttributes().put("decorated", true);
					super.afterConnectionEstablished(session);
				}
			};
		}
	});
}
 
Example #2
Source File: MessageBrokerBeanDefinitionParser.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public WebSocketHandler getObject() throws Exception {
	WebSocketHandler result = this.handler;
	for (WebSocketHandlerDecoratorFactory factory : this.factories) {
		result = factory.decorate(result);
	}
	return result;
}
 
Example #3
Source File: MessageBrokerBeanDefinitionParser.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public WebSocketHandler getObject() {
	WebSocketHandler result = this.handler;
	for (WebSocketHandlerDecoratorFactory factory : this.factories) {
		result = factory.decorate(result);
	}
	return result;
}
 
Example #4
Source File: WebSocketMessageBrokerConfigurationSupportTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected void configureWebSocketTransport(WebSocketTransportRegistration registry) {
	registry.addDecoratorFactory(new WebSocketHandlerDecoratorFactory() {
		@Override
		public WebSocketHandlerDecorator decorate(WebSocketHandler handler) {
			return new WebSocketHandlerDecorator(handler) {
				@Override
				public void afterConnectionEstablished(WebSocketSession session) throws Exception {
					session.getAttributes().put("decorated", true);
					super.afterConnectionEstablished(session);
				}
			};
		}
	});
}
 
Example #5
Source File: ZuulWebSocketConfiguration.java    From spring-cloud-netflix-zuul-websocket with Apache License 2.0 5 votes vote down vote up
@Override
public void configureWebSocketTransport(WebSocketTransportRegistration registration) {
    registration.addDecoratorFactory(new WebSocketHandlerDecoratorFactory() {
        @Override
        public WebSocketHandler decorate(WebSocketHandler handler) {
            ProxyWebSocketHandler proxyWebSocketHandler = new ProxyWebSocketHandler(
                    handler, stompClient, webSocketHttpHeadersCallback,
                    messagingTemplate,
                    proxyTargetResolver,
                    zuulWebSocketProperties);
            proxyWebSocketHandler.errorHandler(proxyWebSocketErrorHandler);
            return proxyWebSocketHandler;
        }
    });
}
 
Example #6
Source File: WebSocketMessageBrokerConfigurationSupportTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void configureWebSocketTransport(WebSocketTransportRegistration registry) {
	registry.addDecoratorFactory(new WebSocketHandlerDecoratorFactory() {
		@Override
		public WebSocketHandlerDecorator decorate(WebSocketHandler handler) {
			return new WebSocketHandlerDecorator(handler) {
				@Override
				public void afterConnectionEstablished(WebSocketSession session) throws Exception {
					session.getAttributes().put("decorated", true);
					super.afterConnectionEstablished(session);
				}
			};
		}
	});
}
 
Example #7
Source File: MessageBrokerBeanDefinitionParser.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public WebSocketHandler getObject() {
	WebSocketHandler result = this.handler;
	for (WebSocketHandlerDecoratorFactory factory : this.factories) {
		result = factory.decorate(result);
	}
	return result;
}
 
Example #8
Source File: MessageBrokerBeanDefinitionParser.java    From java-technology-stack with MIT License 4 votes vote down vote up
@SuppressWarnings("unused")
public DecoratingFactoryBean(WebSocketHandler handler, List<WebSocketHandlerDecoratorFactory> factories) {
	this.handler = handler;
	this.factories = factories;
}
 
Example #9
Source File: MessageBrokerBeanDefinitionParser.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
private DecoratingFactoryBean(WebSocketHandler handler, List<WebSocketHandlerDecoratorFactory> factories) {
	this.handler = handler;
	this.factories = factories;
}
 
Example #10
Source File: WebSocketMessageBrokerConfigurationSupport.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler handler) {
	for (WebSocketHandlerDecoratorFactory factory : getTransportRegistration().getDecoratorFactories()) {
		handler = factory.decorate(handler);
	}
	return handler;
}
 
Example #11
Source File: WebSocketTransportRegistration.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
protected List<WebSocketHandlerDecoratorFactory> getDecoratorFactories() {
	return this.decoratorFactories;
}
 
Example #12
Source File: WebSocketMessageBrokerConfigurationSupport.java    From java-technology-stack with MIT License 4 votes vote down vote up
protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler handler) {
	for (WebSocketHandlerDecoratorFactory factory : getTransportRegistration().getDecoratorFactories()) {
		handler = factory.decorate(handler);
	}
	return handler;
}
 
Example #13
Source File: WebSocketTransportRegistration.java    From java-technology-stack with MIT License 4 votes vote down vote up
protected List<WebSocketHandlerDecoratorFactory> getDecoratorFactories() {
	return this.decoratorFactories;
}
 
Example #14
Source File: MessageBrokerBeanDefinitionParser.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@SuppressWarnings("unused")
public DecoratingFactoryBean(WebSocketHandler handler, List<WebSocketHandlerDecoratorFactory> factories) {
	this.handler = handler;
	this.factories = factories;
}
 
Example #15
Source File: WebSocketMessageBrokerConfigurationSupport.java    From spring-analysis-note with MIT License 4 votes vote down vote up
protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler handler) {
	for (WebSocketHandlerDecoratorFactory factory : getTransportRegistration().getDecoratorFactories()) {
		handler = factory.decorate(handler);
	}
	return handler;
}
 
Example #16
Source File: WebSocketTransportRegistration.java    From spring-analysis-note with MIT License 4 votes vote down vote up
protected List<WebSocketHandlerDecoratorFactory> getDecoratorFactories() {
	return this.decoratorFactories;
}
 
Example #17
Source File: WebSocketTransportRegistration.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Configure one or more factories to decorate the handler used to process
 * WebSocket messages. This may be useful in some advanced use cases, for
 * example to allow Spring Security to forcibly close the WebSocket session
 * when the corresponding HTTP session expires.
 * @since 4.1.2
 */
public WebSocketTransportRegistration setDecoratorFactories(WebSocketHandlerDecoratorFactory... factories) {
	if (factories != null) {
		this.decoratorFactories.addAll(Arrays.asList(factories));
	}
	return this;
}
 
Example #18
Source File: WebSocketTransportRegistration.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Configure one or more factories to decorate the handler used to process
 * WebSocket messages. This may be useful in some advanced use cases, for
 * example to allow Spring Security to forcibly close the WebSocket session
 * when the corresponding HTTP session expires.
 * @since 4.1.2
 */
public WebSocketTransportRegistration setDecoratorFactories(WebSocketHandlerDecoratorFactory... factories) {
	this.decoratorFactories.addAll(Arrays.asList(factories));
	return this;
}
 
Example #19
Source File: WebSocketTransportRegistration.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Add a factory that to decorate the handler used to process WebSocket
 * messages. This may be useful for some advanced use cases, for example
 * to allow Spring Security to forcibly close the WebSocket session when
 * the corresponding HTTP session expires.
 * @since 4.1.2
 */
public WebSocketTransportRegistration addDecoratorFactory(WebSocketHandlerDecoratorFactory factory) {
	this.decoratorFactories.add(factory);
	return this;
}
 
Example #20
Source File: WebSocketTransportRegistration.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Add a factory that to decorate the handler used to process WebSocket
 * messages. This may be useful for some advanced use cases, for example
 * to allow Spring Security to forcibly close the WebSocket session when
 * the corresponding HTTP session expires.
 * @since 4.1.2
 */
public WebSocketTransportRegistration addDecoratorFactory(WebSocketHandlerDecoratorFactory factory) {
	this.decoratorFactories.add(factory);
	return this;
}
 
Example #21
Source File: WebSocketTransportRegistration.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Configure one or more factories to decorate the handler used to process
 * WebSocket messages. This may be useful in some advanced use cases, for
 * example to allow Spring Security to forcibly close the WebSocket session
 * when the corresponding HTTP session expires.
 * @since 4.1.2
 */
public WebSocketTransportRegistration setDecoratorFactories(WebSocketHandlerDecoratorFactory... factories) {
	this.decoratorFactories.addAll(Arrays.asList(factories));
	return this;
}
 
Example #22
Source File: WebSocketTransportRegistration.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Add a factory that to decorate the handler used to process WebSocket
 * messages. This may be useful for some advanced use cases, for example
 * to allow Spring Security to forcibly close the WebSocket session when
 * the corresponding HTTP session expires.
 * @since 4.1.2
 */
public WebSocketTransportRegistration addDecoratorFactory(WebSocketHandlerDecoratorFactory factory) {
	this.decoratorFactories.add(factory);
	return this;
}