org.broadleafcommerce.common.config
Class RuntimeEnvironmentPropertiesConfigurer
java.lang.Object
org.springframework.core.io.support.PropertiesLoaderSupport
org.springframework.beans.factory.config.PropertyResourceConfigurer
org.springframework.beans.factory.config.PlaceholderConfigurerSupport
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
org.broadleafcommerce.common.config.RuntimeEnvironmentPropertiesConfigurer
- All Implemented Interfaces:
- org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.beans.factory.InitializingBean, org.springframework.core.Ordered, org.springframework.core.PriorityOrdered
public class RuntimeEnvironmentPropertiesConfigurer
- extends org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
- implements org.springframework.beans.factory.InitializingBean
A property resource configurer that chooses the property file at runtime
based on the runtime environment.
Used for choosing properties files based on the current runtime environment,
allowing for movement of the same application between multiple runtime
environments without rebuilding.
The property replacement semantics of this implementation are identical to
PropertyPlaceholderConfigurer, from which this class inherits.
<bean id="propertyConfigurator" class="frilista.framework.RuntimeEnvironmentPropertiesConfigurer">
<property name="propertyLocation" value="/WEB-INF/runtime-properties/" />
<property name="environments">
<set>
<value>production</value>
<value>staging</value>
<value>integration</value>
<value>development</value>
</set>
</property>
<property name="defaultEnvironment" value="development"/>
</bean>
The keys of the environment specific properties files are
compared to ensure that each property file defines the complete set of keys,
in order to avoid environment-specific failures.
An optional RuntimeEnvironmentKeyResolver implementation can be provided,
allowing for customization of how the runtime environment is determined. If
no implementation is provided, a default of
SystemPropertyRuntimeEnvironmentKeyResolver is used (which uses the system
property 'runtime.environment')
- Author:
- Chris Lee
| Fields inherited from class org.springframework.beans.factory.config.PropertyPlaceholderConfigurer |
SYSTEM_PROPERTIES_MODE_FALLBACK, SYSTEM_PROPERTIES_MODE_NEVER, SYSTEM_PROPERTIES_MODE_OVERRIDE |
| Fields inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupport |
DEFAULT_PLACEHOLDER_PREFIX, DEFAULT_PLACEHOLDER_SUFFIX, DEFAULT_VALUE_SEPARATOR, ignoreUnresolvablePlaceholders, nullValue, placeholderPrefix, placeholderSuffix, valueSeparator |
| Fields inherited from class org.springframework.core.io.support.PropertiesLoaderSupport |
localOverride, localProperties |
| Fields inherited from interface org.springframework.core.Ordered |
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
| Methods inherited from class org.springframework.beans.factory.config.PropertyPlaceholderConfigurer |
parseStringValue, resolvePlaceholder, resolvePlaceholder, resolveSystemProperty, setSearchSystemEnvironment, setSystemPropertiesMode, setSystemPropertiesModeName |
| Methods inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupport |
doProcessProperties, setBeanFactory, setBeanName, setIgnoreUnresolvablePlaceholders, setNullValue, setPlaceholderPrefix, setPlaceholderSuffix, setValueSeparator |
| Methods inherited from class org.springframework.beans.factory.config.PropertyResourceConfigurer |
convertProperties, convertProperty, convertPropertyValue, getOrder, postProcessBeanFactory, setOrder |
| Methods inherited from class org.springframework.core.io.support.PropertiesLoaderSupport |
loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected SupportLogger logger
SHARED_PROPERTY_OVERRIDE
protected static final String SHARED_PROPERTY_OVERRIDE
- See Also:
- Constant Field Values
PROPERTY_OVERRIDE
protected static final String PROPERTY_OVERRIDE
- See Also:
- Constant Field Values
defaultEnvironments
protected static Set<String> defaultEnvironments
blcPropertyLocations
protected static Set<org.springframework.core.io.Resource> blcPropertyLocations
defaultPropertyLocations
protected static Set<org.springframework.core.io.Resource> defaultPropertyLocations
defaultEnvironment
protected String defaultEnvironment
determinedEnvironment
protected String determinedEnvironment
keyResolver
protected RuntimeEnvironmentKeyResolver keyResolver
environments
protected Set<String> environments
propertyLocations
protected Set<org.springframework.core.io.Resource> propertyLocations
overridableProperyLocations
protected Set<org.springframework.core.io.Resource> overridableProperyLocations
stringValueResolver
protected org.springframework.util.StringValueResolver stringValueResolver
RuntimeEnvironmentPropertiesConfigurer
public RuntimeEnvironmentPropertiesConfigurer()
afterPropertiesSet
public void afterPropertiesSet()
throws IOException
- Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
- Throws:
IOException
createSharedPropertiesResource
protected org.springframework.core.io.Resource[] createSharedPropertiesResource(String environment)
throws IOException
- Throws:
IOException
createBroadleafResource
protected org.springframework.core.io.Resource[] createBroadleafResource()
throws IOException
- Throws:
IOException
createSharedCommonResource
protected org.springframework.core.io.Resource[] createSharedCommonResource()
throws IOException
- Throws:
IOException
createPropertiesResource
protected org.springframework.core.io.Resource[] createPropertiesResource(String environment)
throws IOException
- Throws:
IOException
createCommonResource
protected org.springframework.core.io.Resource[] createCommonResource()
throws IOException
- Throws:
IOException
createSharedOverrideResource
protected org.springframework.core.io.Resource createSharedOverrideResource()
throws IOException
- Throws:
IOException
createOverrideResource
protected org.springframework.core.io.Resource createOverrideResource()
throws IOException
- Throws:
IOException
determineEnvironment
public String determineEnvironment()
processProperties
protected void processProperties(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactoryToProcess,
Properties props)
throws org.springframework.beans.BeansException
- Overrides:
processProperties in class org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
- Throws:
org.springframework.beans.BeansException
setDefaultEnvironment
public void setDefaultEnvironment(String defaultEnvironment)
- Sets the default environment name, used when the runtime environment
cannot be determined.
getDefaultEnvironment
public String getDefaultEnvironment()
setKeyResolver
public void setKeyResolver(RuntimeEnvironmentKeyResolver keyResolver)
setEnvironments
public void setEnvironments(Set<String> environments)
- Sets the allowed list of runtime environments
setPropertyLocations
public void setPropertyLocations(Set<org.springframework.core.io.Resource> propertyLocations)
- Sets the directory from which to read environment-specific properties
files; note that it must end with a '/'
setOverridableProperyLocations
public void setOverridableProperyLocations(Set<org.springframework.core.io.Resource> overridableProperyLocations)
- Sets the directory from which to read environment-specific properties
files; note that it must end with a '/'. Note, these properties may be
overridden by those defined in propertyLocations and any "runtime-properties" directories
- Parameters:
overridableProperyLocations - location containing overridable environment properties
getStringValueResolver
public org.springframework.util.StringValueResolver getStringValueResolver()
Copyright © 2013. All Rights Reserved.