org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver Java Examples

The following examples show how to use org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver. 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: 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 #2
Source File: ControllerMethodResolverTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void exceptionHandlerArgumentResolvers() {
	InvocableHandlerMethod invocable = this.methodResolver.getExceptionHandlerMethod(
			new ResponseStatusException(HttpStatus.BAD_REQUEST, "reason"), this.handlerMethod);

	assertNotNull("No match", invocable);
	assertEquals(TestController.class, invocable.getBeanType());
	List<HandlerMethodArgumentResolver> resolvers = invocable.getResolvers();

	AtomicInteger index = new AtomicInteger(-1);
	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestParamMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CookieValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ExpressionValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(SessionAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(ModelArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ServerWebExchangeArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PrincipalArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(WebSessionArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(CustomArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CustomSyncArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
}
 
Example #3
Source File: ControllerMethodResolverTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void modelAttributeArgumentResolvers() {
	List<InvocableHandlerMethod> methods = this.methodResolver.getModelAttributeMethods(this.handlerMethod);

	assertEquals("Expected one each from Controller + ControllerAdvice", 2, methods.size());
	InvocableHandlerMethod invocable = methods.get(0);
	List<HandlerMethodArgumentResolver> resolvers = invocable.getResolvers();

	AtomicInteger index = new AtomicInteger(-1);
	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestParamMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CookieValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ExpressionValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(SessionAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(ModelArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ErrorsMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ServerWebExchangeArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PrincipalArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(WebSessionArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(CustomArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CustomSyncArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
}
 
Example #4
Source File: ControllerMethodResolverTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void requestMappingArgumentResolvers() {
	InvocableHandlerMethod invocable = this.methodResolver.getRequestMappingMethod(this.handlerMethod);
	List<HandlerMethodArgumentResolver> resolvers = invocable.getResolvers();

	AtomicInteger index = new AtomicInteger(-1);
	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestParamMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestBodyArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestPartMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CookieValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ExpressionValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(SessionAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(HttpEntityArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ErrorsMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ServerWebExchangeArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PrincipalArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(SessionStatusMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(WebSessionArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(CustomArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CustomSyncArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
}
 
Example #5
Source File: ControllerMethodResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void requestMappingArgumentResolvers() {
	InvocableHandlerMethod invocable = this.methodResolver.getRequestMappingMethod(this.handlerMethod);
	List<HandlerMethodArgumentResolver> resolvers = invocable.getResolvers();

	AtomicInteger index = new AtomicInteger(-1);
	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestParamMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestBodyMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestPartMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CookieValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ExpressionValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(SessionAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(ContinuationHandlerMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(HttpEntityMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ErrorsMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ServerWebExchangeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PrincipalMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(SessionStatusMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(WebSessionMethodArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(CustomArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CustomSyncArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
}
 
Example #6
Source File: ControllerMethodResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void modelAttributeArgumentResolvers() {
	List<InvocableHandlerMethod> methods = this.methodResolver.getModelAttributeMethods(this.handlerMethod);

	assertEquals("Expected one each from Controller + ControllerAdvice", 2, methods.size());
	InvocableHandlerMethod invocable = methods.get(0);
	List<HandlerMethodArgumentResolver> resolvers = invocable.getResolvers();

	AtomicInteger index = new AtomicInteger(-1);
	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestParamMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CookieValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ExpressionValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(SessionAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(ContinuationHandlerMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ErrorsMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ServerWebExchangeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PrincipalMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(WebSessionMethodArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(CustomArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CustomSyncArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
}
 
Example #7
Source File: ControllerMethodResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void exceptionHandlerArgumentResolvers() {
	InvocableHandlerMethod invocable = this.methodResolver.getExceptionHandlerMethod(
			new ResponseStatusException(HttpStatus.BAD_REQUEST, "reason"), this.handlerMethod);

	assertNotNull("No match", invocable);
	assertEquals(TestController.class, invocable.getBeanType());
	List<HandlerMethodArgumentResolver> resolvers = invocable.getResolvers();

	AtomicInteger index = new AtomicInteger(-1);
	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestParamMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PathVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(MatrixVariableMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestHeaderMapMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CookieValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ExpressionValueMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(SessionAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(RequestAttributeMethodArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(ContinuationHandlerMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ModelMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(ServerWebExchangeMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(PrincipalMethodArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(WebSessionMethodArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(CustomArgumentResolver.class, next(resolvers, index).getClass());
	assertEquals(CustomSyncArgumentResolver.class, next(resolvers, index).getClass());

	assertEquals(RequestParamMethodArgumentResolver.class, next(resolvers, index).getClass());
}
 
Example #8
Source File: ControllerMethodResolver.java    From java-technology-stack with MIT License 4 votes vote down vote up
private static List<HandlerMethodArgumentResolver> modelMethodResolvers(
		ArgumentResolverConfigurer customResolvers, ReactiveAdapterRegistry reactiveRegistry,
		ConfigurableApplicationContext context) {

	return initResolvers(customResolvers, reactiveRegistry, context, true, Collections.emptyList());
}
 
Example #9
Source File: ControllerMethodResolverTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
private static HandlerMethodArgumentResolver next(
		List<? extends HandlerMethodArgumentResolver> resolvers, AtomicInteger index) {

	return resolvers.get(index.incrementAndGet());
}
 
Example #10
Source File: ArgumentResolverConfigurer.java    From java-technology-stack with MIT License 4 votes vote down vote up
List<HandlerMethodArgumentResolver> getCustomResolvers() {
	return this.customResolvers;
}
 
Example #11
Source File: ArgumentResolverConfigurer.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Configure resolvers for custom controller method arguments.
 * @param resolver the resolver(s) to add
 */
public void addCustomResolver(HandlerMethodArgumentResolver... resolver) {
	Assert.notNull(resolver, "'resolvers' must not be null");
	this.customResolvers.addAll(Arrays.asList(resolver));
}
 
Example #12
Source File: ControllerMethodResolver.java    From java-technology-stack with MIT License 4 votes vote down vote up
private static List<HandlerMethodArgumentResolver> initResolvers(ArgumentResolverConfigurer customResolvers,
		ReactiveAdapterRegistry reactiveRegistry, ConfigurableApplicationContext context,
		boolean supportDataBinding, List<HttpMessageReader<?>> readers) {

	ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
	boolean requestMappingMethod = !readers.isEmpty() && supportDataBinding;

	// Annotation-based...
	List<HandlerMethodArgumentResolver> result = new ArrayList<>();
	result.add(new RequestParamMethodArgumentResolver(beanFactory, reactiveRegistry, false));
	result.add(new RequestParamMapMethodArgumentResolver(reactiveRegistry));
	result.add(new PathVariableMethodArgumentResolver(beanFactory, reactiveRegistry));
	result.add(new PathVariableMapMethodArgumentResolver(reactiveRegistry));
	result.add(new MatrixVariableMethodArgumentResolver(beanFactory, reactiveRegistry));
	result.add(new MatrixVariableMapMethodArgumentResolver(reactiveRegistry));
	if (!readers.isEmpty()) {
		result.add(new RequestBodyArgumentResolver(readers, reactiveRegistry));
		result.add(new RequestPartMethodArgumentResolver(readers, reactiveRegistry));
	}
	if (supportDataBinding) {
		result.add(new ModelAttributeMethodArgumentResolver(reactiveRegistry, false));
	}
	result.add(new RequestHeaderMethodArgumentResolver(beanFactory, reactiveRegistry));
	result.add(new RequestHeaderMapMethodArgumentResolver(reactiveRegistry));
	result.add(new CookieValueMethodArgumentResolver(beanFactory, reactiveRegistry));
	result.add(new ExpressionValueMethodArgumentResolver(beanFactory, reactiveRegistry));
	result.add(new SessionAttributeMethodArgumentResolver(beanFactory, reactiveRegistry));
	result.add(new RequestAttributeMethodArgumentResolver(beanFactory, reactiveRegistry));

	// Type-based...
	if (!readers.isEmpty()) {
		result.add(new HttpEntityArgumentResolver(readers, reactiveRegistry));
	}
	result.add(new ModelArgumentResolver(reactiveRegistry));
	if (supportDataBinding) {
		result.add(new ErrorsMethodArgumentResolver(reactiveRegistry));
	}
	result.add(new ServerWebExchangeArgumentResolver(reactiveRegistry));
	result.add(new PrincipalArgumentResolver(reactiveRegistry));
	if (requestMappingMethod) {
		result.add(new SessionStatusMethodArgumentResolver());
	}
	result.add(new WebSessionArgumentResolver(reactiveRegistry));

	// Custom...
	result.addAll(customResolvers.getCustomResolvers());

	// Catch-all...
	result.add(new RequestParamMethodArgumentResolver(beanFactory, reactiveRegistry, true));
	if (supportDataBinding) {
		result.add(new ModelAttributeMethodArgumentResolver(reactiveRegistry, true));
	}

	return result;
}
 
Example #13
Source File: ControllerMethodResolver.java    From java-technology-stack with MIT License 4 votes vote down vote up
private static List<HandlerMethodArgumentResolver> exceptionHandlerResolvers(
		ArgumentResolverConfigurer customResolvers, ReactiveAdapterRegistry reactiveRegistry,
		ConfigurableApplicationContext context) {

	return initResolvers(customResolvers, reactiveRegistry, context, false, Collections.emptyList());
}
 
Example #14
Source File: ControllerMethodResolver.java    From java-technology-stack with MIT License 4 votes vote down vote up
private static List<HandlerMethodArgumentResolver> requestMappingResolvers(
		ArgumentResolverConfigurer customResolvers, ReactiveAdapterRegistry reactiveRegistry,
		ConfigurableApplicationContext context, List<HttpMessageReader<?>> readers) {

	return initResolvers(customResolvers, reactiveRegistry, context, true, readers);
}
 
Example #15
Source File: ControllerMethodResolver.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static List<HandlerMethodArgumentResolver> modelMethodResolvers(
		ArgumentResolverConfigurer customResolvers, ReactiveAdapterRegistry adapterRegistry,
		ConfigurableApplicationContext context) {

	return initResolvers(customResolvers, adapterRegistry, context, true, Collections.emptyList());
}
 
Example #16
Source File: ControllerMethodResolverTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static HandlerMethodArgumentResolver next(
		List<? extends HandlerMethodArgumentResolver> resolvers, AtomicInteger index) {

	return resolvers.get(index.incrementAndGet());
}
 
Example #17
Source File: ArgumentResolverConfigurer.java    From spring-analysis-note with MIT License 4 votes vote down vote up
List<HandlerMethodArgumentResolver> getCustomResolvers() {
	return this.customResolvers;
}
 
Example #18
Source File: ArgumentResolverConfigurer.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Configure resolvers for custom controller method arguments.
 * @param resolver the resolver(s) to add
 */
public void addCustomResolver(HandlerMethodArgumentResolver... resolver) {
	Assert.notNull(resolver, "'resolvers' must not be null");
	this.customResolvers.addAll(Arrays.asList(resolver));
}
 
Example #19
Source File: ControllerMethodResolver.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static List<HandlerMethodArgumentResolver> initResolvers(ArgumentResolverConfigurer customResolvers,
		ReactiveAdapterRegistry adapterRegistry, ConfigurableApplicationContext context,
		boolean supportDataBinding, List<HttpMessageReader<?>> readers) {

	ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
	boolean requestMappingMethod = !readers.isEmpty() && supportDataBinding;

	// Annotation-based...
	List<HandlerMethodArgumentResolver> result = new ArrayList<>();
	result.add(new RequestParamMethodArgumentResolver(beanFactory, adapterRegistry, false));
	result.add(new RequestParamMapMethodArgumentResolver(adapterRegistry));
	result.add(new PathVariableMethodArgumentResolver(beanFactory, adapterRegistry));
	result.add(new PathVariableMapMethodArgumentResolver(adapterRegistry));
	result.add(new MatrixVariableMethodArgumentResolver(beanFactory, adapterRegistry));
	result.add(new MatrixVariableMapMethodArgumentResolver(adapterRegistry));
	if (!readers.isEmpty()) {
		result.add(new RequestBodyMethodArgumentResolver(readers, adapterRegistry));
		result.add(new RequestPartMethodArgumentResolver(readers, adapterRegistry));
	}
	if (supportDataBinding) {
		result.add(new ModelAttributeMethodArgumentResolver(adapterRegistry, false));
	}
	result.add(new RequestHeaderMethodArgumentResolver(beanFactory, adapterRegistry));
	result.add(new RequestHeaderMapMethodArgumentResolver(adapterRegistry));
	result.add(new CookieValueMethodArgumentResolver(beanFactory, adapterRegistry));
	result.add(new ExpressionValueMethodArgumentResolver(beanFactory, adapterRegistry));
	result.add(new SessionAttributeMethodArgumentResolver(beanFactory, adapterRegistry));
	result.add(new RequestAttributeMethodArgumentResolver(beanFactory, adapterRegistry));

	// Type-based...
	if (KotlinDetector.isKotlinPresent()) {
		result.add(new ContinuationHandlerMethodArgumentResolver());
	}
	if (!readers.isEmpty()) {
		result.add(new HttpEntityMethodArgumentResolver(readers, adapterRegistry));
	}
	result.add(new ModelMethodArgumentResolver(adapterRegistry));
	if (supportDataBinding) {
		result.add(new ErrorsMethodArgumentResolver(adapterRegistry));
	}
	result.add(new ServerWebExchangeMethodArgumentResolver(adapterRegistry));
	result.add(new PrincipalMethodArgumentResolver(adapterRegistry));
	if (requestMappingMethod) {
		result.add(new SessionStatusMethodArgumentResolver());
	}
	result.add(new WebSessionMethodArgumentResolver(adapterRegistry));

	// Custom...
	result.addAll(customResolvers.getCustomResolvers());

	// Catch-all...
	result.add(new RequestParamMethodArgumentResolver(beanFactory, adapterRegistry, true));
	if (supportDataBinding) {
		result.add(new ModelAttributeMethodArgumentResolver(adapterRegistry, true));
	}

	return result;
}
 
Example #20
Source File: ControllerMethodResolver.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static List<HandlerMethodArgumentResolver> exceptionHandlerResolvers(
		ArgumentResolverConfigurer customResolvers, ReactiveAdapterRegistry adapterRegistry,
		ConfigurableApplicationContext context) {

	return initResolvers(customResolvers, adapterRegistry, context, false, Collections.emptyList());
}
 
Example #21
Source File: ControllerMethodResolver.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static List<HandlerMethodArgumentResolver> requestMappingResolvers(
		ArgumentResolverConfigurer customResolvers, ReactiveAdapterRegistry adapterRegistry,
		ConfigurableApplicationContext context, List<HttpMessageReader<?>> readers) {

	return initResolvers(customResolvers, adapterRegistry, context, true, readers);
}