Package com.aspectran.core.context.env
Interface Environment
-
- All Known Implementing Classes:
AbstractEnvironment
,ContextEnvironment
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.ApplicationAdapter
getApplicationAdapter()
Returns the application adapter.java.lang.String
getBasePath()
Returns the base path that the current application is mapped to.java.lang.ClassLoader
getClassLoader()
Returns the class loader used by the current application.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, Activity activity)
Returns the value of the property on environment via Activity.java.lang.String
toRealPath(java.lang.String filePath)
Returns to convert the given file path with the real file path.java.io.File
toRealPathAsFile(java.lang.String filePath)
Returns to convert the given file path with the real file path.
-
-
-
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, Activity activity)
Returns the value of the property on environment via Activity.- Type Parameters:
T
- the type of the value- Parameters:
name
- the given property nameactivity
- the current activity- Returns:
- the value of the property on environment
-
getApplicationAdapter
ApplicationAdapter getApplicationAdapter()
Returns the application adapter.- Returns:
- the application adapter
-
getClassLoader
java.lang.ClassLoader getClassLoader()
Returns the class loader used by the current application.- Returns:
- the class loader
-
getBasePath
java.lang.String getBasePath()
Returns the base path that the current application is mapped to.- Returns:
- the application base path
-
toRealPath
java.lang.String toRealPath(java.lang.String filePath) throws java.io.IOException
Returns to convert the given file path with the real file path.- Parameters:
filePath
- the specified file path- Returns:
- the real file path
- Throws:
java.io.IOException
- if an I/O error has occurred
-
toRealPathAsFile
java.io.File toRealPathAsFile(java.lang.String filePath) throws java.io.IOException
Returns to convert the given file path with the real file path.- Parameters:
filePath
- the specified file path- Returns:
- the real file path
- Throws:
java.io.IOException
- if an I/O error has occurred
-
-