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

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

Introduction

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

Prototype

String SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME

To view the source code for org.springframework.core.env StandardEnvironment SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME.

Click Source Link

Document

JVM system properties property source name: .

Usage

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

public static PropertySource getSystemProperties() {
    StandardEnvironment env = new StandardEnvironment();
    return new MapPropertySource(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME,
            env.getSystemProperties());/*from  w  ww  . j av a 2  s  .c  o m*/
}

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 . j a  va 2 s. c  o 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);
}

From source file:nl.nn.adapterframework.configuration.IbisContext.java

/**
 * Create Spring Bean factory. Parameter 'springContext' can be null.
 *
 * Create the Spring Bean Factory using the supplied <code>springContext</code>,
 * if not <code>null</code>.
 *
 * @param springContext Spring Context to create. If <code>null</code>,
 * use the default spring context.// w  w w.j a  v a 2s.  co  m
 * The spring context is loaded as a spring ClassPathResource from
 * the class path.
 *
 * @return The Spring XML Bean Factory.
 * @throws BeansException If the Factory can not be created.
 *
 */
private ApplicationContext createApplicationContext() throws BeansException {
    // Reading in Spring Context
    long start = System.currentTimeMillis();
    String springContext = "/springContext.xml";
    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext();
    MutablePropertySources propertySources = applicationContext.getEnvironment().getPropertySources();
    propertySources.remove(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
    propertySources.remove(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME);
    propertySources.addFirst(new PropertiesPropertySource("ibis", APP_CONSTANTS));
    applicationContext.setConfigLocation(springContext);
    applicationContext.refresh();
    log("startup " + springContext + " in " + (System.currentTimeMillis() - start) + " ms");
    return applicationContext;
}

From source file:org.metaeffekt.dcc.commons.mapping.AbstractPropertyExpression.java

@SuppressWarnings("unchecked")
protected <T> T evaluateExpression(String originalExpression, String value, Class<T> type) {
    final ExpressionParser parser = new SpelExpressionParser();

    try {/*w ww  . ja v a  2  s  .com*/
        final StandardEvaluationContext context = new StandardEvaluationContext();
        context.setRootObject(propertiesHolder);
        context.addPropertyAccessor(new EnvironmentAccessor());
        context.setVariable(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, STANDARD_ENVIRONMENT);
        context.setVariable(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, STANDARD_ENVIRONMENT);

        final Expression expression = parser.parseExpression(value, PARSER_CONTEXT);

        return expression.getValue(context, type);
    } catch (ParseException | EvaluationException e) {
        LOG.debug(String.format("Failed to evaluate expression %s, and with replaced properties %s",
                originalExpression, value), e);
    }

    if (type == String.class) {
        return (T) value;
    }

    return null;
}

From source file:org.springframework.boot.env.SpringApplicationJsonEnvironmentPostProcessor.java

private String findPropertySource(MutablePropertySources sources) {
    if (ClassUtils.isPresent(SERVLET_ENVIRONMENT_CLASS, null)
            && sources.contains(StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME)) {
        return StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME;

    }//  ww  w.  j a  va2  s. c o m
    return StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME;
}