Search in sources :

Example 6 with DefaultFormattingConversionService

use of org.springframework.format.support.DefaultFormattingConversionService in project spring-framework by spring-projects.

the class RequestHeaderMethodArgumentResolverTests method setup.

@Before
public void setup() throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.refresh();
    ReactiveAdapterRegistry adapterRegistry = new ReactiveAdapterRegistry();
    this.resolver = new RequestHeaderMethodArgumentResolver(context.getBeanFactory(), adapterRegistry);
    ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
    initializer.setConversionService(new DefaultFormattingConversionService());
    this.bindingContext = new BindingContext(initializer);
    Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
    this.paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 0);
    this.paramNamedValueStringArray = new SynthesizingMethodParameter(method, 1);
    this.paramSystemProperty = new SynthesizingMethodParameter(method, 2);
    this.paramResolvedNameWithExpression = new SynthesizingMethodParameter(method, 3);
    this.paramResolvedNameWithPlaceholder = new SynthesizingMethodParameter(method, 4);
    this.paramNamedValueMap = new SynthesizingMethodParameter(method, 5);
    this.paramDate = new SynthesizingMethodParameter(method, 6);
    this.paramInstant = new SynthesizingMethodParameter(method, 7);
    this.paramMono = new SynthesizingMethodParameter(method, 8);
}
Also used : SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ConfigurableWebBindingInitializer(org.springframework.web.bind.support.ConfigurableWebBindingInitializer) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) Method(java.lang.reflect.Method) BindingContext(org.springframework.web.reactive.BindingContext) DefaultFormattingConversionService(org.springframework.format.support.DefaultFormattingConversionService) Before(org.junit.Before)

Example 7 with DefaultFormattingConversionService

use of org.springframework.format.support.DefaultFormattingConversionService in project spring-framework by spring-projects.

the class WebMvcConfigurationSupport method mvcConversionService.

/**
	 * Return a {@link FormattingConversionService} for use with annotated
	 * controller methods and the {@code spring:eval} JSP tag.
	 * Also see {@link #addFormatters} as an alternative to overriding this method.
	 */
@Bean
public FormattingConversionService mvcConversionService() {
    FormattingConversionService conversionService = new DefaultFormattingConversionService();
    addFormatters(conversionService);
    return conversionService;
}
Also used : FormattingConversionService(org.springframework.format.support.FormattingConversionService) DefaultFormattingConversionService(org.springframework.format.support.DefaultFormattingConversionService) DefaultFormattingConversionService(org.springframework.format.support.DefaultFormattingConversionService) Bean(org.springframework.context.annotation.Bean)

Example 8 with DefaultFormattingConversionService

use of org.springframework.format.support.DefaultFormattingConversionService in project cas by apereo.

the class EnvironmentConversionServiceInitializer method initialize.

@Override
public void initialize(final ConfigurableApplicationContext applicationContext) {
    final DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(true);
    applicationContext.getEnvironment().setConversionService(conversionService);
}
Also used : DefaultFormattingConversionService(org.springframework.format.support.DefaultFormattingConversionService)

Example 9 with DefaultFormattingConversionService

use of org.springframework.format.support.DefaultFormattingConversionService in project cas by apereo.

the class CasCoreUtilConfiguration method init.

@PostConstruct
public void init() {
    final ConfigurableApplicationContext applicationContext = applicationContextProvider().getConfigurableApplicationContext();
    final DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(true);
    applicationContext.getEnvironment().setConversionService(conversionService);
    final ScheduledAnnotationBeanPostProcessor p = applicationContext.getBean(ScheduledAnnotationBeanPostProcessor.class);
    p.setEmbeddedValueResolver(new CasConfigurationEmbeddedValueResolver(applicationContext));
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ScheduledAnnotationBeanPostProcessor(org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor) CasConfigurationEmbeddedValueResolver(org.apereo.cas.config.support.CasConfigurationEmbeddedValueResolver) DefaultFormattingConversionService(org.springframework.format.support.DefaultFormattingConversionService) PostConstruct(javax.annotation.PostConstruct)

Example 10 with DefaultFormattingConversionService

use of org.springframework.format.support.DefaultFormattingConversionService in project spring-framework by spring-projects.

the class InitBinderBindingContextTests method createBinderWithGlobalInitialization.

@Test
public void createBinderWithGlobalInitialization() throws Exception {
    ConversionService conversionService = new DefaultFormattingConversionService();
    bindingInitializer.setConversionService(conversionService);
    ServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange();
    BindingContext context = createBindingContext("initBinder", WebDataBinder.class);
    WebDataBinder dataBinder = context.createDataBinder(exchange, null, null);
    assertSame(conversionService, dataBinder.getConversionService());
}
Also used : ServerWebExchange(org.springframework.web.server.ServerWebExchange) WebDataBinder(org.springframework.web.bind.WebDataBinder) DefaultFormattingConversionService(org.springframework.format.support.DefaultFormattingConversionService) ConversionService(org.springframework.core.convert.ConversionService) BindingContext(org.springframework.web.reactive.BindingContext) DefaultFormattingConversionService(org.springframework.format.support.DefaultFormattingConversionService) Test(org.junit.Test)

Aggregations

DefaultFormattingConversionService (org.springframework.format.support.DefaultFormattingConversionService)16 Test (org.junit.Test)8 ConfigurableWebBindingInitializer (org.springframework.web.bind.support.ConfigurableWebBindingInitializer)7 BindingContext (org.springframework.web.reactive.BindingContext)6 Before (org.junit.Before)4 SynthesizingMethodParameter (org.springframework.core.annotation.SynthesizingMethodParameter)3 FormattingConversionService (org.springframework.format.support.FormattingConversionService)3 Optional (java.util.Optional)2 Bean (org.springframework.context.annotation.Bean)2 MethodParameter (org.springframework.core.MethodParameter)2 ReactiveAdapterRegistry (org.springframework.core.ReactiveAdapterRegistry)2 ConversionService (org.springframework.core.convert.ConversionService)2 WebDataBinder (org.springframework.web.bind.WebDataBinder)2 DefaultDataBinderFactory (org.springframework.web.bind.support.DefaultDataBinderFactory)2 Method (java.lang.reflect.Method)1 Instant (java.time.Instant)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 PostConstruct (javax.annotation.PostConstruct)1 CasConfigurationEmbeddedValueResolver (org.apereo.cas.config.support.CasConfigurationEmbeddedValueResolver)1