use of cn.taketoday.web.bind.resolver.ParameterResolvingRegistry in project today-infrastructure by TAKETODAY.
the class AnnotationHandlerFactory method initDefaults.
public void initDefaults() {
ParameterResolvingRegistry registry = beanFactory.getBean(ParameterResolvingRegistry.class);
Assert.state(registry != null, "No ParameterResolvingRegistry");
setReturnValueHandlerManager(beanFactory.getBean(ReturnValueHandlerManager.class));
setParameterFactory(new ParameterResolvingRegistryResolvableParameterFactory(registry));
}
use of cn.taketoday.web.bind.resolver.ParameterResolvingRegistry in project today-infrastructure by TAKETODAY.
the class RequestMappingHandlerAdapter method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
// Do this first, it may add ResponseBody advice beans
initControllerAdviceCache();
if (resolvingRegistry == null) {
this.resolvingRegistry = new ParameterResolvingRegistry();
resolvingRegistry.setApplicationContext(getApplicationContext());
resolvingRegistry.registerDefaultStrategies();
}
// prepare returnValueHandlerManager
setReturnValueHandlerManager(returnValueHandlerManager);
}
use of cn.taketoday.web.bind.resolver.ParameterResolvingRegistry in project today-framework by TAKETODAY.
the class HandlerMethodTests method testSimple.
@Test
public void testSimple() throws Throwable {
final Method method = HandlerMethodTests.class.getDeclaredMethod("method", String.class);
final HandlerMethod handlerMethod = HandlerMethod.from(method);
DefaultParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
handlerMethod.initParameterNameDiscovery(parameterNameDiscoverer);
assertThat(handlerMethod.getMethod()).isEqualTo(method);
assertThat(handlerMethod.getParameters()).hasSize(1);
assertThat(handlerMethod.getReturnType()).isEqualTo(method.getReturnType()).isEqualTo(void.class);
assertThat(handlerMethod.getContentType()).isNull();
// produce
final Method produce = HandlerMethodTests.class.getDeclaredMethod("produce", String.class);
final HandlerMethod produceMethod = HandlerMethod.from(produce);
assertThat(produceMethod.getContentType()).isEqualTo(MediaType.APPLICATION_JSON_VALUE);
produceMethod.initParameterNameDiscovery(parameterNameDiscoverer);
ApplicationContext applicationContext = getApplicationContext();
final ParameterResolvingRegistryResolvableParameterFactory methodParameterBuilder = new ParameterResolvingRegistryResolvableParameterFactory();
final ParameterResolvingRegistry resolversRegistry = methodParameterBuilder.getResolvingRegistry();
resolversRegistry.setApplicationContext(applicationContext);
resolversRegistry.registerDefaultStrategies();
setResultHandlers(produceMethod, applicationContext);
assertThat(produceMethod).isNotEqualTo(handlerMethod);
assertThat(produceMethod).hasToString("HandlerMethodTests#produce(String name)");
}
use of cn.taketoday.web.bind.resolver.ParameterResolvingRegistry in project today-framework by TAKETODAY.
the class ParameterResolvingRegistryTests method parameterResolvingRegistry.
@Test
void parameterResolvingRegistry() {
assertThat(registry.getMessageConverters()).hasSize(3);
ParameterResolvingRegistry registry1 = new ParameterResolvingRegistry(registry.getMessageConverters());
assertThat(registry1.getMessageConverters()).isNotEmpty().hasSize(3);
assertThat(registry1).isNotEqualTo(registry);
registry.setMessageConverters(List.of(new StringHttpMessageConverter(StandardCharsets.US_ASCII)));
assertThat(registry.getMessageConverters()).isNotEmpty().hasSize(1);
assertThat(registry.toString()).isNotEmpty();
registry.hashCode();
}
use of cn.taketoday.web.bind.resolver.ParameterResolvingRegistry in project today-framework by TAKETODAY.
the class ValidationParameterResolver method obtainResolvers.
private ParameterResolvingRegistry obtainResolvers() {
final ParameterResolvingRegistry ret = getResolvingRegistry();
Assert.state(ret != null, "No ParameterResolvingRegistry.");
return ret;
}
Aggregations