use of org.finra.herd.dao.ReloadablePropertySource 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