Java Code Examples for org.springframework.web.reactive.handler.SimpleUrlHandlerMapping#setUrlMap()
The following examples show how to use
org.springframework.web.reactive.handler.SimpleUrlHandlerMapping#setUrlMap() .
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: WebSocketMessagingHandlerConfiguration.java From jetlinks-community with Apache License 2.0 | 6 votes |
@Bean public HandlerMapping webSocketMessagingHandlerMapping(MessagingManager messagingManager, UserTokenManager userTokenManager, ReactiveAuthenticationManager authenticationManager) { WebSocketMessagingHandler messagingHandler=new WebSocketMessagingHandler( messagingManager, userTokenManager, authenticationManager ); final Map<String, WebSocketHandler> map = new HashMap<>(1); map.put("/messaging/**", messagingHandler); final SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setOrder(Ordered.HIGHEST_PRECEDENCE); mapping.setUrlMap(map); return mapping; }
Example 2
Source File: WebSocketConfig.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 6 votes |
@Bean HandlerMapping webSocketMapping(CommentService commentService) { Map<String, WebSocketHandler> urlMap = new HashMap<>(); urlMap.put("/topic/comments.new", commentService); Map<String, CorsConfiguration> corsConfigurationMap = new HashMap<>(); CorsConfiguration corsConfiguration = new CorsConfiguration(); corsConfiguration.addAllowedOrigin("http://localhost:8080"); corsConfigurationMap.put( "/topic/comments.new", corsConfiguration); SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setOrder(10); mapping.setUrlMap(urlMap); mapping.setCorsConfigurations(corsConfigurationMap); return mapping; }
Example 3
Source File: WebSocketRouter.java From webFluxTemplate with MIT License | 5 votes |
@Bean public HandlerMapping handlerMapping() { Map<String, WebSocketHandler> map = new HashMap<>(); map.put("/api/ws/echotest", new DefaultWebSocketHandler()); SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.initApplicationContext(); mapping.setOrder(10); mapping.setUrlMap(map); return mapping; }
Example 4
Source File: WebSocketConfig.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 5 votes |
private static SimpleUrlHandlerMapping configureUrlMappings(CommentService commentService, InboundChatService inboundChatService, OutboundChatService outboundChatService) { Map<String, WebSocketHandler> urlMap = new HashMap<>(); urlMap.put("/topic/comments.new", commentService); urlMap.put("/app/chatMessage.new", inboundChatService); urlMap.put("/topic/chatMessage.new", outboundChatService); SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setOrder(10); mapping.setUrlMap(urlMap); return mapping; }
Example 5
Source File: WebSocketConfig.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 5 votes |
@Bean HandlerMapping webSocketMapping(CommentService commentService, InboundChatService inboundChatService, OutboundChatService outboundChatService) { Map<String, WebSocketHandler> urlMap = new HashMap<>(); urlMap.put("/topic/comments.new", commentService); urlMap.put("/app/chatMessage.new", inboundChatService); urlMap.put("/topic/chatMessage.new", outboundChatService); // tag::cors[] Map<String, CorsConfiguration> corsConfigurationMap = new HashMap<>(); CorsConfiguration corsConfiguration = new CorsConfiguration(); corsConfiguration.addAllowedOrigin("http://localhost:8080"); corsConfigurationMap.put( "/topic/comments.new", corsConfiguration); corsConfigurationMap.put( "/app/chatMessage.new", corsConfiguration); corsConfigurationMap.put( "/topic/chatMessage.new", corsConfiguration); // end::cors[] SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setOrder(10); mapping.setUrlMap(urlMap); mapping.setCorsConfigurations(corsConfigurationMap); return mapping; }
Example 6
Source File: WebSocketConfig.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 5 votes |
@Bean HandlerMapping webSocketMapping(CommentService commentService, InboundChatService inboundChatService, OutboundChatService outboundChatService) { Map<String, WebSocketHandler> urlMap = new HashMap<>(); urlMap.put("/topic/comments.new", commentService); urlMap.put("/app/chatMessage.new", inboundChatService); urlMap.put("/topic/chatMessage.new", outboundChatService); Map<String, CorsConfiguration> corsConfigurationMap = new HashMap<>(); CorsConfiguration corsConfiguration = new CorsConfiguration(); corsConfiguration.addAllowedOrigin("http://localhost:8080"); corsConfigurationMap.put( "/topic/comments.new", corsConfiguration); corsConfigurationMap.put( "/app/chatMessage.new", corsConfiguration); corsConfigurationMap.put( "/topic/chatMessage.new", corsConfiguration); SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setOrder(10); mapping.setUrlMap(urlMap); mapping.setCorsConfigurations(corsConfigurationMap); return mapping; }
Example 7
Source File: EmployeeConfig.java From tutorials with MIT License | 5 votes |
@Bean public HandlerMapping handlerMapping() { Map<String, WebSocketHandler> map = new HashMap<>(); map.put("/employee-feed", new EmployeeWebSocketHandler()); SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setUrlMap(map); mapping.setOrder(10); return mapping; }
Example 8
Source File: ServiceInstanceLogStreamAutoConfiguration.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Bean public HandlerMapping logsHandlerMapping(StreamingLogWebSocketHandler webSocketHandler) { Map<String, WebSocketHandler> map = new HashMap<>(); map.put("/logs/**/stream", webSocketHandler); SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping(); handlerMapping.setOrder(1); handlerMapping.setUrlMap(map); return handlerMapping; }
Example 9
Source File: WebSocketConfiguration.java From reactor-workshop with GNU General Public License v3.0 | 5 votes |
@Bean public HandlerMapping handlerMapping() { Map<String, WebSocketHandler> map = Map.of( "/echo", new EchoHandler(), "/time", new TimeHandler() ); SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setUrlMap(map); mapping.setOrder(-1); return mapping; }
Example 10
Source File: SpringWebFluxDemoApplication.java From Spring-5.0-Projects with MIT License | 5 votes |
@Bean public HandlerMapping webSockertHandlerMapping() { Map<String, WebSocketHandler> map = new HashMap<>(); map.put("/student", studentWebSocketHandler); SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setUrlMap(map); return mapping; }
Example 11
Source File: WebSocketConfiguration.java From Hands-On-Reactive-Programming-in-Spring-5 with MIT License | 5 votes |
@Bean public HandlerMapping handlerMapping() { SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setUrlMap(Collections.singletonMap("/ws/echo", new EchoWebSocketHandler())); mapping.setOrder(-1); return mapping; }
Example 12
Source File: ResourceHandlerRegistry.java From spring-analysis-note with MIT License | 5 votes |
/** * Return a handler mapping with the mapped resource handlers; or {@code null} in case * of no registrations. */ @Nullable protected AbstractUrlHandlerMapping getHandlerMapping() { if (this.registrations.isEmpty()) { return null; } Map<String, WebHandler> urlMap = new LinkedHashMap<>(); for (ResourceHandlerRegistration registration : this.registrations) { for (String pathPattern : registration.getPathPatterns()) { ResourceWebHandler handler = registration.getRequestHandler(); handler.getResourceTransformers().forEach(transformer -> { if (transformer instanceof ResourceTransformerSupport) { ((ResourceTransformerSupport) transformer).setResourceUrlProvider(this.resourceUrlProvider); } }); try { handler.afterPropertiesSet(); } catch (Throwable ex) { throw new BeanInitializationException("Failed to init ResourceHttpRequestHandler", ex); } urlMap.put(pathPattern, handler); } } SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping(); handlerMapping.setOrder(this.order); handlerMapping.setUrlMap(urlMap); return handlerMapping; }
Example 13
Source File: WebSocketConfiguration.java From springboot-learning-example with Apache License 2.0 | 5 votes |
@Autowired @Bean public HandlerMapping webSocketMapping(final EchoHandler echoHandler) { final Map<String, WebSocketHandler> map = new HashMap<>(); map.put("/echo", echoHandler); final SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setOrder(Ordered.HIGHEST_PRECEDENCE); mapping.setUrlMap(map); return mapping; }
Example 14
Source File: WebSocketConfiguration.java From soul with Apache License 2.0 | 5 votes |
/** * Web socket mapping handler mapping. * * @param echoHandler the echo handler * @return the handler mapping */ @Bean public HandlerMapping webSocketMapping(final EchoHandler echoHandler) { final Map<String, WebSocketHandler> map = new HashMap<>(1); map.put("/echo", echoHandler); final SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setOrder(Ordered.HIGHEST_PRECEDENCE); mapping.setUrlMap(map); return mapping; }
Example 15
Source File: Application.java From spring-reactive-playground with Apache License 2.0 | 5 votes |
@Bean public HandlerMapping handlerMapping() { Map<String, WebSocketHandler> map = new HashMap<>(); map.put("/websocket/echo", new EchoWebSocketHandler()); SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setUrlMap(map); return mapping; }
Example 16
Source File: ResourceUrlProviderTests.java From java-technology-stack with MIT License | 5 votes |
@Bean public SimpleUrlHandlerMapping simpleUrlHandlerMapping() { ResourceWebHandler handler = new ResourceWebHandler(); HashMap<String, ResourceWebHandler> handlerMap = new HashMap<>(); handlerMap.put("/resources/**", handler); SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping(); hm.setUrlMap(handlerMap); return hm; }
Example 17
Source File: WebSocketIntegrationTests.java From java-technology-stack with MIT License | 5 votes |
@Bean public HandlerMapping handlerMapping() { Map<String, WebSocketHandler> map = new HashMap<>(); map.put("/echo", new EchoWebSocketHandler()); map.put("/sub-protocol", new SubProtocolWebSocketHandler()); map.put("/custom-header", new CustomHeaderHandler()); map.put("/close", new SessionClosingHandler()); SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setUrlMap(map); return mapping; }
Example 18
Source File: WebSocketConfiguration.java From tools-journey with Apache License 2.0 | 5 votes |
@Autowired @Bean public HandlerMapping webSocketMapping(final EchoHandler echoHandler) { final Map<String, WebSocketHandler> map = new HashMap<>(1); map.put("/objectecho", echoHandler); final SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setOrder(Ordered.HIGHEST_PRECEDENCE); mapping.setUrlMap(map); return mapping; }
Example 19
Source File: ResourceUrlProviderTests.java From spring-analysis-note with MIT License | 5 votes |
@Bean public SimpleUrlHandlerMapping simpleUrlHandlerMapping() { ResourceWebHandler handler = new ResourceWebHandler(); HashMap<String, ResourceWebHandler> handlerMap = new HashMap<>(); handlerMap.put("/resources/**", handler); SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping(); hm.setUrlMap(handlerMap); return hm; }
Example 20
Source File: WebSocketIntegrationTests.java From spring-cloud-gateway with Apache License 2.0 | 5 votes |
@Bean public HandlerMapping handlerMapping() { Map<String, WebSocketHandler> map = new HashMap<>(); map.put("/echo", new EchoWebSocketHandler()); map.put("/echoForHttp", new EchoWebSocketHandler()); map.put("/sub-protocol", new SubProtocolWebSocketHandler()); map.put("/custom-header", new CustomHeaderHandler()); map.put("/close", new SessionClosingHandler()); SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setUrlMap(map); return mapping; }