Example usage for org.springframework.web.socket.config.annotation StompWebSocketEndpointRegistration setAllowedOrigins

List of usage examples for org.springframework.web.socket.config.annotation StompWebSocketEndpointRegistration setAllowedOrigins

Introduction

In this page you can find the example usage for org.springframework.web.socket.config.annotation StompWebSocketEndpointRegistration setAllowedOrigins.

Prototype

StompWebSocketEndpointRegistration setAllowedOrigins(String... origins);

Source Link

Document

Configure allowed Origin header values.

Usage

From source file:org.appverse.web.framework.backend.frontfacade.websocket.autoconfigure.FrontFacadeWebSocketAutoConfiguration.java

@Override
public void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) {

    logger.info("Initializing websocket standard on path:'{}' ...", defaultWebsocketEndpointPath);
    StompWebSocketEndpointRegistration webSockedEndpoint = stompEndpointRegistry
            .addEndpoint(defaultWebsocketEndpointPath);
    logger.info("Initializing websocket sockJs on path:'{}' ...", defaultSockJsEndpointPath);
    StompWebSocketEndpointRegistration sockJsEndpoint = stompEndpointRegistry
            .addEndpoint(defaultSockJsEndpointPath);
    sockJsEndpoint.withSockJS();/*from   w  w w . ja  v a  2  s .c o  m*/
    if (Boolean.valueOf(corsEnabled)) {
        logger.info("Initializing cors on websockets");
        webSockedEndpoint.setAllowedOrigins(StringUtils.commaDelimitedListToStringArray(allowedOrigins));
        sockJsEndpoint.setAllowedOrigins(StringUtils.commaDelimitedListToStringArray(allowedOrigins));
    }
}