Package org.appng.api
Interface Environment
-
- All Known Implementing Classes:
DefaultEnvironment
public interface Environment
TheEnvironment
is able to set, read and remove attributes of a certainScope
. The main purposes are:- keeping track of the current
Subject
viagetSubject()
- providing informations about the current
Locale
andTimeZone
viagetLocale()
andgetTimeZone()
- allowing to share attributes between multiple applications (using
Scope.SESSION
andScope.SITE
) - keeping track of platform-wide configuration parameters (
Scope.PLATFORM
andApplication
s whereApplication.isPrivileged()
istrue
)
- Author:
- Matthias Müller
- See Also:
Scope
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> T
getAttribute(Scope scope, String name)
Returns the attribute with the given name for the givenScope
.String
getAttributeAsString(Scope scope, String name)
Returns the string-representation of an attribute, callingtoString()
on the resulting object.Locale
getLocale()
Returns the currentLocale
.Subject
getSubject()
Returns the currentSubject
.TimeZone
getTimeZone()
Returns the currentTimeZone
.boolean
isSubjectAuthenticated()
Set<String>
keySet(Scope scope)
<T> T
removeAttribute(Scope scope, String name)
Removes the attribute with the given name from the givenScope
and returns it.void
setAttribute(Scope scope, String name, Object value)
Sets an attribute for the givenScope
to the given value.
-
-
-
Method Detail
-
setAttribute
void setAttribute(Scope scope, String name, Object value)
Sets an attribute for the givenScope
to the given value.- Parameters:
scope
- theScope
of the attribute to setname
- the name of the attribute to setvalue
- the attribute to set
-
getAttribute
<T> T getAttribute(Scope scope, String name)
Returns the attribute with the given name for the givenScope
.
-
removeAttribute
<T> T removeAttribute(Scope scope, String name)
Removes the attribute with the given name from the givenScope
and returns it.
-
getAttributeAsString
String getAttributeAsString(Scope scope, String name)
Returns the string-representation of an attribute, callingtoString()
on the resulting object.
-
getLocale
Locale getLocale()
Returns the currentLocale
. If aSubject
is logged in, aLocale
is returned that represent the language of theSubject
viaAccount.getLanguage()
. If noSubject
is present, the default-Locale
from theSite
is used.- Returns:
- the
Locale
-
getTimeZone
TimeZone getTimeZone()
Returns the currentTimeZone
. If aSubject
is present (no matter whether it is logged in or not),Account.getTimeZone()
is being returned. If noSubject
is present, the default-TimeZone
from theSite
is used.- Returns:
- the
TimeZone
-
isSubjectAuthenticated
boolean isSubjectAuthenticated()
- Returns:
true
if the currentSubject
is authenticated,false
otherwise
-
-