Example usage for org.springframework.core.env StandardEnvironment getSystemEnvironment

List of usage examples for org.springframework.core.env StandardEnvironment getSystemEnvironment

Introduction

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

Prototype

@Override
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public Map<String, Object> getSystemEnvironment() 

Source Link

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.");
    }/* w ww. j av  a  2s . co m*/

    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);
}