use of org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration in project spring-integration by spring-projects.
the class ServerWebSocketContainer method registerWebSocketHandlers.
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
WebSocketHandler webSocketHandler = this.webSocketHandler;
if (this.decoratorFactories != null) {
for (WebSocketHandlerDecoratorFactory factory : this.decoratorFactories) {
webSocketHandler = factory.decorate(webSocketHandler);
}
}
WebSocketHandlerRegistration registration = registry.addHandler(webSocketHandler, this.paths).setHandshakeHandler(this.handshakeHandler).addInterceptors(this.interceptors).setAllowedOrigins(this.origins);
if (this.sockJsServiceOptions != null) {
SockJsServiceRegistration sockJsServiceRegistration = registration.withSockJS();
if (this.sockJsServiceOptions.webSocketEnabled != null) {
sockJsServiceRegistration.setWebSocketEnabled(this.sockJsServiceOptions.webSocketEnabled);
}
if (this.sockJsServiceOptions.clientLibraryUrl != null) {
sockJsServiceRegistration.setClientLibraryUrl(this.sockJsServiceOptions.clientLibraryUrl);
}
if (this.sockJsServiceOptions.disconnectDelay != null) {
sockJsServiceRegistration.setDisconnectDelay(this.sockJsServiceOptions.disconnectDelay);
}
if (this.sockJsServiceOptions.heartbeatTime != null) {
sockJsServiceRegistration.setHeartbeatTime(this.sockJsServiceOptions.heartbeatTime);
}
if (this.sockJsServiceOptions.httpMessageCacheSize != null) {
sockJsServiceRegistration.setHttpMessageCacheSize(this.sockJsServiceOptions.httpMessageCacheSize);
}
if (this.sockJsServiceOptions.heartbeatTime != null) {
sockJsServiceRegistration.setHeartbeatTime(this.sockJsServiceOptions.heartbeatTime);
}
if (this.sockJsServiceOptions.sessionCookieNeeded != null) {
sockJsServiceRegistration.setSessionCookieNeeded(this.sockJsServiceOptions.sessionCookieNeeded);
}
if (this.sockJsServiceOptions.streamBytesLimit != null) {
sockJsServiceRegistration.setStreamBytesLimit(this.sockJsServiceOptions.streamBytesLimit);
}
if (this.sockJsServiceOptions.transportHandlers != null) {
sockJsServiceRegistration.setTransportHandlers(this.sockJsServiceOptions.transportHandlers);
}
if (this.sockJsServiceOptions.taskScheduler != null) {
sockJsServiceRegistration.setTaskScheduler(this.sockJsServiceOptions.taskScheduler);
}
if (this.sockJsServiceOptions.messageCodec != null) {
sockJsServiceRegistration.setMessageCodec(this.sockJsServiceOptions.messageCodec);
}
if (this.sockJsServiceOptions.suppressCors != null) {
sockJsServiceRegistration.setSupressCors(this.sockJsServiceOptions.suppressCors);
}
}
}
use of org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration in project ma-core-public by infiniteautomation.
the class MangoWebSocketConfiguration method registerWebSocketHandlers.
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
// Setup Allowed Origins for CORS requests
boolean hasOrigins = false;
String[] origins = null;
if (Common.envProps.getBoolean("rest.cors.enabled", false)) {
hasOrigins = true;
origins = Common.envProps.getStringArray("rest.cors.allowedOrigins", ",", new String[0]);
}
for (WebSocketDefinition def : websocketDefinitions()) {
WebSocketHandler handler = def.getHandlerInstance();
if (def.perConnection()) {
PerConnectionWebSocketHandler perConnection = new PerConnectionWebSocketHandler(handler.getClass());
beanFactory.initializeBean(perConnection, PerConnectionWebSocketHandler.class.getName());
handler = perConnection;
} else {
beanFactory.autowireBean(handler);
handler = (WebSocketHandler) beanFactory.initializeBean(handler, handler.getClass().getName());
}
WebSocketHandlerRegistration registration = registry.addHandler(handler, def.getUrl()).setHandshakeHandler(handshakeHandler()).addInterceptors(handshakeIterceptor());
if (hasOrigins)
registration.setAllowedOrigins(origins);
}
}
use of org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration in project pinpoint by naver.
the class WebSocketConfig method registerWebSocketHandlers.
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
final String[] allowedOriginArray = getAllowedOriginArray(configProperties.getWebSocketAllowedOrigins());
for (PinpointWebSocketHandler handler : handlerRepository.getWebSocketHandlerRepository()) {
String path = handler.getRequestMapping() + WEBSOCKET_SUFFIX;
WebSocketHandler webSocketHandler = webSocketHandlerDecoratorFactory.decorate(handler);
final WebSocketHandlerRegistration webSocketHandlerRegistration = registry.addHandler(webSocketHandler, path);
webSocketHandlerRegistration.addInterceptors(new HttpSessionHandshakeInterceptor());
webSocketHandlerRegistration.addInterceptors(new WebSocketSessionContextPrepareHandshakeInterceptor());
if (Objects.nonNull(customHandshakeInterceptor)) {
webSocketHandlerRegistration.addInterceptors(customHandshakeInterceptor);
}
webSocketHandlerRegistration.setAllowedOrigins(allowedOriginArray);
}
}
Aggregations