Search in sources :

Example 1 with HandlerMethodArgumentResolverComposite

use of org.springframework.web.method.support.HandlerMethodArgumentResolverComposite in project spring-framework by spring-projects.

the class ExceptionHandlerExceptionResolver method setArgumentResolvers.

/**
	 * Configure the complete list of supported argument types thus overriding
	 * the resolvers that would otherwise be configured by default.
	 */
public void setArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
    if (argumentResolvers == null) {
        this.argumentResolvers = null;
    } else {
        this.argumentResolvers = new HandlerMethodArgumentResolverComposite();
        this.argumentResolvers.addResolvers(argumentResolvers);
    }
}
Also used : HandlerMethodArgumentResolverComposite(org.springframework.web.method.support.HandlerMethodArgumentResolverComposite)

Example 2 with HandlerMethodArgumentResolverComposite

use of org.springframework.web.method.support.HandlerMethodArgumentResolverComposite in project spring-framework by spring-projects.

the class RequestMappingHandlerAdapter method setArgumentResolvers.

/**
	 * Configure the complete list of supported argument types thus overriding
	 * the resolvers that would otherwise be configured by default.
	 */
public void setArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
    if (argumentResolvers == null) {
        this.argumentResolvers = null;
    } else {
        this.argumentResolvers = new HandlerMethodArgumentResolverComposite();
        this.argumentResolvers.addResolvers(argumentResolvers);
    }
}
Also used : HandlerMethodArgumentResolverComposite(org.springframework.web.method.support.HandlerMethodArgumentResolverComposite)

Example 3 with HandlerMethodArgumentResolverComposite

use of org.springframework.web.method.support.HandlerMethodArgumentResolverComposite in project spring-framework by spring-projects.

the class RequestMappingHandlerAdapter method setInitBinderArgumentResolvers.

/**
	 * Configure the supported argument types in {@code @InitBinder} methods.
	 */
public void setInitBinderArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
    if (argumentResolvers == null) {
        this.initBinderArgumentResolvers = null;
    } else {
        this.initBinderArgumentResolvers = new HandlerMethodArgumentResolverComposite();
        this.initBinderArgumentResolvers.addResolvers(argumentResolvers);
    }
}
Also used : HandlerMethodArgumentResolverComposite(org.springframework.web.method.support.HandlerMethodArgumentResolverComposite)

Example 4 with HandlerMethodArgumentResolverComposite

use of org.springframework.web.method.support.HandlerMethodArgumentResolverComposite in project spring-framework by spring-projects.

the class ModelFactoryOrderingTests method runTest.

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);
    }
}
Also used : InvocableHandlerMethod(org.springframework.web.method.support.InvocableHandlerMethod) ArrayList(java.util.ArrayList) InvocableHandlerMethod(org.springframework.web.method.support.InvocableHandlerMethod) HandlerMethod(org.springframework.web.method.HandlerMethod) Method(java.lang.reflect.Method) HandlerMethodArgumentResolverComposite(org.springframework.web.method.support.HandlerMethodArgumentResolverComposite) InvocableHandlerMethod(org.springframework.web.method.support.InvocableHandlerMethod) HandlerMethod(org.springframework.web.method.HandlerMethod) WebDataBinderFactory(org.springframework.web.bind.support.WebDataBinderFactory) DefaultDataBinderFactory(org.springframework.web.bind.support.DefaultDataBinderFactory)

Example 5 with HandlerMethodArgumentResolverComposite

use of org.springframework.web.method.support.HandlerMethodArgumentResolverComposite in project spring-framework by spring-projects.

the class ModelFactoryTests method createModelFactory.

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);
}
Also used : LocalVariableTableParameterNameDiscoverer(org.springframework.core.LocalVariableTableParameterNameDiscoverer) InvocableHandlerMethod(org.springframework.web.method.support.InvocableHandlerMethod) HandlerMethodArgumentResolverComposite(org.springframework.web.method.support.HandlerMethodArgumentResolverComposite)

Aggregations

HandlerMethodArgumentResolverComposite (org.springframework.web.method.support.HandlerMethodArgumentResolverComposite)5 InvocableHandlerMethod (org.springframework.web.method.support.InvocableHandlerMethod)2 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 LocalVariableTableParameterNameDiscoverer (org.springframework.core.LocalVariableTableParameterNameDiscoverer)1 DefaultDataBinderFactory (org.springframework.web.bind.support.DefaultDataBinderFactory)1 WebDataBinderFactory (org.springframework.web.bind.support.WebDataBinderFactory)1 HandlerMethod (org.springframework.web.method.HandlerMethod)1