Java Code Examples for org.springframework.web.method.support.HandlerMethodArgumentResolverComposite#addResolver()

The following examples show how to use org.springframework.web.method.support.HandlerMethodArgumentResolverComposite#addResolver() . 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: ModelFactoryTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private ModelFactory createModelFactory(String methodName, Class<?>... parameterTypes) throws Exception {
	HandlerMethodArgumentResolverComposite resolvers = new HandlerMethodArgumentResolverComposite();
	resolvers.addResolver(new ModelMethodProcessor());

	InvocableHandlerMethod modelMethod = createHandlerMethod(methodName, parameterTypes);
	modelMethod.setHandlerMethodArgumentResolvers(resolvers);
	modelMethod.setDataBinderFactory(null);
	modelMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());

	return new ModelFactory(Collections.singletonList(modelMethod), null, this.attributeHandler);
}
 
Example 2
Source File: ModelFactoryOrderingTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void runTest(Object controller) throws Exception {
	HandlerMethodArgumentResolverComposite resolvers = new HandlerMethodArgumentResolverComposite();
	resolvers.addResolver(new ModelAttributeMethodProcessor(false));
	resolvers.addResolver(new ModelMethodProcessor());
	WebDataBinderFactory dataBinderFactory = new DefaultDataBinderFactory(null);

	Class<?> type = controller.getClass();
	Set<Method> methods = MethodIntrospector.selectMethods(type, METHOD_FILTER);
	List<InvocableHandlerMethod> modelMethods = new ArrayList<>();
	for (Method method : methods) {
		InvocableHandlerMethod modelMethod = new InvocableHandlerMethod(controller, method);
		modelMethod.setHandlerMethodArgumentResolvers(resolvers);
		modelMethod.setDataBinderFactory(dataBinderFactory);
		modelMethods.add(modelMethod);
	}
	Collections.shuffle(modelMethods);

	SessionAttributesHandler sessionHandler = new SessionAttributesHandler(type, this.sessionAttributeStore);
	ModelFactory factory = new ModelFactory(modelMethods, dataBinderFactory, sessionHandler);
	factory.initModel(this.webRequest, this.mavContainer, new HandlerMethod(controller, "handle"));
	if (logger.isDebugEnabled()) {
		StringBuilder sb = new StringBuilder();
		for (String name : getInvokedMethods()) {
			sb.append(" >> ").append(name);
		}
		logger.debug(sb);
	}
}
 
Example 3
Source File: ModelFactoryTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private ModelFactory createModelFactory(String methodName, Class<?>... parameterTypes) throws Exception {
	HandlerMethodArgumentResolverComposite resolvers = new HandlerMethodArgumentResolverComposite();
	resolvers.addResolver(new ModelMethodProcessor());

	InvocableHandlerMethod modelMethod = createHandlerMethod(methodName, parameterTypes);
	modelMethod.setHandlerMethodArgumentResolvers(resolvers);
	modelMethod.setDataBinderFactory(null);
	modelMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());

	return new ModelFactory(Collections.singletonList(modelMethod), null, this.attributeHandler);
}
 
Example 4
Source File: ModelFactoryOrderingTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void runTest(Object controller) throws Exception {
	HandlerMethodArgumentResolverComposite resolvers = new HandlerMethodArgumentResolverComposite();
	resolvers.addResolver(new ModelAttributeMethodProcessor(false));
	resolvers.addResolver(new ModelMethodProcessor());
	WebDataBinderFactory dataBinderFactory = new DefaultDataBinderFactory(null);

	Class<?> type = controller.getClass();
	Set<Method> methods = MethodIntrospector.selectMethods(type, METHOD_FILTER);
	List<InvocableHandlerMethod> modelMethods = new ArrayList<>();
	for (Method method : methods) {
		InvocableHandlerMethod modelMethod = new InvocableHandlerMethod(controller, method);
		modelMethod.setHandlerMethodArgumentResolvers(resolvers);
		modelMethod.setDataBinderFactory(dataBinderFactory);
		modelMethods.add(modelMethod);
	}
	Collections.shuffle(modelMethods);

	SessionAttributesHandler sessionHandler = new SessionAttributesHandler(type, this.sessionAttributeStore);
	ModelFactory factory = new ModelFactory(modelMethods, dataBinderFactory, sessionHandler);
	factory.initModel(this.webRequest, this.mavContainer, new HandlerMethod(controller, "handle"));
	if (logger.isDebugEnabled()) {
		StringBuilder sb = new StringBuilder();
		for (String name : getInvokedMethods()) {
			sb.append(" >> ").append(name);
		}
		logger.debug(sb);
	}
}
 
Example 5
Source File: ModelFactoryTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private ModelFactory createModelFactory(String methodName, Class<?>... parameterTypes) throws Exception{
	Method method = TestController.class.getMethod(methodName, parameterTypes);

	HandlerMethodArgumentResolverComposite argResolvers = new HandlerMethodArgumentResolverComposite();
	argResolvers.addResolver(new ModelMethodProcessor());

	InvocableHandlerMethod handlerMethod = new InvocableHandlerMethod(this.controller, method);
	handlerMethod.setHandlerMethodArgumentResolvers(argResolvers);
	handlerMethod.setDataBinderFactory(null);
	handlerMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());

	return new ModelFactory(Arrays.asList(handlerMethod), null, this.sessionAttrsHandler);
}
 
Example 6
Source File: ModelFactoryOrderingTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void runTest(Object controller) throws Exception {
	HandlerMethodArgumentResolverComposite resolvers = new HandlerMethodArgumentResolverComposite();
	resolvers.addResolver(new ModelAttributeMethodProcessor(false));
	resolvers.addResolver(new ModelMethodProcessor());
	WebDataBinderFactory dataBinderFactory = new DefaultDataBinderFactory(null);

	Class<?> type = controller.getClass();
	Set<Method> methods = MethodIntrospector.selectMethods(type, METHOD_FILTER);
	List<InvocableHandlerMethod> modelMethods = new ArrayList<InvocableHandlerMethod>();
	for (Method method : methods) {
		InvocableHandlerMethod modelMethod = new InvocableHandlerMethod(controller, method);
		modelMethod.setHandlerMethodArgumentResolvers(resolvers);
		modelMethod.setDataBinderFactory(dataBinderFactory);
		modelMethods.add(modelMethod);
	}
	Collections.shuffle(modelMethods);

	SessionAttributesHandler sessionHandler = new SessionAttributesHandler(type, this.sessionAttributeStore);
	ModelFactory factory = new ModelFactory(modelMethods, dataBinderFactory, sessionHandler);
	factory.initModel(this.webRequest, this.mavContainer, new HandlerMethod(controller, "handle"));
	if (logger.isDebugEnabled()) {
		StringBuilder sb = new StringBuilder();
		for (String name : getInvokedMethods()) {
			sb.append(" >> ").append(name);
		}
		logger.debug(sb);
	}
}
 
Example 7
Source File: NotificationHandlerMethodArgumentResolverConfigurationUtils.java    From spring-cloud-aws with Apache License 2.0 5 votes vote down vote up
public static HandlerMethodArgumentResolver getNotificationHandlerMethodArgumentResolver(
		AmazonSNS amazonSns) {
	HandlerMethodArgumentResolverComposite composite = new HandlerMethodArgumentResolverComposite();
	composite.addResolver(
			new NotificationStatusHandlerMethodArgumentResolver(amazonSns));
	composite.addResolver(new NotificationMessageHandlerMethodArgumentResolver());
	composite.addResolver(new NotificationSubjectHandlerMethodArgumentResolver());
	return composite;
}