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

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

Introduction

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

Prototype

public void setSearchSystemEnvironment(boolean searchSystemEnvironment) 

Source Link

Document

Set whether to search for a matching system environment variable if no matching system property has been found.

Usage

From source file:org.intalio.tempo.security.ws.BaseWS.java

protected void initStatics() {
    if (_initialized)
        return;//w w w.  j  a v a 2s  .co m
    try {
        synchronized (BaseWS.class) {
            if (_initialized)
                return;
            LOG.debug("Initializing configuration.");
            String configDir = System.getProperty(Constants.CONFIG_DIR_PROPERTY);
            if (configDir == null) {
                throw new RuntimeException(
                        "System property " + Constants.CONFIG_DIR_PROPERTY + " not defined.");
            }
            _configDir = new File(configDir);
            if (!_configDir.exists()) {
                throw new RuntimeException(
                        "Configuration directory " + _configDir.getAbsolutePath() + " doesn't exist.");
            }

            Thread thread = Thread.currentThread();
            ClassLoader oldClassLoader = thread.getContextClassLoader();
            try {
                thread.setContextClassLoader(getClass().getClassLoader());
                FileSystemResource config = new FileSystemResource(new File(_configDir, "securityConfig.xml"));
                XmlBeanFactory factory = new XmlBeanFactory(config);

                PropertyPlaceholderConfigurer propsCfg = new PropertyPlaceholderConfigurer();
                propsCfg.setSearchSystemEnvironment(true);
                propsCfg.postProcessBeanFactory(factory);
                _securityProvider = (SecurityProvider) factory.getBean("securityProvider");
                _tokenService = (org.intalio.tempo.security.token.TokenService) factory.getBean("tokenService");
                _initialized = true;
            } finally {
                thread.setContextClassLoader(oldClassLoader);
            }
        }
    } catch (RuntimeException except) {
        LOG.error("Error during initialization of security service", except);
        throw except;
    }
}

From source file:guru.qas.martini.jmeter.config.DefaultApplicationContextBuilder.java

protected void setEnvironment(ConfigurableApplicationContext context, Properties properties) {
    PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    configurer.setProperties(properties);
    configurer.setLocalOverride(true);//  w w  w.  j  a v a  2  s .c  o m
    configurer.setSearchSystemEnvironment(true);
    configurer.setSystemPropertiesMode(SYSTEM_PROPERTIES_MODE_FALLBACK);
    context.addBeanFactoryPostProcessor(configurer);
}