diff --git a/org.springframework.context/src/main/java/org/springframework/jndi/JndiPropertySource.java b/org.springframework.context/src/main/java/org/springframework/jndi/JndiPropertySource.java index f0688a35c2a..734a6a07622 100644 --- a/org.springframework.context/src/main/java/org/springframework/jndi/JndiPropertySource.java +++ b/org.springframework.context/src/main/java/org/springframework/jndi/JndiPropertySource.java @@ -42,12 +42,6 @@ public class JndiPropertySource extends PropertySource { /** JNDI context property source name: {@value} */ public static final String JNDI_PROPERTY_SOURCE_NAME = "jndiPropertySource"; - /** - * Name of property used to determine if a {@link JndiPropertySource} - * should be registered by default: {@value} - */ - public static final String JNDI_PROPERTY_SOURCE_ENABLED_FLAG = "jndiPropertySourceEnabled"; - /** * Create a new {@code JndiPropertySource} with the default name * {@value #JNDI_PROPERTY_SOURCE_NAME} and create a new {@link InitialContext} diff --git a/org.springframework.web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java b/org.springframework.web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java index 534c728af63..56b864523ec 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java +++ b/org.springframework.web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java @@ -55,6 +55,13 @@ public class StandardServletEnvironment extends StandardEnvironment { /** Servlet config init parameters property source name: {@value} */ public static final String SERVLET_CONFIG_PROPERTY_SOURCE_NAME = "servletConfigInitParams"; + /** + * Name of property used to determine if a {@link JndiPropertySource} + * should be registered by default: {@value} + */ + public static final String JNDI_PROPERTY_SOURCE_ENABLED_FLAG = "jndiPropertySourceEnabled"; + + /** * Customize the set of property sources with those contributed by superclasses as * well as those appropriate for standard servlet-based environments: @@ -90,7 +97,7 @@ public class StandardServletEnvironment extends StandardEnvironment { propertySources.addLast(new StubPropertySource(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)); super.customizePropertySources(propertySources); - if (this.getProperty(JndiPropertySource.JNDI_PROPERTY_SOURCE_ENABLED_FLAG, boolean.class, false)) { + if (this.getProperty(JNDI_PROPERTY_SOURCE_ENABLED_FLAG, boolean.class, false)) { propertySources.addAfter(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, new JndiPropertySource()); } } diff --git a/org.springframework.web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java b/org.springframework.web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java index bf61846b832..068338a94e0 100644 --- a/org.springframework.web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java +++ b/org.springframework.web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java @@ -19,6 +19,7 @@ package org.springframework.web.context.support; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; +import static org.springframework.web.context.support.StandardServletEnvironment.JNDI_PROPERTY_SOURCE_ENABLED_FLAG; import org.junit.Test; import org.springframework.core.env.ConfigurableEnvironment; @@ -48,7 +49,7 @@ public class StandardServletEnvironmentTests { @Test public void propertySourceOrder_jndiPropertySourceEnabled() { - System.setProperty(JndiPropertySource.JNDI_PROPERTY_SOURCE_ENABLED_FLAG, "true"); + System.setProperty(JNDI_PROPERTY_SOURCE_ENABLED_FLAG, "true"); ConfigurableEnvironment env = new StandardServletEnvironment(); MutablePropertySources sources = env.getPropertySources(); @@ -59,12 +60,12 @@ public class StandardServletEnvironmentTests { assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(4)); assertThat(sources.size(), is(5)); - System.clearProperty(JndiPropertySource.JNDI_PROPERTY_SOURCE_ENABLED_FLAG); + System.clearProperty(JNDI_PROPERTY_SOURCE_ENABLED_FLAG); } @Test public void propertySourceOrder_jndiPropertySourceEnabledIsFalse() { - System.setProperty(JndiPropertySource.JNDI_PROPERTY_SOURCE_ENABLED_FLAG, "false"); + System.setProperty(JNDI_PROPERTY_SOURCE_ENABLED_FLAG, "false"); ConfigurableEnvironment env = new StandardServletEnvironment(); MutablePropertySources sources = env.getPropertySources(); @@ -75,6 +76,6 @@ public class StandardServletEnvironmentTests { assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(3)); assertThat(sources.size(), is(4)); - System.clearProperty(JndiPropertySource.JNDI_PROPERTY_SOURCE_ENABLED_FLAG); + System.clearProperty(JNDI_PROPERTY_SOURCE_ENABLED_FLAG); } }