use of cn.taketoday.web.bind.resolver.ModelMethodProcessor in project today-framework by TAKETODAY.
the class ModelFactoryTests method createModelFactory.
private ModelFactory createModelFactory(String methodName, Class<?>... parameterTypes) throws Throwable {
InvocableHandlerMethod modelMethod = createHandlerMethod(methodName, parameterTypes);
ParameterResolvingRegistry registry = new ParameterResolvingRegistry();
registry.getCustomizedStrategies().add(new ModelMethodProcessor());
modelMethod.setResolvingRegistry(registry);
return new ModelFactory(Collections.singletonList(modelMethod), null, this.attributeHandler);
}
use of cn.taketoday.web.bind.resolver.ModelMethodProcessor in project today-framework by TAKETODAY.
the class ModelFactoryOrderingTests method runTest.
private void runTest(Object controller) throws Throwable {
ParameterResolvingRegistry resolvers = new ParameterResolvingRegistry();
resolvers.addStrategies(new ModelAttributeMethodProcessor(false));
resolvers.addStrategies(new ModelMethodProcessor());
BindingContext dataBinderFactory = new BindingContext(null);
Class<?> type = controller.getClass();
Set<Method> methods = MethodIntrospector.filterMethods(type, METHOD_FILTER);
List<InvocableHandlerMethod> modelMethods = new ArrayList<>();
for (Method method : methods) {
InvocableHandlerMethod modelMethod = new InvocableHandlerMethod(controller, method);
modelMethod.setResolvingRegistry(resolvers);
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()) {
logger.debug(String.join(" >> ", getInvokedMethods()));
}
}
Aggregations