public class DefaultEnvironment extends Object implements Environment
Environment.| Modifier | Constructor and Description |
|---|---|
protected |
DefaultEnvironment() |
protected |
DefaultEnvironment(javax.servlet.ServletContext servletContext,
javax.servlet.http.HttpSession httpSession,
javax.servlet.ServletRequest servletRequest)
Deprecated.
|
protected |
DefaultEnvironment(javax.servlet.ServletContext servletContext,
javax.servlet.http.HttpSession httpSession,
javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse)
Deprecated.
use
DefaultEnvironment(ServletRequest, ServletResponse) instead. |
|
DefaultEnvironment(javax.servlet.ServletContext context,
String host)
Deprecated.
use
get(ServletContext) instead |
|
DefaultEnvironment(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearSiteScope(Site site)
Clears the site-scoped attributes for the given
Site. |
void |
disable(Scope scope)
Disables the given
Scope for this environment |
void |
enable(Scope scope)
Enables the given
Scope for this environment |
static DefaultEnvironment |
get(javax.servlet.http.HttpSession session)
Returns a new
DefaultEnvironment. |
static DefaultEnvironment |
get(javax.servlet.jsp.PageContext pageContext)
Returns a fully initialized DefaultEnvironment.
|
static DefaultEnvironment |
get(javax.servlet.ServletContext context)
Returns a new
DefaultEnvironment. |
static DefaultEnvironment |
get(javax.servlet.ServletContext context,
javax.servlet.ServletRequest request)
Deprecated.
use
get(ServletRequest, ServletResponse) instead! |
static DefaultEnvironment |
get(javax.servlet.ServletContext context,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
Deprecated.
use
get(ServletRequest, ServletResponse) instead! |
static DefaultEnvironment |
get(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
Returns a fully initialized DefaultEnvironment.
|
<T> T |
getAttribute(Scope scope,
String name)
Returns the attribute with the given name for the given
Scope. |
String |
getAttributeAsString(Scope scope,
String name)
Returns the string-representation of an attribute, calling
toString() on the resulting object. |
ScopedEnvironment |
getEnvironment(Scope scope)
Returns a
ScopedEnvironment for the given Scope |
static DefaultEnvironment |
getGlobal() |
Locale |
getLocale()
Returns the current
Locale. |
javax.servlet.ServletContext |
getServletContext()
Returns the current
ServletContext. |
javax.servlet.http.HttpServletRequest |
getServletRequest()
Returns the current
HttpServletRequest. |
javax.servlet.http.HttpServletResponse |
getServletResponse()
Returns the current
HttpServletResponse. |
Map<String,Object> |
getSession() |
Site |
getSite()
Returns the current
Site, if this environment has been created from a HttpServletRequest |
Subject |
getSubject()
Returns the current
Subject. |
TimeZone |
getTimeZone()
Returns the current
TimeZone. |
void |
init(javax.servlet.ServletContext context,
javax.servlet.http.HttpSession session,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
String host)
Deprecated.
|
void |
init(javax.servlet.ServletContext servletContext,
javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse) |
static DefaultEnvironment |
initGlobal(javax.servlet.ServletContext ctx) |
void |
initSiteScope(Site site) |
boolean |
isInitialized()
Checks whether this
Environment has been initialized. |
boolean |
isSubjectAuthenticated()
|
Set<String> |
keySet(Scope scope)
|
void |
logoutSubject()
Removes the current
Subject form the HttpSession and invalidates the latter. |
<T> T |
removeAttribute(Scope scope,
String name)
Removes the attribute with the given name from the given
Scope and returns it. |
void |
setAttribute(Scope scope,
String name,
Object value)
Sets an attribute for the given
Scope to the given value. |
void |
setLocale(Locale locale) |
void |
setSubject(Subject subject)
Sets the
Subject fur the current HttpSession. |
void |
setTimeZone(TimeZone timeZone) |
String |
toString() |
protected DefaultEnvironment()
@Deprecated protected DefaultEnvironment(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpSession httpSession, javax.servlet.ServletRequest servletRequest)
@Deprecated protected DefaultEnvironment(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpSession httpSession, javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse)
DefaultEnvironment(ServletRequest, ServletResponse) instead.@Deprecated public DefaultEnvironment(javax.servlet.ServletContext context, String host)
get(ServletContext) insteadcontext - a ServletContexthost - the host for the site-Scopepublic DefaultEnvironment(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse)
public static DefaultEnvironment initGlobal(javax.servlet.ServletContext ctx)
public static DefaultEnvironment getGlobal()
@Deprecated public void init(javax.servlet.ServletContext context, javax.servlet.http.HttpSession session, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, String host)
init(ServletContext, ServletRequest, ServletResponse) instead.init in interface Environmentcontext - a ServletContextsession - a HttpSessionrequest - a ServletRequestresponse - a ServletResponsehost - the host for the site-Scopepublic void init(javax.servlet.ServletContext servletContext,
javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse)
public static DefaultEnvironment get(javax.servlet.jsp.PageContext pageContext)
pageContext - a PageContextpublic static DefaultEnvironment get(javax.servlet.http.HttpSession session)
DefaultEnvironment. Only Scope.PLATFORM and Scope.SESSION will be available
for the returned instance.session - a HttpSessionDefaultEnvironment@Deprecated public static DefaultEnvironment get(javax.servlet.ServletContext context, javax.servlet.ServletRequest request)
get(ServletRequest, ServletResponse) instead!context - a ServletContextrequest - a ServletRequestDefaultEnvironmentpublic static DefaultEnvironment get(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
request - a ServletRequestresponse - a ServletResponseDefaultEnvironment@Deprecated public static DefaultEnvironment get(javax.servlet.ServletContext context, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
get(ServletRequest, ServletResponse) instead!context - a ServletContextrequest - a ServletRequestresponse - a ServletResponseDefaultEnvironmentpublic static DefaultEnvironment get(javax.servlet.ServletContext context)
DefaultEnvironment. Only Scope.PLATFORM will be available for the returned
instance.context - a ServletContextDefaultEnvironmentpublic void setAttribute(Scope scope, String name, Object value)
EnvironmentScope to the given value.setAttribute in interface Environmentscope - the Scope of the attribute to setname - the name of the attribute to setvalue - the attribute to setpublic <T> T getAttribute(Scope scope, String name)
EnvironmentScope.getAttribute in interface Environmentscope - the Scope of the attribute to getname - the name of the attribute to getnull if the attribute does not exist in the given
Scopepublic <T> T removeAttribute(Scope scope, String name)
EnvironmentScope and returns it.removeAttribute in interface Environmentscope - the Scope of the attribute to removename - the name of the attribute to removenull if the attribute does not exist in the given
Scopepublic String getAttributeAsString(Scope scope, String name)
EnvironmenttoString() on the resulting object.getAttributeAsString in interface Environmentscope - the Scope of the attribute to getname - the name of the attribute to getnull if the attribute does not exist in the given
Scopepublic ScopedEnvironment getEnvironment(Scope scope)
EnvironmentScopedEnvironment for the given ScopegetEnvironment in interface Environmentscope - the Scope to useScopedEnvironment, if scope is available, null otherwise.public Set<String> keySet(Scope scope)
EnvironmentkeySet in interface Environmentscope - the Scope the get the attribute names forSet containing all attribute names, or null if the Scope is not availablepublic javax.servlet.ServletContext getServletContext()
ServletContext.ServletContextpublic javax.servlet.http.HttpServletRequest getServletRequest()
HttpServletRequest.HttpServletRequestpublic javax.servlet.http.HttpServletResponse getServletResponse()
HttpServletResponse.HttpServletResponsepublic boolean isSubjectAuthenticated()
EnvironmentisSubjectAuthenticated in interface Environmenttrue if the current Subject is authenticated, false otherwisepublic void setSubject(Subject subject)
Subject fur the current HttpSession.subject - the Subject to setpublic Locale getLocale()
EnvironmentLocale. If a Subject is logged in, a Locale is returned that
represent the language of the Subject via Account.getLanguage(). If no Subject is
present, the default-Locale from the Site is used.getLocale in interface EnvironmentLocalepublic void setLocale(Locale locale)
public TimeZone getTimeZone()
EnvironmentTimeZone. If a Subject is present (no matter whether it is logged in or not),
Account.getTimeZone() is being returned. If no Subject is present, the default-TimeZone
from the Site is used.getTimeZone in interface EnvironmentTimeZonepublic void setTimeZone(TimeZone timeZone)
public Site getSite()
EnvironmentSite, if this environment has been created from a HttpServletRequestgetSite in interface Environmentpublic Subject getSubject()
EnvironmentSubject.getSubject in interface EnvironmentSubject, if presentpublic void logoutSubject()
Subject form the HttpSession and invalidates the latter.public void disable(Scope scope)
Scope for this environmentscope - the Scope to disableenable(Scope)public void enable(Scope scope)
Scope for this environmentscope - the Scope to enabledisable(Scope)public boolean isInitialized()
Environment has been initialized.true if his Environment has been initialized, false otherwise.init(ServletContext, HttpSession, ServletRequest, ServletResponse, String)public void initSiteScope(Site site)
Copyright © 2011–2023 aiticon GmbH. All rights reserved.