Example usage for org.springframework.format.support DefaultFormattingConversionService DefaultFormattingConversionService

List of usage examples for org.springframework.format.support DefaultFormattingConversionService DefaultFormattingConversionService

Introduction

In this page you can find the example usage for org.springframework.format.support DefaultFormattingConversionService DefaultFormattingConversionService.

Prototype

public DefaultFormattingConversionService() 

Source Link

Document

Create a new DefaultFormattingConversionService with the set of DefaultConversionService#addDefaultConverters default converters and #addDefaultFormatters default formatters .

Usage

From source file:org.jdal.beans.SpringConverter.java

public SpringConverter() {
    converter.setConversionService(new DefaultFormattingConversionService());
}

From source file:com.luna.common.entity.search.SearchableTest.java

@Before
public void setUp() {
    try {//w  w w  . j  a  v  a 2  s  .c  om
        oldConversionService = SearchableConvertUtils.getConversionService();
    } catch (Exception e) {
        //ignore null case
    }
    SearchableConvertUtils.setConversionService(new DefaultFormattingConversionService());
}

From source file:ch.rasc.wampspring.method.MethodParameterConverterTest.java

@Before
public void setup() throws Exception {
    this.converter = new MethodParameterConverter(new ObjectMapper(), new DefaultFormattingConversionService());
}

From source file:com.logsniffer.app.ConfigValueAppConfig.java

@Bean
public ConversionService conversionService() {
    return new DefaultFormattingConversionService();
}

From source file:uk.co.blackpepper.support.retrofit.jsoup.spring.AbstractBeanHtmlConverter.java

public AbstractBeanHtmlConverter() {
    fromBodyFunctionsByPropertyName = new HashMap<>();
    toBodyNamesByPropertyName = new HashMap<>();
    conversionService = new DefaultFormattingConversionService();
}

From source file:br.com.alura.casadocodigo.conf.AppWebConfiguration.java

@Bean
public FormattingConversionService mvcConversionService() {
    DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
    DateFormatterRegistrar dateFormatterRegistrar = new DateFormatterRegistrar();
    dateFormatterRegistrar.setFormatter(new DateFormatter("dd/MM/yyyy"));
    dateFormatterRegistrar.registerFormatters(conversionService);

    return conversionService;
}

From source file:ch.rasc.wampspring.method.WampAnnotationMethodMessageHandlerTest.java

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    when(this.clientOutboundChannel.send(any(WampMessage.class))).thenReturn(true);

    DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
    MethodParameterConverter paramConverter = new MethodParameterConverter(new ObjectMapper(),
            conversionService);/*from   ww  w  .jav  a2 s .  co  m*/
    this.messageHandler = new WampAnnotationMethodMessageHandler(this.clientInboundChannel,
            this.clientOutboundChannel, this.eventMessenger, conversionService, paramConverter,
            new AntPathMatcher(), WampMessageSelectors.ACCEPT_ALL);

    @SuppressWarnings("resource")
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.registerPrototype("annotatedTestService", AnnotatedTestService.class);
    applicationContext.refresh();
    this.messageHandler.setApplicationContext(applicationContext);
    this.messageHandler.afterPropertiesSet();

    this.messageHandler.start();
}

From source file:ch.ralscha.extdirectspring.controller.ConfigurationService.java

@Override
public void afterPropertiesSet() {

    if (configuration == null) {
        configuration = new Configuration();
    }//  w w  w.ja v a  2  s  .c om

    if (configuration.getJsonHandler() != null) {
        jsonHandler = configuration.getJsonHandler();
    }

    if (jsonHandler == null) {
        jsonHandler = new JsonHandler();
    }

    if (routerExceptionHandler == null) {
        routerExceptionHandler = new DefaultRouterExceptionHandler(this);
    }

    if (configuration.getBatchedMethodsExecutionPolicy() == BatchedMethodsExecutionPolicy.CONCURRENT
            && configuration.getBatchedMethodsExecutorService() == null) {
        configuration.setBatchedMethodsExecutorService(Executors.newFixedThreadPool(5));
    }

    if (configuration.getConversionService() == null) {
        Map<String, ConversionService> conversionServices = context.getBeansOfType(ConversionService.class);
        if (conversionServices.isEmpty()) {
            configuration.setConversionService(new DefaultFormattingConversionService());
        } else if (conversionServices.size() == 1) {
            configuration.setConversionService(conversionServices.values().iterator().next());
        } else {
            if (conversionServices.containsKey("mvcConversionService")) {
                configuration.setConversionService(conversionServices.get("mvcConversionService"));
            } else {
                for (ConversionService conversionService : conversionServices.values()) {
                    if (conversionService instanceof FormattingConversionService) {
                        configuration.setConversionService(conversionService);
                        break;
                    }
                }
                if (configuration.getConversionService() == null) {
                    configuration.setConversionService(conversionServices.values().iterator().next());
                }
            }
        }
    }

    Collection<WebArgumentResolver> webResolvers = context.getBeansOfType(WebArgumentResolver.class).values();
    parametersResolver = new ParametersResolver(configuration.getConversionService(), jsonHandler,
            webResolvers);
}

From source file:spring.boot.hateoas.sample.SampleHdivApplication.java

@Bean
public ConversionService defaultConversionService() {
    return new DefaultFormattingConversionService();
}

From source file:de.escalon.hypermedia.action.ActionInputParameter.java

/**
 * Creates new ActionInputParameter with default formatting conversion service.
 *
 * @param methodParameter holding metadata about the parameter
 * @param value           during sample method invocation
 *//*from  w w  w.  j  a v a 2 s  . c  o m*/
public ActionInputParameter(MethodParameter methodParameter, Object value) {
    this(methodParameter, value, new DefaultFormattingConversionService());
}