Class BroadleafEnvironmentConfigurer

java.lang.Object
org.broadleafcommerce.common.config.BroadleafEnvironmentConfigurer
Direct Known Subclasses:
BroadleafEnvironmentConfiguringApplicationListener, BroadleafEnvironmentConfiguringPostProcessor

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 PropertySources are in the Environment in the following order, all as CompositePropertySources:

  1. OVERRIDE_SOURCES_NAME - An external property file given with -Dproperty-override
  2. PROFILE_AWARE_SOURCES_NAME - All BroadleafSharedOverrideProfileAwarePropertySource entries from META-INF/spring.factories
  3. 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.

See Also:
  • Field Details

    • PROPERTY_OVERRIDES_PROPERTY

      public static final 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
      See Also:
    • PROPERTY_SHARED_OVERRIDES_PROPERTY

      public static final String PROPERTY_SHARED_OVERRIDES_PROPERTY
      See Also:
    • DEPRECATED_RUNTIME_ENVIRONMENT_KEY

      public static final String DEPRECATED_RUNTIME_ENVIRONMENT_KEY
      See Also:
    • FRAMEWORK_SOURCES_NAME

      public static final String FRAMEWORK_SOURCES_NAME
      The name of the Broadleaf framework composite properties within the Environment, useful for ordering before and after
      See Also:
    • PROFILE_AWARE_SOURCES_NAME

      public static final String PROFILE_AWARE_SOURCES_NAME
      The name of the profile-aware property sources
      See Also:
    • SHARED_OVERRIDE_SOURCES_NAME

      public static final String SHARED_OVERRIDE_SOURCES_NAME
      The name of the the property source from the command line -Dproperty-shared-override
      See Also:
    • OVERRIDE_SOURCES_NAME

      public static final String OVERRIDE_SOURCES_NAME
      The name of the the property source from the command line -Dproperty-override
      See Also:
  • Constructor Details

    • BroadleafEnvironmentConfigurer

      public BroadleafEnvironmentConfigurer()
  • Method Details

    • getFrameworkSources

      protected List<FrameworkCommonClasspathPropertySource> getFrameworkSources()
    • getProfileAwareSources

      protected List<BroadleafSharedOverrideProfileAwarePropertySource> getProfileAwareSources()
    • configure

      public void configure(org.springframework.core.env.ConfigurableEnvironment environment)
    • createClasspathResource

      protected org.springframework.core.io.Resource createClasspathResource(String rootLocation, String propertyName, String suffix)
    • addToEnvironment

      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).

    • getDeprecatedDefaultProfileKey

      protected String getDeprecatedDefaultProfileKey()