Search in sources :

Example 1 with WebSocketHandlerMapping

use of org.springframework.web.socket.server.support.WebSocketHandlerMapping in project spring-framework by spring-projects.

the class ServletWebSocketHandlerRegistry method getHandlerMapping.

/**
	 * Return a {@link HandlerMapping} with mapped {@link HttpRequestHandler}s.
	 */
public AbstractHandlerMapping getHandlerMapping() {
    Map<String, Object> urlMap = new LinkedHashMap<>();
    for (ServletWebSocketHandlerRegistration registration : this.registrations) {
        MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
        for (HttpRequestHandler httpHandler : mappings.keySet()) {
            for (String pattern : mappings.get(httpHandler)) {
                urlMap.put(pattern, httpHandler);
            }
        }
    }
    WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
    hm.setUrlMap(urlMap);
    hm.setOrder(this.order);
    if (this.urlPathHelper != null) {
        hm.setUrlPathHelper(this.urlPathHelper);
    }
    return hm;
}
Also used : HttpRequestHandler(org.springframework.web.HttpRequestHandler) WebSocketHandlerMapping(org.springframework.web.socket.server.support.WebSocketHandlerMapping) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with WebSocketHandlerMapping

use of org.springframework.web.socket.server.support.WebSocketHandlerMapping in project spring-framework by spring-projects.

the class WebMvcStompEndpointRegistry method getHandlerMapping.

/**
	 * Return a handler mapping with the mapped ViewControllers; or {@code null}
	 * in case of no registrations.
	 */
public AbstractHandlerMapping getHandlerMapping() {
    Map<String, Object> urlMap = new LinkedHashMap<>();
    for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) {
        MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
        for (HttpRequestHandler httpHandler : mappings.keySet()) {
            for (String pattern : mappings.get(httpHandler)) {
                urlMap.put(pattern, httpHandler);
            }
        }
    }
    WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
    hm.setUrlMap(urlMap);
    hm.setOrder(this.order);
    if (this.urlPathHelper != null) {
        hm.setUrlPathHelper(this.urlPathHelper);
    }
    return hm;
}
Also used : HttpRequestHandler(org.springframework.web.HttpRequestHandler) WebSocketHandlerMapping(org.springframework.web.socket.server.support.WebSocketHandlerMapping) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)2 HttpRequestHandler (org.springframework.web.HttpRequestHandler)2 WebSocketHandlerMapping (org.springframework.web.socket.server.support.WebSocketHandlerMapping)2