Package com.aspectran.core.context.env
Interface Environment
-
- All Known Implementing Classes:
ActivityEnvironment
public interface Environment
Interface representing the environment in which the current application is running. Models two key aspects of the application environment: profiles and properties.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
acceptsProfiles(java.lang.String... profiles)
Return whether one or more of the given profiles is active or, in the case of no explicit active profiles, whether one or more of the given profiles is included in the set of default profiles.java.lang.String[]
getActiveProfiles()
Returns the set of profiles explicitly made active for this environment.java.lang.String[]
getDefaultProfiles()
Returns the set of profiles to be active by default when no active profiles have been set explicitly.<T> T
getProperty(java.lang.String name)
Returns the value of the property on environment via the currently available activity.<T> T
getProperty(java.lang.String name, Activity activity)
Returns the value of the property on environment via the specified activity.
-
-
-
Method Detail
-
getActiveProfiles
java.lang.String[] getActiveProfiles()
Returns the set of profiles explicitly made active for this environment.- Returns:
- the set of profiles explicitly made active
-
getDefaultProfiles
java.lang.String[] getDefaultProfiles()
Returns the set of profiles to be active by default when no active profiles have been set explicitly.- Returns:
- the set of profiles to be active by default
-
acceptsProfiles
boolean acceptsProfiles(java.lang.String... profiles)
Return whether one or more of the given profiles is active or, in the case of no explicit active profiles, whether one or more of the given profiles is included in the set of default profiles. If a profile begins with '!' the logic is inverted, i.e. the method will return true if the given profile is not active. For example,env.acceptsProfiles("p1", "!p2")
will returntrue
if profile 'p1' is active or 'p2' is not active.- Parameters:
profiles
- the given profiles- Returns:
- true if the given profile is active; false otherwise
- Throws:
java.lang.IllegalArgumentException
- if called with zero arguments or if any profile isnull
, empty or whitespace-only- See Also:
getActiveProfiles()
,getDefaultProfiles()
-
getProperty
<T> T getProperty(java.lang.String name)
Returns the value of the property on environment via the currently available activity.- Type Parameters:
T
- the type of the value- Parameters:
name
- the given property name- Returns:
- the value of the property on environment
-
getProperty
<T> T getProperty(java.lang.String name, Activity activity)
Returns the value of the property on environment via the specified activity.- Type Parameters:
T
- the type of the value- Parameters:
name
- the given property nameactivity
- the activity- Returns:
- the value of the property on environment
-
-