use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project spring-boot by spring-projects.
the class ConfigurationPropertiesBindingPostProcessor method getSinglePropertySourcesPlaceholderConfigurer.
private PropertySourcesPlaceholderConfigurer getSinglePropertySourcesPlaceholderConfigurer() {
// Take care not to cause early instantiation of all FactoryBeans
if (this.beanFactory instanceof ListableBeanFactory) {
ListableBeanFactory listableBeanFactory = (ListableBeanFactory) this.beanFactory;
Map<String, PropertySourcesPlaceholderConfigurer> beans = listableBeanFactory.getBeansOfType(PropertySourcesPlaceholderConfigurer.class, false, false);
if (beans.size() == 1) {
return beans.values().iterator().next();
}
if (beans.size() > 1 && logger.isWarnEnabled()) {
logger.warn("Multiple PropertySourcesPlaceholderConfigurer " + "beans registered " + beans.keySet() + ", falling back to Environment");
}
}
return null;
}
use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project waltz by khartec.
the class DIConfiguration method propertySourcesPlaceholderConfigurer.
/* Required for property interpolation to work correctly */
/**
* @see <a href="http://stackoverflow.com/a/41760877/2311919">Explanation</a>
*/
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(ConfigurableEnvironment env) {
PropertySourcesPlaceholderConfigurer placeholderConfigurer = new PropertySourcesPlaceholderConfigurer();
JndiPropertySource jndiPropertySource = new JndiPropertySource("java:comp");
env.getPropertySources().addFirst(jndiPropertySource);
return placeholderConfigurer;
}
use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project molgenis by molgenis.
the class PlatformITConfig method properties.
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
Resource[] resources = new Resource[] { new ClassPathResource("/conf/molgenis.properties") };
pspc.setLocations(resources);
pspc.setFileEncoding("UTF-8");
pspc.setIgnoreUnresolvablePlaceholders(true);
pspc.setIgnoreResourceNotFound(true);
pspc.setNullValue("@null");
return pspc;
}
use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project molgenis by molgenis.
the class MolgenisWebAppConfig method properties.
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
Resource[] resources = new Resource[] { new FileSystemResource(System.getProperty(MOLGENIS_HOME) + "/molgenis-server.properties"), new ClassPathResource("/molgenis.properties") };
pspc.setLocations(resources);
pspc.setFileEncoding("UTF-8");
pspc.setIgnoreUnresolvablePlaceholders(true);
pspc.setIgnoreResourceNotFound(true);
pspc.setNullValue("@null");
return pspc;
}
use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project herd by FINRAOS.
the class DaoSpringModuleConfig method databasePropertySourcesPlaceholderConfigurer.
/**
* The database supplied property sources placeholder configurer that allows access to externalized properties from a database. This method also adds a new
* property source that contains the database properties to the environment.
*
* @return the property sources placeholder configurer.
*/
@Bean
public static PropertySourcesPlaceholderConfigurer databasePropertySourcesPlaceholderConfigurer() {
// Get the configurable environment and add a new property source to it that contains the database properties.
// That way, the properties can be accessed via the environment or via an injected @Value annotation.
// We are adding this property source last so other property sources (e.g. system properties, environment variables) can be used
// to override the database properties.
Environment environment = ApplicationContextHolder.getApplicationContext().getEnvironment();
if (environment instanceof ConfigurableEnvironment) {
ConfigurableEnvironment configurableEnvironment = (ConfigurableEnvironment) environment;
ReloadablePropertySource reloadablePropertySource = new ReloadablePropertySource(ReloadablePropertySource.class.getName(), ConfigurationConverter.getProperties(getPropertyDatabaseConfiguration()), getPropertyDatabaseConfiguration());
configurableEnvironment.getPropertySources().addLast(reloadablePropertySource);
}
return new PropertySourcesPlaceholderConfigurer();
}
Aggregations