Examples of GenericConversionService


Examples of org.springframework.core.convert.support.GenericConversionService

        if(autowireCapableBeanFactory instanceof ConfigurableListableBeanFactory) {
            ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory)autowireCapableBeanFactory;
            ConversionService existingConversionService = beanFactory.getConversionService();
            ConverterRegistry converterRegistry;
            if(existingConversionService == null) {
                GenericConversionService conversionService = new GenericConversionService();
                converterRegistry = conversionService;
                beanFactory.setConversionService(conversionService);
            }
            else {
                converterRegistry = (ConverterRegistry)existingConversionService;
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

{

    @Override
    public ConversionService getObject() throws Exception
    {
        GenericConversionService conversionService = new GenericConversionService();
        addConverters(conversionService);
        ConversionServiceFactory.addDefaultConverters( conversionService );
        return conversionService;
    }
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

  @Configuration
  public static class Config {

    @Bean
    public ConversionService webSocketConversionService() {
      GenericConversionService conversionService = new DefaultConversionService();
      conversionService.addConverter(new MyTypeToStringConverter());
      conversionService.addConverter(new MyTypeToBytesConverter());
      conversionService.addConverter(new StringToMyTypeConverter());
      conversionService.addConverter(new BytesToMyTypeConverter());
      return conversionService;
    }
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

  @Configuration
  public static class NoConvertersConfig {

    @Bean
    public ConversionService webSocketConversionService() {
      return new GenericConversionService();
    }
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

  @Test
  public void prototypeCreationReevaluatesExpressions() {
    GenericApplicationContext ac = new GenericApplicationContext();
    AnnotationConfigUtils.registerAnnotationConfigProcessors(ac);
    GenericConversionService cs = new GenericConversionService();
    cs.addConverter(String.class, String.class, new Converter<String, String>() {
      @Override
      public String convert(String source) {
        return source.trim();
      }
    });
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

  @Test
  public void testNullNestedTypeDescriptorWithBadConversionService() {
    Foo foo = new Foo();
    BeanWrapperImpl wrapper = new BeanWrapperImpl(foo);
    wrapper.setConversionService(new GenericConversionService() {
      @Override
      public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
        throw new ConversionFailedException(sourceType, targetType, source, null);
      }
    });
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

  Spr7839Controller controller = new Spr7839Controller();

  @Before
  public void setUp() {
    ConfigurableWebBindingInitializer binder = new ConfigurableWebBindingInitializer();
    GenericConversionService service = new DefaultConversionService();
    service.addConverter(new Converter<String, NestedBean>() {
      @Override
      public NestedBean convert(String source) {
        return new NestedBean(source);
      }
    });
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

  }

  @Test
  public void testCustomConverter() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    GenericConversionService conversionService = new DefaultConversionService();
    conversionService.addConverter(new Converter<String, Float>() {
      @Override
      public Float convert(String source) {
        try {
          NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
          return nf.parse(source).floatValue();
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

    evaluateAndCheckError("null and true", SpelMessage.TYPE_CONVERSION_ERROR, 0, "null", "boolean");
    evaluateAndCheckError("!null", SpelMessage.TYPE_CONVERSION_ERROR, 1, "null", "boolean");
    evaluateAndCheckError("null ? 'foo' : 'bar'", SpelMessage.TYPE_CONVERSION_ERROR, 0, "null", "boolean");

    // with null conversion (null -> false)
    GenericConversionService conversionService = new GenericConversionService() {
      @Override
      protected Object convertNullSource(TypeDescriptor sourceType, TypeDescriptor targetType) {
        return targetType.getType() == Boolean.class ? false : null;
      }
    };
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

  @Test
  @Deprecated
  public void test() throws Exception {
    AnnotationMethodHandlerAdapter adapter = new AnnotationMethodHandlerAdapter();
    ConfigurableWebBindingInitializer binder = new ConfigurableWebBindingInitializer();
    GenericConversionService service = new DefaultConversionService();
    service.addConverter(new ColorConverter());
    binder.setConversionService(service);
    adapter.setWebBindingInitializer(binder);
    Spr7766Controller controller = new Spr7766Controller();
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/colors");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.