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 ServletContext
host
- the host for the site-Scope
public 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 Environment
context
- a ServletContext
session
- a HttpSession
request
- a ServletRequest
response
- a ServletResponse
host
- the host for the site-Scope
public 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 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
@Deprecated public static DefaultEnvironment get(javax.servlet.ServletContext context, javax.servlet.ServletRequest request)
get(ServletRequest, ServletResponse)
instead!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
@Deprecated public static DefaultEnvironment get(javax.servlet.ServletContext context, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
get(ServletRequest, ServletResponse)
instead!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 ScopedEnvironment getEnvironment(Scope scope)
Environment
ScopedEnvironment
for the given Scope
getEnvironment
in interface Environment
scope
- the Scope
to useScopedEnvironment
, if scope is available, null
otherwise.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 Site getSite()
Environment
Site
, if this environment has been created from a HttpServletRequest
getSite
in interface Environment
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)
public void initSiteScope(Site site)
Copyright © 2011–2023 aiticon GmbH. All rights reserved.