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) |
protected |
DefaultEnvironment(javax.servlet.ServletContext servletContext,
javax.servlet.http.HttpSession httpSession,
javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse) |
|
DefaultEnvironment(javax.servlet.ServletContext context,
String host)
Returns a fully initialized DefaultEnvironment.
|
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)
Returns a fully initialized DefaultEnvironment.
|
static DefaultEnvironment |
get(javax.servlet.ServletContext context,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
Returns a fully initialized DefaultEnvironment.
|
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. |
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 . |
Subject |
getSubject()
Returns the current
Subject . |
TimeZone |
getTimeZone()
Returns the current
TimeZone . |
void |
init(javax.servlet.ServletContext servletContext,
javax.servlet.http.HttpSession httpSession,
javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse,
String host)
Initializes the
Environment . |
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(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpSession httpSession, javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse)
protected DefaultEnvironment()
protected DefaultEnvironment(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpSession httpSession, javax.servlet.ServletRequest servletRequest)
public void init(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpSession httpSession, javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, String host)
Environment
Environment
.init
in interface Environment
servletContext
- a ServletContext
httpSession
- a HttpSession
servletRequest
- a ServletRequest
servletResponse
- a ServletResponse
host
- the host for the site-Scope
public static DefaultEnvironment get(javax.servlet.jsp.PageContext pageContext)
pageContext
- a PageContext
public static DefaultEnvironment get(javax.servlet.http.HttpSession session)
DefaultEnvironment
. Only Scope.PLATFORM
and Scope.SESSION
will be available
for the returned instance.session
- a HttpSession
DefaultEnvironment
public static DefaultEnvironment get(javax.servlet.ServletContext context, javax.servlet.ServletRequest request)
context
- a ServletContext
request
- a ServletRequest
DefaultEnvironment
public static DefaultEnvironment get(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
request
- a ServletRequest
response
- a ServletResponse
DefaultEnvironment
public static DefaultEnvironment get(javax.servlet.ServletContext context, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
context
- a ServletContext
request
- a ServletRequest
response
- a ServletResponse
DefaultEnvironment
public static DefaultEnvironment get(javax.servlet.ServletContext context)
DefaultEnvironment
. Only Scope.PLATFORM
will be available for the returned
instance.context
- a ServletContext
DefaultEnvironment
public void setAttribute(Scope scope, String name, Object value)
Environment
Scope
to the given value.setAttribute
in interface Environment
scope
- 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)
Environment
Scope
.getAttribute
in interface Environment
scope
- the Scope
of the attribute to getname
- the name of the attribute to getnull
if the attribute does not exist in the given
Scope
public <T> T removeAttribute(Scope scope, String name)
Environment
Scope
and returns it.removeAttribute
in interface Environment
scope
- the Scope
of the attribute to removename
- the name of the attribute to removenull
if the attribute does not exist in the given
Scope
public String getAttributeAsString(Scope scope, String name)
Environment
toString()
on the resulting object.getAttributeAsString
in interface Environment
scope
- the Scope
of the attribute to getname
- the name of the attribute to getnull
if the attribute does not exist in the given
Scope
public Set<String> keySet(Scope scope)
Environment
keySet
in interface Environment
scope
- 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
.ServletContext
public javax.servlet.http.HttpServletRequest getServletRequest()
HttpServletRequest
.HttpServletRequest
public javax.servlet.http.HttpServletResponse getServletResponse()
HttpServletResponse
.HttpServletResponse
public boolean isSubjectAuthenticated()
Environment
isSubjectAuthenticated
in interface Environment
true
if the current Subject
is authenticated, false
otherwisepublic void setSubject(Subject subject)
Subject
fur the current HttpSession
.subject
- the Subject
to setpublic Locale getLocale()
Environment
Locale
. 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 Environment
Locale
public void setLocale(Locale locale)
public TimeZone getTimeZone()
Environment
TimeZone
. 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 Environment
TimeZone
public void setTimeZone(TimeZone timeZone)
public Subject getSubject()
Environment
Subject
.getSubject
in interface Environment
Subject
, 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)
Copyright © 2011–2020 aiticon GmbH. All rights reserved.