|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.core.env.AbstractEnvironment
public abstract class AbstractEnvironment
Abstract base class for Environment implementations.
DefaultEnvironment| Field Summary | |
|---|---|
static String |
ACTIVE_PROFILES_PROPERTY_NAME
Name of property to set to specify active profiles: "spring.profiles.active". |
static String |
DEFAULT_PROFILES_PROPERTY_NAME
Name of property to set to specify default profiles: "spring.profiles.default". |
protected Log |
logger
|
| Constructor Summary | |
|---|---|
AbstractEnvironment()
|
|
| Method Summary | ||
|---|---|---|
boolean |
acceptsProfiles(String... profiles)
|
|
boolean |
containsProperty(String key)
Return whether the given property key is available for resolution. |
|
protected Set<String> |
doGetActiveProfiles()
|
|
protected Set<String> |
doGetDefaultProfiles()
|
|
String[] |
getActiveProfiles()
Return the set of profiles explicitly made active for this environment. |
|
ConversionService |
getConversionService()
|
|
String[] |
getDefaultProfiles()
Return the set of profiles to be active by default when no active profiles have been set explicitly. |
|
String |
getProperty(String key)
Return the property value associated with the given key. |
|
|
getProperty(String key,
Class<T> targetType)
Return the property value associated with the given key, or null
if the key cannot be resolved. |
|
ConfigurablePropertyResolver |
getPropertyResolver()
|
|
MutablePropertySources |
getPropertySources()
Return the PropertySources for this environment in mutable form |
|
String |
getRequiredProperty(String key)
Return the property value associated with the given key, converted to the given targetType (never null). |
|
|
getRequiredProperty(String key,
Class<T> targetType)
Return the property value associated with the given key, converted to the given targetType (never null). |
|
Map<String,Object> |
getSystemEnvironment()
Return the value of System.getenv() if allowed by the current SecurityManager,
otherwise return a map implementation that will attempt to access individual keys using calls to
System.getenv(String). |
|
Map<String,Object> |
getSystemProperties()
Return the value of System.getProperties() if allowed by the current SecurityManager,
otherwise return a map implementation that will attempt to access individual keys using calls to
System.getProperty(String). |
|
String |
resolvePlaceholders(String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by PropertyResolver.getProperty(java.lang.String). |
|
String |
resolveRequiredPlaceholders(String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by PropertyResolver.getProperty(java.lang.String). |
|
void |
setActiveProfiles(String... profiles)
Specify the set of profiles active for this Environment. |
|
void |
setConversionService(ConversionService conversionService)
Set the ConversionService to be used when performing type
conversions on properties. |
|
void |
setDefaultProfiles(String... profiles)
Specify the set of profiles to be made active by default if no other profiles are explicitly made active through ConfigurableEnvironment.setActiveProfiles(java.lang.String...). |
|
void |
setPlaceholderPrefix(String placeholderPrefix)
|
|
void |
setPlaceholderSuffix(String placeholderSuffix)
|
|
void |
setValueSeparator(String valueSeparator)
|
|
String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String ACTIVE_PROFILES_PROPERTY_NAME
ConfigurableEnvironment.setActiveProfiles(java.lang.String...),
Constant Field Valuespublic static final String DEFAULT_PROFILES_PROPERTY_NAME
ConfigurableEnvironment.setDefaultProfiles(java.lang.String...),
Constant Field Valuesprotected final Log logger
| Constructor Detail |
|---|
public AbstractEnvironment()
| Method Detail |
|---|
public String[] getActiveProfiles()
EnvironmentConfigurableEnvironment.setActiveProfiles(String...).
If no profiles have explicitly been specified as active, then any 'default' profiles will implicitly be considered active.
getActiveProfiles in interface EnvironmentEnvironment.getDefaultProfiles(),
ConfigurableEnvironment.setActiveProfiles(java.lang.String...),
ACTIVE_PROFILES_PROPERTY_NAMEprotected Set<String> doGetActiveProfiles()
public void setActiveProfiles(String... profiles)
ConfigurableEnvironment
setActiveProfiles in interface ConfigurableEnvironmentConfigurableEnvironment.setDefaultProfiles(java.lang.String...),
Profile,
ACTIVE_PROFILES_PROPERTY_NAMEpublic String[] getDefaultProfiles()
Environment
getDefaultProfiles in interface EnvironmentEnvironment.getActiveProfiles(),
ConfigurableEnvironment.setDefaultProfiles(java.lang.String...)protected Set<String> doGetDefaultProfiles()
public void setDefaultProfiles(String... profiles)
ConfigurableEnvironmentConfigurableEnvironment.setActiveProfiles(java.lang.String...).
setDefaultProfiles in interface ConfigurableEnvironmentDEFAULT_PROFILES_PROPERTY_NAMEpublic boolean acceptsProfiles(String... profiles)
acceptsProfiles in interface EnvironmentEnvironment.getActiveProfiles(),
Environment.getDefaultProfiles()public MutablePropertySources getPropertySources()
ConfigurableEnvironmentPropertySources for this environment in mutable form
getPropertySources in interface ConfigurableEnvironmentpublic ConfigurablePropertyResolver getPropertyResolver()
public Map<String,Object> getSystemEnvironment()
ConfigurableEnvironmentSystem.getenv() if allowed by the current SecurityManager,
otherwise return a map implementation that will attempt to access individual keys using calls to
System.getenv(String).
Note that most Environment implementations will include this system environment map as
a default PropertySource to be searched. Therefore, it is recommended that this method not be
used directly unless bypassing other property sources is expressly intended.
Calls to Map.get(Object) on the Map returned will never throw IllegalAccessException;
in cases where the SecurityManager forbids access to a property, null will be returned and an
INFO-level log message will be issued noting the exception.
getSystemEnvironment in interface ConfigurableEnvironmentpublic Map<String,Object> getSystemProperties()
ConfigurableEnvironmentSystem.getProperties() if allowed by the current SecurityManager,
otherwise return a map implementation that will attempt to access individual keys using calls to
System.getProperty(String).
Note that most Environment implementations will include this system properties map as a
default PropertySource to be searched. Therefore, it is recommended that this method not be
used directly unless bypassing other property sources is expressly intended.
Calls to Map.get(Object) on the Map returned will never throw IllegalAccessException;
in cases where the SecurityManager forbids access to a property, null will be returned and an
INFO-level log message will be issued noting the exception.
getSystemProperties in interface ConfigurableEnvironmentpublic boolean containsProperty(String key)
PropertyResolver
containsProperty in interface PropertyResolverpublic String getProperty(String key)
PropertyResolver
getProperty in interface PropertyResolverPropertyResolver.getProperty(String, Class)
public <T> T getProperty(String key,
Class<T> targetType)
PropertyResolvernull
if the key cannot be resolved.
getProperty in interface PropertyResolver
public String getRequiredProperty(String key)
throws IllegalStateException
PropertyResolvernull).
getRequiredProperty in interface PropertyResolverIllegalStateException - if the key cannot be resolvedPropertyResolver.getRequiredProperty(String, Class)
public <T> T getRequiredProperty(String key,
Class<T> targetType)
throws IllegalStateException
PropertyResolvernull).
getRequiredProperty in interface PropertyResolverIllegalStateException - if the given key cannot be resolvedpublic String resolvePlaceholders(String text)
PropertyResolverPropertyResolver.getProperty(java.lang.String). Unresolvable placeholders with
no default value are ignored and passed through unchanged.
resolvePlaceholders in interface PropertyResolvertext - the String to resolve
null)PropertyResolver.resolveRequiredPlaceholders(java.lang.String),
SystemPropertyUtils.resolvePlaceholders(String)
public String resolveRequiredPlaceholders(String text)
throws IllegalArgumentException
PropertyResolverPropertyResolver.getProperty(java.lang.String). Unresolvable placeholders with
no default value will cause an IllegalArgumentException to be thrown.
resolveRequiredPlaceholders in interface PropertyResolvernull)
IllegalArgumentException - if given text is nullSystemPropertyUtils.resolvePlaceholders(String, boolean)public void setConversionService(ConversionService conversionService)
ConfigurablePropertyResolverConversionService to be used when performing type
conversions on properties.
setConversionService in interface ConfigurablePropertyResolverPropertyResolver.getProperty(String, Class)public ConversionService getConversionService()
getConversionService in interface ConfigurablePropertyResolverConversionService used when performing type
conversions on properties.PropertyResolver.getProperty(String, Class)public void setPlaceholderPrefix(String placeholderPrefix)
setPlaceholderPrefix in interface ConfigurablePropertyResolverpublic void setPlaceholderSuffix(String placeholderSuffix)
setPlaceholderSuffix in interface ConfigurablePropertyResolverpublic void setValueSeparator(String valueSeparator)
setValueSeparator in interface ConfigurablePropertyResolverpublic String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||