Java Code Examples for org.springframework.web.method.support.InvocableHandlerMethod#setDataBinderFactory()

The following examples show how to use org.springframework.web.method.support.InvocableHandlerMethod#setDataBinderFactory() . 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: 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 2
Source File: InitBinderDataBinderFactoryTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private WebDataBinderFactory createBinderFactory(String methodName, Class<?>... parameterTypes)
		throws Exception {

	Object handler = new InitBinderHandler();
	Method method = handler.getClass().getMethod(methodName, parameterTypes);

	InvocableHandlerMethod handlerMethod = new InvocableHandlerMethod(handler, method);
	handlerMethod.setHandlerMethodArgumentResolvers(argumentResolvers);
	handlerMethod.setDataBinderFactory(new DefaultDataBinderFactory(null));
	handlerMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());

	return new InitBinderDataBinderFactory(Arrays.asList(handlerMethod), bindingInitializer);
}
 
Example 3
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 4
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 5
Source File: RequestMappingHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private InvocableHandlerMethod createInitBinderMethod(Object bean, Method method) {
	InvocableHandlerMethod binderMethod = new InvocableHandlerMethod(bean, method);
	binderMethod.setHandlerMethodArgumentResolvers(this.initBinderArgumentResolvers);
	binderMethod.setDataBinderFactory(new DefaultDataBinderFactory(this.webBindingInitializer));
	binderMethod.setParameterNameDiscoverer(this.parameterNameDiscoverer);
	return binderMethod;
}
 
Example 6
Source File: RequestMappingHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private InvocableHandlerMethod createModelAttributeMethod(WebDataBinderFactory factory, Object bean, Method method) {
	InvocableHandlerMethod attrMethod = new InvocableHandlerMethod(bean, method);
	attrMethod.setHandlerMethodArgumentResolvers(this.argumentResolvers);
	attrMethod.setParameterNameDiscoverer(this.parameterNameDiscoverer);
	attrMethod.setDataBinderFactory(factory);
	return attrMethod;
}
 
Example 7
Source File: RequestMappingHandlerAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private InvocableHandlerMethod createInitBinderMethod(Object bean, Method method) {
	InvocableHandlerMethod binderMethod = new InvocableHandlerMethod(bean, method);
	binderMethod.setHandlerMethodArgumentResolvers(this.initBinderArgumentResolvers);
	binderMethod.setDataBinderFactory(new DefaultDataBinderFactory(this.webBindingInitializer));
	binderMethod.setParameterNameDiscoverer(this.parameterNameDiscoverer);
	return binderMethod;
}
 
Example 8
Source File: RequestMappingHandlerAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private InvocableHandlerMethod createModelAttributeMethod(WebDataBinderFactory factory, Object bean, Method method) {
	InvocableHandlerMethod attrMethod = new InvocableHandlerMethod(bean, method);
	attrMethod.setHandlerMethodArgumentResolvers(this.argumentResolvers);
	attrMethod.setParameterNameDiscoverer(this.parameterNameDiscoverer);
	attrMethod.setDataBinderFactory(factory);
	return attrMethod;
}
 
Example 9
Source File: InitBinderDataBinderFactoryTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private WebDataBinderFactory createFactory(String methodName, Class<?>... parameterTypes)
		throws Exception {

	Object handler = new InitBinderHandler();
	Method method = handler.getClass().getMethod(methodName, parameterTypes);

	InvocableHandlerMethod handlerMethod = new InvocableHandlerMethod(handler, method);
	handlerMethod.setHandlerMethodArgumentResolvers(this.argumentResolvers);
	handlerMethod.setDataBinderFactory(new DefaultDataBinderFactory(null));
	handlerMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());

	return new InitBinderDataBinderFactory(
			Collections.singletonList(handlerMethod), this.bindingInitializer);
}
 
Example 10
Source File: RequestMappingHandlerAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private InvocableHandlerMethod createModelAttributeMethod(WebDataBinderFactory factory, Object bean, Method method) {
	InvocableHandlerMethod attrMethod = new InvocableHandlerMethod(bean, method);
	if (this.argumentResolvers != null) {
		attrMethod.setHandlerMethodArgumentResolvers(this.argumentResolvers);
	}
	attrMethod.setParameterNameDiscoverer(this.parameterNameDiscoverer);
	attrMethod.setDataBinderFactory(factory);
	return attrMethod;
}
 
Example 11
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 12
Source File: RequestMappingHandlerAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
private InvocableHandlerMethod createInitBinderMethod(Object bean, Method method) {
	InvocableHandlerMethod binderMethod = new InvocableHandlerMethod(bean, method);
	if (this.initBinderArgumentResolvers != null) {
		binderMethod.setHandlerMethodArgumentResolvers(this.initBinderArgumentResolvers);
	}
	binderMethod.setDataBinderFactory(new DefaultDataBinderFactory(this.webBindingInitializer));
	binderMethod.setParameterNameDiscoverer(this.parameterNameDiscoverer);
	return binderMethod;
}
 
Example 13
Source File: RequestMappingHandlerAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
private InvocableHandlerMethod createModelAttributeMethod(WebDataBinderFactory factory, Object bean, Method method) {
	InvocableHandlerMethod attrMethod = new InvocableHandlerMethod(bean, method);
	if (this.argumentResolvers != null) {
		attrMethod.setHandlerMethodArgumentResolvers(this.argumentResolvers);
	}
	attrMethod.setParameterNameDiscoverer(this.parameterNameDiscoverer);
	attrMethod.setDataBinderFactory(factory);
	return attrMethod;
}
 
Example 14
Source File: InitBinderDataBinderFactoryTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private WebDataBinderFactory createFactory(String methodName, Class<?>... parameterTypes)
		throws Exception {

	Object handler = new InitBinderHandler();
	Method method = handler.getClass().getMethod(methodName, parameterTypes);

	InvocableHandlerMethod handlerMethod = new InvocableHandlerMethod(handler, method);
	handlerMethod.setHandlerMethodArgumentResolvers(this.argumentResolvers);
	handlerMethod.setDataBinderFactory(new DefaultDataBinderFactory(null));
	handlerMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());

	return new InitBinderDataBinderFactory(
			Collections.singletonList(handlerMethod), this.bindingInitializer);
}
 
Example 15
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 16
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 17
Source File: RequestMappingHandlerAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private InvocableHandlerMethod createInitBinderMethod(Object bean, Method method) {
	InvocableHandlerMethod binderMethod = new InvocableHandlerMethod(bean, method);
	if (this.initBinderArgumentResolvers != null) {
		binderMethod.setHandlerMethodArgumentResolvers(this.initBinderArgumentResolvers);
	}
	binderMethod.setDataBinderFactory(new DefaultDataBinderFactory(this.webBindingInitializer));
	binderMethod.setParameterNameDiscoverer(this.parameterNameDiscoverer);
	return binderMethod;
}