use of org.springframework.core.env.Environment 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();
}
use of org.springframework.core.env.Environment in project nakadi by zalando.
the class HashPartitionStrategyCrutchTest method whenPartitionCountIsWrongThenIllegalArgumentException.
@Test(expected = IllegalArgumentException.class)
public void whenPartitionCountIsWrongThenIllegalArgumentException() {
final Environment env = mock(Environment.class);
when(env.getProperty("nakadi.hashPartitioning.overrideOrder.p3", List.class)).thenReturn(ImmutableList.of("1", "2", "0", "3"));
new HashPartitionStrategyCrutch(env, 4);
}
use of org.springframework.core.env.Environment in project kylo by Teradata.
the class InspectorApp method main.
/**
* Main method, used to run the application.
*
* @param args the command line arguments
* @throws UnknownHostException if the local host name could not be resolved into an address
*/
public static void main(String[] args) throws UnknownHostException {
SpringApplication app = new SpringApplication(InspectorApp.class);
DefaultProfileUtil.addDefaultProfile(app);
Environment env = app.run(args).getEnvironment();
String protocol = "http";
if (env.getProperty("server.ssl.key-store") != null) {
protocol = "https";
}
log.info("\n----------------------------------------------------------\n\t" + "Application '{}' is running! Access URLs:\n\t" + "Local: \t\t{}://localhost:{}\n\t" + "External: \t{}://{}:{}\n\t" + "Profile(s): \t{}\n----------------------------------------------------------", env.getProperty("spring.application.name"), protocol, env.getProperty("server.port"), protocol, InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"), env.getActiveProfiles());
}
use of org.springframework.core.env.Environment in project cas by apereo.
the class CasConfigurationPropertiesEnvironmentManager method getStandaloneProfileConfigurationDirectory.
/**
* Gets standalone profile configuration directory.
*
* @param environment the environment
* @return the standalone profile configuration directory
*/
public File getStandaloneProfileConfigurationDirectory(final Environment environment) {
val values = new LinkedHashSet<>(RelaxedPropertyNames.forCamelCase(PROPERTY_CAS_STANDALONE_CONFIGURATION_DIRECTORY).getValues());
values.add(PROPERTY_CAS_STANDALONE_CONFIGURATION_DIRECTORY);
val file = values.stream().map(key -> environment.getProperty(key, File.class)).filter(Objects::nonNull).findFirst().orElse(null);
if (file != null && file.exists()) {
LOGGER.trace("Received standalone configuration directory [{}]", file);
return file;
}
return Arrays.stream(DEFAULT_CAS_CONFIG_DIRECTORIES).filter(File::exists).findFirst().orElse(null);
}
use of org.springframework.core.env.Environment in project dubbo by alibaba.
the class DubboBeanDefinitionParser method resolveAttribute.
private static String resolveAttribute(Element element, String attributeName, ParserContext parserContext) {
String attributeValue = element.getAttribute(attributeName);
Environment environment = parserContext.getReaderContext().getEnvironment();
return environment.resolvePlaceholders(attributeValue);
}
Aggregations