@Override public void afterPropertiesSet() throws Exception { if (this.propertySources == null) { this.propertySources = deducePropertySources(); } if (this.conversionService == null) { this.conversionService = getOptionalBean( ConfigurableApplicationContext.CONVERSION_SERVICE_BEAN_NAME, ConfigurableConversionService.class); } // If no explicit conversion service is provided we add one so that (at least) // comma-separated arrays of convertibles can be bound automatically if (this.conversionService == null) { this.conversionService = getDefaultConversionService(); } this.propertyResolver = new PropertySourcesPropertyResolver(this.propertySources); this.propertyResolver.setConversionService(this.conversionService); }
/** * Initialize default ConversionService * * @return */ private ConfigurableConversionService getDefaultConversionService() { if (this.defaultConversionService == null) { DefaultConversionService conversionService = new DefaultConversionService(); this.applicationContext.getAutowireCapableBeanFactory().autowireBean(this); for (Converter<?, ?> converter : this.converters) { conversionService.addConverter(converter); } for (GenericConverter genericConverter : this.genericConverters) { conversionService.addConverter(genericConverter); } this.defaultConversionService = conversionService; } return this.defaultConversionService; }
public PlainTarantoolSerializer(Class<T> desiredClass, ConfigurableConversionService conversionService) { this.desiredClass = desiredClass; this.conversionService = conversionService; conversionService.addConverter(Date.class, Number.class, (Converter<Date, Number>) Date::getTime); conversionService.addConverter(Number.class, Date.class, (Converter<Number, Date>) it -> new Date(it.longValue())); }
@Bean @Autowired public ConfigurableConversionService conversionService(Converter[] converters) { final ConfigurableConversionService ours = new DefaultConversionService(); for (Converter converter : converters) { ours.addConverter(converter); } return ours; }
@Override protected void configureConversionService( ConfigurableConversionService conversionService) { conversionService.addConverter(stringToThreadIdConverter()); conversionService.addConverter(stringToReplyIdConverter()); super.configureConversionService(conversionService); }
public NumberConverterGenerator(Class<M> mutableType, Class<S> scalarType, ConfigurableConversionService conversionService) { super(); this.scalarType = Preconditions.checkNotNull(scalarType); this.mutableType = Preconditions.checkNotNull(mutableType); this.conversionService = Preconditions.checkNotNull(conversionService); }
@Override public ConfigurableConversionService getConversionService() { return this.propertyResolver.getConversionService(); }
@Override public void setConversionService(ConfigurableConversionService conversionService) { this.propertyResolver.setConversionService(conversionService); }
@Override public ConfigurableConversionService getConversionService() { return this.conversionService; }
@Override public void setConversionService(ConfigurableConversionService conversionService) { this.conversionService = conversionService; }
@Override public ConfigurableConversionService getConversionService() { return delegate.getConversionService(); }
@Override public void setConversionService(ConfigurableConversionService conversionService) { delegate.setConversionService(conversionService); }
public NotNullStringToCollectionConverter(ConversionService conversionService) { this.conversionService = (ConfigurableConversionService) conversionService; this.conversionService.addConverter(this); }
public void setConversionService(ConfigurableConversionService conversionService) { this.propertyResolver.setConversionService(conversionService); }
public ConfigurableConversionService getConversionService() { return this.propertyResolver.getConversionService(); }
public ConfigurableConversionService getConversionService() { return this.conversionService; }
public void setConversionService(ConfigurableConversionService conversionService) { this.conversionService = conversionService; }
@Bean public DomainClassConverter<?> domainClassConverter(ConfigurableConversionService conversionService) { return new DomainClassConverter<>(conversionService); }
public static ConfigurableConversionService createDefaultConversionService() { GenericConversionService conversionService = new GenericConversionService(); addDateConverters(conversionService); addWmConverters(conversionService); DefaultConversionService.addDefaultConverters(conversionService); return conversionService; }
/** * Set the conversion service used to convert property values. * * @param conversionService the conversion service */ public void setConversionService(ConfigurableConversionService conversionService) { this.conversionService = conversionService; }
private static void addWmConverters(ConfigurableConversionService conversionService) { addMScalars(conversionService); }
/** * @return the {@link ConfigurableConversionService} used when performing type * conversions on properties. * <p>The configurable nature of the returned conversion service allows for * the convenient addition and removal of individual {@code Converter} instances: * <pre class="code"> * ConfigurableConversionService cs = env.getConversionService(); * cs.addConverter(new FooConverter()); * </pre> * @see PropertyResolver#getProperty(String, Class) * @see org.springframework.core.convert.converter.ConverterRegistry#addConverter */ ConfigurableConversionService getConversionService();
/** * Set the {@link ConfigurableConversionService} to be used when performing type * conversions on properties. * <p><strong>Note:</strong> as an alternative to fully replacing the {@code * ConversionService}, consider adding or removing individual {@code Converter} * instances by drilling into {@link #getConversionService()} and calling methods * such as {@code #addConverter}. * @see PropertyResolver#getProperty(String, Class) * @see #getConversionService() * @see org.springframework.core.convert.converter.ConverterRegistry#addConverter */ void setConversionService(ConfigurableConversionService conversionService);