Search in sources :

Example 1 with StubPropertySource

use of org.springframework.core.env.PropertySource.StubPropertySource in project spring-framework by spring-projects.

the class StandardServletEnvironment method customizePropertySources.

/**
 * Customize the set of property sources with those contributed by superclasses as
 * well as those appropriate for standard servlet-based environments:
 * <ul>
 * <li>{@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME}
 * <li>{@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}
 * <li>{@value #JNDI_PROPERTY_SOURCE_NAME}
 * </ul>
 * <p>Properties present in {@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME} will
 * take precedence over those in {@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}, and
 * properties found in either of the above take precedence over those found in
 * {@value #JNDI_PROPERTY_SOURCE_NAME}.
 * <p>Properties in any of the above will take precedence over system properties and
 * environment variables contributed by the {@link StandardEnvironment} superclass.
 * <p>The {@code Servlet}-related property sources are added as
 * {@link StubPropertySource stubs} at this stage, and will be
 * {@linkplain #initPropertySources(ServletContext, ServletConfig) fully initialized}
 * once the actual {@link ServletContext} object becomes available.
 * @see StandardEnvironment#customizePropertySources
 * @see org.springframework.core.env.AbstractEnvironment#customizePropertySources
 * @see ServletConfigPropertySource
 * @see ServletContextPropertySource
 * @see org.springframework.jndi.JndiPropertySource
 * @see org.springframework.context.support.AbstractApplicationContext#initPropertySources
 * @see #initPropertySources(ServletContext, ServletConfig)
 */
@Override
protected void customizePropertySources(MutablePropertySources propertySources) {
    propertySources.addLast(new StubPropertySource(SERVLET_CONFIG_PROPERTY_SOURCE_NAME));
    propertySources.addLast(new StubPropertySource(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME));
    if (jndiPresent && JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()) {
        propertySources.addLast(new JndiPropertySource(JNDI_PROPERTY_SOURCE_NAME));
    }
    super.customizePropertySources(propertySources);
}
Also used : StubPropertySource(org.springframework.core.env.PropertySource.StubPropertySource) JndiPropertySource(org.springframework.jndi.JndiPropertySource)

Aggregations

StubPropertySource (org.springframework.core.env.PropertySource.StubPropertySource)1 JndiPropertySource (org.springframework.jndi.JndiPropertySource)1