org.springframework.boot.convert.ApplicationConversionService Java Examples

The following examples show how to use org.springframework.boot.convert.ApplicationConversionService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JasyptEncryptorConfigurationProperties.java    From jasypt-spring-boot with MIT License 6 votes vote down vote up
public static JasyptEncryptorConfigurationProperties bindConfigProps(ConfigurableEnvironment environment) {
    final BindHandler handler = new IgnoreErrorsBindHandler(BindHandler.DEFAULT);
    final MutablePropertySources propertySources = environment.getPropertySources();
    final Binder binder = new Binder(ConfigurationPropertySources.from(propertySources),
            new PropertySourcesPlaceholdersResolver(propertySources),
            ApplicationConversionService.getSharedInstance());
    final JasyptEncryptorConfigurationProperties config = new JasyptEncryptorConfigurationProperties();

    final ResolvableType type = ResolvableType.forClass(JasyptEncryptorConfigurationProperties.class);
    final Annotation annotation = AnnotationUtils.findAnnotation(JasyptEncryptorConfigurationProperties.class,
            ConfigurationProperties.class);
    final Annotation[] annotations = new Annotation[]{annotation};
    final Bindable<?> target = Bindable.of(type).withExistingValue(config).withAnnotations(annotations);

    binder.bind("jasypt.encryptor", target, handler);
    return config;
}
 
Example #2
Source File: BetweenRoutePredicateFactoryTests.java    From spring-cloud-gateway with Apache License 2.0 5 votes vote down vote up
static <T> T bindConfig(HashMap<String, Object> properties,
		AbstractRoutePredicateFactory<T> factory) {
	ApplicationConversionService conversionService = new ApplicationConversionService();
	conversionService.addConverter(new StringToZonedDateTimeConverter());
	// @formatter:off
	T config = new ConfigurationService(null, () -> conversionService, () -> null)
			.with(factory)
			.name("myname")
			.normalizedProperties(properties)
			.bind();
	// @formatter:on
	return config;
}
 
Example #3
Source File: WebMvcConfiguration.java    From springdoc-openapi with Apache License 2.0 4 votes vote down vote up
@Override
public void addFormatters(FormatterRegistry registry) {
	ApplicationConversionService.configure(registry);
}