org.springframework.web.reactive.function.server.support.ServerResponseResultHandler Java Examples

The following examples show how to use org.springframework.web.reactive.function.server.support.ServerResponseResultHandler. 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: WebFluxConfigurationSupport.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Bean
public ServerResponseResultHandler serverResponseResultHandler(
		ServerCodecConfigurer serverCodecConfigurer) {
	List<ViewResolver> resolvers = getViewResolverRegistry().getViewResolvers();
	ServerResponseResultHandler handler = new ServerResponseResultHandler();
	handler.setMessageWriters(serverCodecConfigurer.getWriters());
	handler.setViewResolvers(resolvers);
	return handler;
}
 
Example #2
Source File: WebFluxConfigurationSupport.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Bean
public ServerResponseResultHandler serverResponseResultHandler() {
	List<ViewResolver> resolvers = getViewResolverRegistry().getViewResolvers();
	ServerResponseResultHandler handler = new ServerResponseResultHandler();
	handler.setMessageWriters(serverCodecConfigurer().getWriters());
	handler.setViewResolvers(resolvers);
	return handler;
}
 
Example #3
Source File: ReactiveWebServerInitializer.java    From spring-fu with 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 #4
Source File: WebTestClientBuilder.java    From spring-security-reactive with Apache License 2.0 5 votes vote down vote up
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;
}