Example usage for org.springframework.core.env SystemEnvironmentPropertySource SystemEnvironmentPropertySource

List of usage examples for org.springframework.core.env SystemEnvironmentPropertySource SystemEnvironmentPropertySource

Introduction

In this page you can find the example usage for org.springframework.core.env SystemEnvironmentPropertySource SystemEnvironmentPropertySource.

Prototype

public SystemEnvironmentPropertySource(String name, Map<String, Object> source) 

Source Link

Document

Create a new SystemEnvironmentPropertySource with the given name and delegating to the given MapPropertySource .

Usage

From source file:org.greencheek.utils.environment.propertyplaceholder.spring.ListBasedMutablePropertySources.java

public static PropertySource getSystemEnvironmentProperties() {
    StandardEnvironment env = new StandardEnvironment();
    return new SystemEnvironmentPropertySource(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME,
            env.getSystemEnvironment());
}

From source file:org.greencheek.utils.environment.propertyplaceholder.spring.EnvironmentalPropertySourcesPlaceholderConfigurerWithSpringValueResolution.java

@Override
public void afterPropertiesSet() {
    if (mergerBuilder == null) {
        throw new IllegalStateException("The PropertyMergerBuilder must not be null.");
    }/*from w  w  w .  java  2  s .c om*/

    Properties p = mergerBuilder.build().getMergedProperties();

    StandardEnvironment env = new StandardEnvironment();
    MutablePropertySources sources = new MutablePropertySources();

    if (isSystemPropertiesResolutionEnabled())
        sources.addLast(new MapPropertySource(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME,
                env.getSystemProperties()));
    if (isEnvironmentPropertiesResolutionEnabled())
        sources.addLast(new SystemEnvironmentPropertySource(
                StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, env.getSystemEnvironment()));

    sources.addFirst(new PropertiesPropertySource(ENVIRONMENT_SPECIFIC_PROPERTIES, p));
    super.setPropertySources(sources);
}