当前位置: 首页>>代码示例>>Java>>正文


Java HandlerMapping类代码示例

本文整理汇总了Java中org.springframework.web.reactive.HandlerMapping的典型用法代码示例。如果您正苦于以下问题:Java HandlerMapping类的具体用法?Java HandlerMapping怎么用?Java HandlerMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HandlerMapping类属于org.springframework.web.reactive包,在下文中一共展示了HandlerMapping类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: webSocketMapping

import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@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;
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:20,代码来源:WebSocketConfig.java

示例2: webSocketMapping

import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
HandlerMapping webSocketMapping(CommentService commentService,
								InboundChatService inboundChatService,
								OutboundChatService outboundChatService) {
	SimpleUrlHandlerMapping mapping =
		configureUrlMappings(commentService, inboundChatService, outboundChatService);

	Map<String, CorsConfiguration> corsConfigurationMap = new HashMap<>();
	CorsConfiguration corsConfiguration = new CorsConfiguration();
	corsConfiguration.addAllowedOrigin(chatConfigProperties.getOrigin());

	mapping.getUrlMap().keySet().forEach(route ->
		corsConfigurationMap.put(route, corsConfiguration)
	);

	mapping.setCorsConfigurations(corsConfigurationMap);

	return mapping;
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:20,代码来源:WebSocketConfig.java

示例3: handlerMapping

import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
public HandlerMapping handlerMapping() {
    Map<String, WebSocketHandler> mappings = new HashMap<>(2);
    mappings.put("/in", session -> {
        session.receive()
            .map(WebSocketMessage::getPayloadAsText)
            .log()
            .subscribe(out::onNext);

        return session.send(Mono.just(session.textMessage(MESSAGE_HELLO))).then(session.send(in.map(session::textMessage)));
    });

    mappings.put("/out", session -> {
        session.receive()
            .map(WebSocketMessage::getPayloadAsText)
            .log()
            .subscribe();

        return session.send(Mono.just(session.textMessage(MESSAGE_HELLO))).then(session.send(out.map(session::textMessage)));
    });

    SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
    mapping.setUrlMap(mappings);
    mapping.setOrder(10);
    return mapping;
}
 
开发者ID:pzmi,项目名称:webflux-websocket-server,代码行数:27,代码来源:Websocket.java

示例4: webSocketMapping

import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@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);

	SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
	mapping.setOrder(10);
	mapping.setUrlMap(urlMap);

	return mapping;
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:16,代码来源:WebSocketConfig.java

示例5: webSocketMapping

import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@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;
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:28,代码来源:WebSocketConfig.java

示例6: webSocketMapping

import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@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;
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:30,代码来源:WebSocketConfig.java

示例7: webSocketMapping

import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
public HandlerMapping webSocketMapping() {
	Map<String, WebSocketHandler> map = new HashMap<>();
	map.put("/react", messageWebSocketHandler);

	SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
	mapping.setOrder(10);
	mapping.setUrlMap(map);
	return mapping;
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:11,代码来源:ReactiveChatSocketConfig.java

示例8: handlerMapping

import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
    public HandlerMapping handlerMapping() {
        Map<String, WebSocketHandler> map = new HashMap<>();
        map.put("/echo", new EchoWebSocketHandler());
	    map.put("/posts", new PostsWebSocketHandler(this.posts));
//			map.put("/custom-header", new CustomHeaderHandler());

        SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
        mapping.setUrlMap(map);
        return mapping;
    }
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:12,代码来源:WebConfig.java

示例9: applicationContext

import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
private static ApplicationContext applicationContext(WebFilter... webFilters) {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	for(WebFilter filter : webFilters) {
		context.registerBean(WebFilter.class, () -> filter);
	}
	context.registerBean("webHandler", DispatcherHandler.class, () -> new DispatcherHandler());
	context.registerBean(HandlerMapping.class, () -> RouterFunctions.toHandlerMapping(request -> Mono.just(r -> ServerResponse.ok().build())));
	context.registerBean(HandlerAdapter.class, () -> new HandlerFunctionAdapter());
	context.registerBean(HandlerResultHandler.class, () -> new ServerResponseResultHandler());
	context.refresh();

	return context;
}
 
开发者ID:spring-projects,项目名称:spring-security-reactive,代码行数:14,代码来源:WebTestClientBuilder.java

示例10: handlerMapping

import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@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());

	SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
	mapping.setUrlMap(map);
	return mapping;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gateway,代码行数:12,代码来源:WebSocketIntegrationTests.java

示例11: handlerMapping

import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@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;
}
 
开发者ID:sdeleuze,项目名称:spring-reactive-playground,代码行数:11,代码来源:Application.java


注:本文中的org.springframework.web.reactive.HandlerMapping类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。