Java Code Examples for org.springframework.web.reactive.DispatcherHandler

The following examples show how to use org.springframework.web.reactive.DispatcherHandler. These examples are extracted from open source projects. 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
@Override
protected HttpHandler createHttpHandler() {
	AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
	wac.register(TestConfiguration.class);
	wac.refresh();

	return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(wac)).build();
}
 
Example 2
@Override
protected HttpHandler createHttpHandler() {
	this.wac = new AnnotationConfigApplicationContext();
	this.wac.register(TestConfiguration.class);
	this.wac.refresh();

	DispatcherHandler webHandler = new DispatcherHandler();
	webHandler.setApplicationContext(this.wac);

	return WebHttpHandlerBuilder.webHandler(webHandler).build();
}
 
Example 3
@Override
protected HttpHandler createHttpHandler() {
	AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
	wac.register(WebConfig.class);
	wac.refresh();

	return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(wac))
			.exceptionHandler(new ResponseStatusExceptionHandler())
			.build();
}
 
Example 4
Source Project: spring-analysis-note   Source File: MultipartIntegrationTests.java    License: MIT License 5 votes vote down vote up
@Override
protected HttpHandler createHttpHandler() {
	AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
	wac.register(TestConfiguration.class);
	wac.refresh();
	return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(wac)).build();
}
 
Example 5
Source Project: spring-analysis-note   Source File: SseIntegrationTests.java    License: MIT License 5 votes vote down vote up
@Override
protected HttpHandler createHttpHandler() {
	this.wac = new AnnotationConfigApplicationContext();
	this.wac.register(TestConfiguration.class);
	this.wac.refresh();

	return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(this.wac)).build();
}
 
Example 6
@Override
protected HttpHandler createHttpHandler() {
	this.wac = new AnnotationConfigApplicationContext();
	this.wac.register(TestConfiguration.class);
	this.wac.refresh();

	return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(this.wac)).build();
}
 
Example 7
@Override
protected HttpHandler createHttpHandler() {
	AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
	wac.register(TestConfiguration.class);
	wac.refresh();

	return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(wac)).build();
}
 
Example 8
@Override
protected HttpHandler createHttpHandler() {
	this.wac = new AnnotationConfigApplicationContext();
	this.wac.register(TestConfiguration.class);
	this.wac.refresh();

	DispatcherHandler webHandler = new DispatcherHandler();
	webHandler.setApplicationContext(this.wac);

	return WebHttpHandlerBuilder.webHandler(webHandler).build();
}
 
Example 9
@Override
protected HttpHandler createHttpHandler() {
	AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
	wac.register(WebConfig.class);
	wac.refresh();

	return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(wac))
			.exceptionHandler(new ResponseStatusExceptionHandler())
			.build();
}
 
Example 10
Source Project: java-technology-stack   Source File: MultipartIntegrationTests.java    License: MIT License 5 votes vote down vote up
@Override
protected HttpHandler createHttpHandler() {
	AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
	wac.register(TestConfiguration.class);
	wac.refresh();
	return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(wac)).build();
}
 
Example 11
Source Project: java-technology-stack   Source File: SseIntegrationTests.java    License: MIT License 5 votes vote down vote up
@Override
protected HttpHandler createHttpHandler() {
	this.wac = new AnnotationConfigApplicationContext();
	this.wac.register(TestConfiguration.class);
	this.wac.refresh();

	return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(this.wac)).build();
}
 
Example 12
@Override
protected HttpHandler createHttpHandler() {
	this.wac = new AnnotationConfigApplicationContext();
	this.wac.register(TestConfiguration.class);
	this.wac.refresh();

	return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(this.wac)).build();
}
 
Example 13
Source Project: spring-fu   Source File: ReactiveWebServerInitializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(GenericApplicationContext context) {
	context.registerBean("webServerFactoryCustomizerBeanPostProcessor", WebServerFactoryCustomizerBeanPostProcessor.class, WebServerFactoryCustomizerBeanPostProcessor::new);

	context.registerBean(ReactiveWebServerFactoryCustomizer.class, () -> new ReactiveWebServerFactoryCustomizer(this.serverProperties));
	context.registerBean(ConfigurableReactiveWebServerFactory.class, () -> serverFactory);
	//noinspection deprecation
	context.registerBean(ErrorAttributes.class, () -> new DefaultErrorAttributes(serverProperties.getError().isIncludeException()));
	context.registerBean(ErrorWebExceptionHandler.class,  () -> {
		ErrorWebFluxAutoConfiguration errorConfiguration = new ErrorWebFluxAutoConfiguration(this.serverProperties);
		return errorConfiguration.errorWebExceptionHandler(context.getBean(ErrorAttributes.class), this.resourceProperties, context.getBeanProvider(ViewResolver.class), context.getBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class), context);
	});
	context.registerBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class, () -> new EnableWebFluxConfigurationWrapper(context, webFluxProperties));
	context.registerBean(LOCALE_CONTEXT_RESOLVER_BEAN_NAME, LocaleContextResolver.class, () -> context.getBean(EnableWebFluxConfigurationWrapper.class).localeContextResolver());
	context.registerBean("responseStatusExceptionHandler", WebExceptionHandler.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).responseStatusExceptionHandler());

	context.registerBean(RouterFunctionMapping.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).routerFunctionMapping(context.getBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class)));
	context.registerBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).serverCodecConfigurer());
	context.registerBean("webFluxAdapterRegistry", ReactiveAdapterRegistry.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxAdapterRegistry());
	context.registerBean("handlerFunctionAdapter", HandlerFunctionAdapter.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).handlerFunctionAdapter());
	context.registerBean("webFluxContentTypeResolver", RequestedContentTypeResolver.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxContentTypeResolver());
	context.registerBean("webFluxConversionService", FormattingConversionService.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxConversionService());
	context.registerBean("serverResponseResultHandler", ServerResponseResultHandler.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).serverResponseResultHandler(context.getBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class)));
	context.registerBean("simpleHandlerAdapter", SimpleHandlerAdapter.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).simpleHandlerAdapter());
	context.registerBean("viewResolutionResultHandler", ViewResolutionResultHandler.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).viewResolutionResultHandler(context.getBean("webFluxAdapterRegistry", ReactiveAdapterRegistry.class), context.getBean("webFluxContentTypeResolver", RequestedContentTypeResolver.class)));
	context.registerBean("webFluxValidator", Validator.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxValidator());
	context.registerBean(HttpHandler.class, () -> applicationContext(context).build());
	context.registerBean(WEB_HANDLER_BEAN_NAME, DispatcherHandler.class, (Supplier<DispatcherHandler>) DispatcherHandler::new);
	context.registerBean(WebFluxConfig.class, () -> new WebFluxConfig(resourceProperties, webFluxProperties, context, context.getBeanProvider(HandlerMethodArgumentResolver.class), context.getBeanProvider(CodecCustomizer.class),
		context.getBeanProvider(ResourceHandlerRegistrationCustomizer.class), context.getBeanProvider(ViewResolver.class)));
}
 
Example 14
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8095"));
	return httpServer.newHandler(adapter).block();
}
 
Example 15
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8908"));
	return httpServer.newHandler(adapter).block();
}
 
Example 16
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8901"));
	return httpServer.newHandler(adapter).block();
}
 
Example 17
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("9007"));
	return httpServer.newHandler(adapter).block();
}
 
Example 18
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("9006"));
	return httpServer.newHandler(adapter).block();
}
 
Example 19
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8901"));
	return httpServer.newHandler(adapter).block();
}
 
Example 20
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8909"));
	return httpServer.newHandler(adapter).block();
}
 
Example 21
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8125"));
	return httpServer.newHandler(adapter).block();
}
 
Example 22
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("9008"));
	return httpServer.newHandler(adapter).block();
}
 
Example 23
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8901"));
	return httpServer.newHandler(adapter).block();
}
 
Example 24
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8095"));
	return httpServer.newHandler(adapter).block();
}
 
Example 25
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("9008"));
	return httpServer.newHandler(adapter).block();
}
 
Example 26
Source Project: Spring-5.0-Cookbook   Source File: HttpServerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public  NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8908"));
	return httpServer.newHandler(adapter).block();
}
 
Example 27
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;
}
 
Example 28
Source Project: spring-security-reactive   Source File: Application.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create("localhost", port);
	return httpServer.newHandler(adapter).block();
}
 
Example 29
@Bean
@ConditionalOnBean(ReactiveResilience4JCircuitBreakerFactory.class)
public SpringCloudCircuitBreakerResilience4JFilterFactory springCloudCircuitBreakerResilience4JFilterFactory(
		ReactiveResilience4JCircuitBreakerFactory reactiveCircuitBreakerFactory,
		ObjectProvider<DispatcherHandler> dispatcherHandler) {
	return new SpringCloudCircuitBreakerResilience4JFilterFactory(
			reactiveCircuitBreakerFactory, dispatcherHandler);
}
 
Example 30
public SpringCloudCircuitBreakerFilterFactory(
		ReactiveCircuitBreakerFactory reactiveCircuitBreakerFactory,
		ObjectProvider<DispatcherHandler> dispatcherHandlerProvider) {
	super(Config.class);
	this.reactiveCircuitBreakerFactory = reactiveCircuitBreakerFactory;
	this.dispatcherHandlerProvider = dispatcherHandlerProvider;
}