use of org.springframework.boot.convert.ApplicationConversionService in project spring-boot by spring-projects.
the class EndpointAutoConfiguration method createConversionService.
private ConversionService createConversionService(List<Converter<?, ?>> converters, List<GenericConverter> genericConverters) {
if (genericConverters.isEmpty() && converters.isEmpty()) {
return ApplicationConversionService.getSharedInstance();
}
ApplicationConversionService conversionService = new ApplicationConversionService();
converters.forEach(conversionService::addConverter);
genericConverters.forEach(conversionService::addConverter);
return conversionService;
}
use of org.springframework.boot.convert.ApplicationConversionService in project spring-boot by spring-projects.
the class SpringApplication method configureEnvironment.
/**
* Template method delegating to
* {@link #configurePropertySources(ConfigurableEnvironment, String[])} and
* {@link #configureProfiles(ConfigurableEnvironment, String[])} in that order.
* Override this method for complete control over Environment customization, or one of
* the above for fine-grained control over property sources or profiles, respectively.
* @param environment this application's environment
* @param args arguments passed to the {@code run} method
* @see #configureProfiles(ConfigurableEnvironment, String[])
* @see #configurePropertySources(ConfigurableEnvironment, String[])
*/
protected void configureEnvironment(ConfigurableEnvironment environment, String[] args) {
if (this.addConversionService) {
environment.setConversionService(new ApplicationConversionService());
}
configurePropertySources(environment, args);
configureProfiles(environment, args);
}
use of org.springframework.boot.convert.ApplicationConversionService in project spring-boot by spring-projects.
the class ConversionServiceDeducerTests method getConversionServiceWhenHasNoConversionServiceBeanAndNoQualifiedBeansAndBeanFactoryConversionServiceContainsOnlyBeanFactoryInstance.
@Test
void getConversionServiceWhenHasNoConversionServiceBeanAndNoQualifiedBeansAndBeanFactoryConversionServiceContainsOnlyBeanFactoryInstance() {
ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext(EmptyConfiguration.class);
ConversionService conversionService = new ApplicationConversionService();
applicationContext.getBeanFactory().setConversionService(conversionService);
ConversionServiceDeducer deducer = new ConversionServiceDeducer(applicationContext);
List<ConversionService> conversionServices = deducer.getConversionServices();
assertThat(conversionServices).containsOnly(conversionService);
assertThat(conversionServices.get(0)).isSameAs(conversionService);
}
use of org.springframework.boot.convert.ApplicationConversionService in project spring-boot by spring-projects.
the class ConversionServiceDeducer method getConversionServices.
private List<ConversionService> getConversionServices(ConfigurableApplicationContext applicationContext) {
List<ConversionService> conversionServices = new ArrayList<>();
if (applicationContext.getBeanFactory().getConversionService() != null) {
conversionServices.add(applicationContext.getBeanFactory().getConversionService());
}
ConverterBeans converterBeans = new ConverterBeans(applicationContext);
if (!converterBeans.isEmpty()) {
ApplicationConversionService beansConverterService = new ApplicationConversionService();
converterBeans.addTo(beansConverterService);
conversionServices.add(beansConverterService);
}
return conversionServices;
}
Aggregations