Example usage for org.springframework.beans.factory.config PropertyPlaceholderConfigurer SYSTEM_PROPERTIES_MODE_NEVER

List of usage examples for org.springframework.beans.factory.config PropertyPlaceholderConfigurer SYSTEM_PROPERTIES_MODE_NEVER

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config PropertyPlaceholderConfigurer SYSTEM_PROPERTIES_MODE_NEVER.

Prototype

int SYSTEM_PROPERTIES_MODE_NEVER

To view the source code for org.springframework.beans.factory.config PropertyPlaceholderConfigurer SYSTEM_PROPERTIES_MODE_NEVER.

Click Source Link

Document

Never check system properties.

Usage

From source file:org.alfresco.config.SystemPropertiesFactoryBean.java

@SuppressWarnings("unchecked")
@Override/* w ww  . j  a  va2 s  .  com*/
protected Properties mergeProperties() throws IOException {
    // First do the default merge
    Properties props = super.mergeProperties();

    // Now resolve all the merged properties
    if (this.systemPropertiesMode == PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_NEVER) {
        // If we are in never mode, we don't refer to system properties at all
        for (String systemProperty : (Set<String>) (Set) props.keySet()) {
            resolveMergedProperty(systemProperty, props);
        }
    } else {
        // Otherwise, we allow unset properties to drift through from the systemProperties set and potentially set
        // ones to be overriden by system properties
        Set<String> propNames = new HashSet<String>((Set<String>) (Set) props.keySet());
        propNames.addAll(this.systemProperties);
        for (String systemProperty : propNames) {
            resolveMergedProperty(systemProperty, props);
            if (this.systemPropertiesMode == PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_FALLBACK
                    && props.containsKey(systemProperty)) {
                // It's already there
                continue;
            }
            // Get the system value and assign if present
            String systemPropertyValue = System.getProperty(systemProperty);
            if (systemPropertyValue != null) {
                props.put(systemProperty, systemPropertyValue);
            }
        }
    }
    return props;
}