public class BroadleafEnvironmentConfigurer extends Object
Created as a common class for adding property sources to the Spring Environment
.
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 PropertySource
s are in the Environment
in the following order, all as CompositePropertySource
s:
OVERRIDE_SOURCES_NAME
- An external property file given with -Dproperty-override
PROFILE_AWARE_SOURCES_NAME
- All BroadleafSharedOverrideProfileAwarePropertySource
entries from META-INF/spring.factories
FRAMEWORK_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.
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 |
---|
BroadleafEnvironmentConfigurer() |
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. |
void |
configure(org.springframework.core.env.ConfigurableEnvironment environment) |
protected org.springframework.core.io.Resource |
createClasspathResource(String rootLocation,
String propertyName,
String suffix) |
protected String |
getDeprecatedDefaultProfileKey() |
protected List<FrameworkCommonClasspathPropertySource> |
getFrameworkSources() |
protected List<BroadleafSharedOverrideProfileAwarePropertySource> |
getProfileAwareSources() |
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
protected List<FrameworkCommonClasspathPropertySource> getFrameworkSources()
protected List<BroadleafSharedOverrideProfileAwarePropertySource> getProfileAwareSources()
public void configure(org.springframework.core.env.ConfigurableEnvironment environment)
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 © 2022. All rights reserved.