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

The following examples show how to use org.springframework.web.reactive.function.server.support.RouterFunctionMapping. 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 RouterFunctionMapping routerFunctionMapping(ServerCodecConfigurer serverCodecConfigurer) {
	RouterFunctionMapping mapping = createRouterFunctionMapping();
	mapping.setOrder(-1); // go before RequestMappingHandlerMapping
	mapping.setMessageReaders(serverCodecConfigurer.getReaders());
	mapping.setCorsConfigurations(getCorsConfigurations());

	return mapping;
}
 
Example #2
Source File: WebFluxConfigurationSupport.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Bean
public RouterFunctionMapping routerFunctionMapping() {
	RouterFunctionMapping mapping = createRouterFunctionMapping();
	mapping.setOrder(-1); // go before RequestMappingHandlerMapping
	mapping.setMessageReaders(serverCodecConfigurer().getReaders());
	mapping.setCorsConfigurations(getCorsConfigurations());

	return mapping;
}
 
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: WebFluxConfigurationSupport.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Override to plug a sub-class of {@link RouterFunctionMapping}.
 */
protected RouterFunctionMapping createRouterFunctionMapping() {
	return new RouterFunctionMapping();
}
 
Example #5
Source File: WebFluxConfigurationSupport.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Override to plug a sub-class of {@link RouterFunctionMapping}.
 */
protected RouterFunctionMapping createRouterFunctionMapping() {
	return new RouterFunctionMapping();
}