|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Environment
Interface representing the environment in which the current application is running. Models two key aspects of the application environment:
@Profile annotation for syntax details.
The role of the Environment object with relation to profiles is in determining which profiles
(if any) are currently active, and which profiles (if any)
should be active by default.
Properties play an important role in almost all applications, and may originate from a variety of sources: properties files, JVM system properties, system environment variables, JNDI, servlet context parameters, ad-hoc Properties objects, Maps, and so on. The role of the environment object with relation to properties is to provide the user with a convenient service interface for configuring property sources and resolving properties from them.
Beans managed within an ApplicationContext may register to be EnvironmentAware, where they can query profile state
or resolve properties directly.
More commonly, beans will not interact with the Environment directly, but will have ${...}
property values replaced by a property placeholder configurer such as PropertySourcesPlaceholderConfigurer, which itself is EnvironmentAware, and as of Spring 3.1 is
registered by default when using <context:property-placeholder/>.
Configuration of the environment object must be done through the ConfigurableEnvironment
interface, returned from all AbstractApplicationContext subclass getEnvironment() methods. See
DefaultEnvironment for several examples of using the ConfigurableEnvironment interface
to manipulate property sources prior to application context refresh().
EnvironmentCapable,
ConfigurableEnvironment,
DefaultEnvironment,
EnvironmentAware,
ConfigurableApplicationContext.getEnvironment(),
ConfigurableApplicationContext.setEnvironment(org.springframework.core.env.ConfigurableEnvironment),
AbstractApplicationContext.createEnvironment()| Method Summary | |
|---|---|
boolean |
acceptsProfiles(String... profiles)
|
String[] |
getActiveProfiles()
Return the set of profiles explicitly made active for this environment. |
String[] |
getDefaultProfiles()
Return the set of profiles to be active by default when no active profiles have been set explicitly. |
| Methods inherited from interface org.springframework.core.env.PropertyResolver |
|---|
containsProperty, getProperty, getProperty, getRequiredProperty, getRequiredProperty, resolvePlaceholders, resolveRequiredPlaceholders |
| Method Detail |
|---|
String[] getActiveProfiles()
ConfigurableEnvironment.setActiveProfiles(String...).
If no profiles have explicitly been specified as active, then any 'default' profiles will implicitly be considered active.
getDefaultProfiles(),
ConfigurableEnvironment.setActiveProfiles(java.lang.String...),
AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAMEString[] getDefaultProfiles()
getActiveProfiles(),
ConfigurableEnvironment.setDefaultProfiles(java.lang.String...)boolean acceptsProfiles(String... profiles)
IllegalArgumentException - unless at least one profile has been specified
IllegalArgumentException - if any profile is the empty string or consists only of whitespacegetActiveProfiles(),
getDefaultProfiles()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||