public class BroadleafEnvironmentConfiguringApplicationListener extends Object implements org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>
Adds META-INF/spring.factories entries of type FrameworkCommonClasspathPropertySource and BroadleafSharedOverrideProfileAwarePropertySource
to the current Environment. All property sources that this initializer adds are added as composite sources to the Environment with
different priorities, and are added relative to each other via the AnnotationAwareOrderComparator. The PropertySources are in the Environment
in the following order, all as CompositePropertySources:
OVERRIDE_SOURCES_NAME - An external property file given with -Dproperty-overridePROFILE_AWARE_SOURCES_NAME - All BroadleafSharedOverrideProfileAwarePropertySource entries from META-INF/spring.factoriesFRAMEWORK_SOURCES_NAME - All FrameworkCommonClasspathPropertySource entries from META-IF/spring.factories
If no Spring profile is active, this will default to "development" and add that profile to Environment.getActiveProfiles() in order
to maintain backwards compatibility with Broadleaf versions prior to 5.2.
This is by default added into META-INF/spring.factories with the org.springframework.context.ApplicationContextInitializer key. In non-boot
applications this must be added manually like in a web.xml with:
<context-param> <param-name>contextInitializerClasses</param-name> <param-value>org.broadleafcommerce.common.config.BroadleafEnvironmentConfiguringApplicationListener</param-value> </context-param>
BroadleafSharedOverrideProfileAwarePropertySource,
FrameworkCommonClasspathPropertySource| Modifier and Type | Field and Description |
|---|---|
static String |
DEPRECATED_RUNTIME_ENVIRONMENT_KEY |
static String |
FRAMEWORK_SOURCES_NAME
The name of the Broadleaf framework composite properties within the Environment, useful for ordering before and after
|
static String |
OVERRIDE_SOURCES_NAME
The name of the the property source from the command line -Dproperty-override
|
static String |
PROFILE_AWARE_SOURCES_NAME
The name of the profile-aware property sources
|
static String |
PROPERTY_OVERRIDES_PROPERTY
A -D argument representing a path to a file that overrides all of the other properties resolved from internal property files
|
static String |
PROPERTY_SHARED_OVERRIDES_PROPERTY |
static String |
SHARED_OVERRIDE_SOURCES_NAME
The name of the the property source from the command line -Dproperty-shared-override
|
| Constructor and Description |
|---|
BroadleafEnvironmentConfiguringApplicationListener() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addToEnvironment(org.springframework.core.env.ConfigurableEnvironment environment,
List<org.springframework.core.io.Resource> resources,
String compositeSourceName,
String addBeforeSourceName)
Adds the specified resource as a
PropertySource to the given environment at the order from addBeforeResourceName. |
protected org.springframework.core.io.Resource |
createClasspathResource(String rootLocation,
String propertyName,
String suffix) |
protected String |
getDeprecatedDefaultProfileKey() |
protected List<FrameworkCommonClasspathPropertySource> |
getFrameworkSources() |
protected List<BroadleafSharedOverrideProfileAwarePropertySource> |
getProfileAwareSources() |
void |
initialize(org.springframework.context.ConfigurableApplicationContext applicationContext) |
public static final String PROPERTY_OVERRIDES_PROPERTY
public static final String PROPERTY_SHARED_OVERRIDES_PROPERTY
public static final String DEPRECATED_RUNTIME_ENVIRONMENT_KEY
public static final String FRAMEWORK_SOURCES_NAME
public static final String PROFILE_AWARE_SOURCES_NAME
public static final String SHARED_OVERRIDE_SOURCES_NAME
public static final String OVERRIDE_SOURCES_NAME
public BroadleafEnvironmentConfiguringApplicationListener()
protected List<FrameworkCommonClasspathPropertySource> getFrameworkSources()
protected List<BroadleafSharedOverrideProfileAwarePropertySource> getProfileAwareSources()
public void initialize(org.springframework.context.ConfigurableApplicationContext applicationContext)
initialize in interface org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>protected org.springframework.core.io.Resource createClasspathResource(String rootLocation, String propertyName, String suffix)
protected void addToEnvironment(org.springframework.core.env.ConfigurableEnvironment environment,
List<org.springframework.core.io.Resource> resources,
String compositeSourceName,
String addBeforeSourceName)
Adds the specified resource as a PropertySource to the given environment at the order from addBeforeResourceName. If the
resource does not exist (meaning resource.exists() == false) then this immediately returns addBeforeResourceName
If addBeforeResourceName is null, the given resource will be added last via MutablePropertySources.addLast(PropertySource).
protected String getDeprecatedDefaultProfileKey()
Copyright © 2017. All rights reserved.