@RequestScoped public class ActionContext extends ActContext.Base<ActionContext> implements Destroyable
AppContext encapsulate contextual properties needed by an application session
| Modifier and Type | Class and Description |
|---|---|
static class |
ActionContext.ActionContextEvent |
static class |
ActionContext.PreFireSessionResolvedEvent
This event is fired after session resolved and before any
SessionManager.Listener get called |
static class |
ActionContext.SessionDissolvedEvent |
static class |
ActionContext.SessionResolvedEvent
This event is fired after session resolved and after all
SessionManager.Listener get notified and in turn after all event listeners that listen to the ActionContext.PreFireSessionResolvedEvent get notified |
static class |
ActionContext.SessionWillDissolveEvent |
static class |
ActionContext.State |
Destroyable.UtilActContext.Base<CTX extends ActContext.Base>, ActContext.Listener| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ATTR_CSR_TOKEN_PREFETCH |
static java.lang.String |
ATTR_CSRF_TOKEN |
static java.lang.String |
ATTR_CURRENT_FILE_INDEX |
static java.lang.String |
ATTR_EXCEPTION |
static java.lang.String |
ATTR_HANDLER |
static java.lang.String |
ATTR_RESULT |
static java.lang.String |
ATTR_WAS_UNAUTHENTICATED |
static java.lang.String |
METHOD_GET_CURRENT |
static java.lang.String |
REQ_BODY |
loggerATTR_CUR_METHOD| Modifier and Type | Method and Description |
|---|---|
java.util.List<java.lang.String> |
__appRenderArgNames() |
ActionContext |
__appRenderArgNames(java.lang.String names)
Called by bytecode enhancer to set the name list of the render arguments that is update by the enhancer
|
java.lang.Object |
__controllerInstance(java.lang.String className) |
ActionContext |
__controllerInstance(java.lang.String className,
java.lang.Object instance) |
org.osgl.http.H.Format |
accept() |
ActionContext |
accept(org.osgl.http.H.Format fmt) |
boolean |
acceptJson() |
boolean |
acceptXML() |
java.lang.String |
actionPath() |
ActionContext |
actionPath(java.lang.String path) |
ActionContext |
addUpload(java.lang.String name,
org.osgl.storage.ISObject sobj) |
java.util.Map<java.lang.String,java.lang.String[]> |
allParams() |
ActionContext |
applyContentType() |
ActionContext |
applyContentType(org.osgl.mvc.result.Result result)
Apply content type to response with result provided.
|
ActionContext |
applyCorsSpec() |
java.lang.String |
body() |
org.osgl.util.S.Buffer |
buildViolationMessage(org.osgl.util.S.Buffer builder) |
org.osgl.util.S.Buffer |
buildViolationMessage(org.osgl.util.S.Buffer builder,
java.lang.String separator) |
ActionContext |
byPassImplicitVariable() |
void |
cache(java.lang.String key,
java.lang.Object obj)
Add an object into cache by key.
|
void |
cache(java.lang.String key,
java.lang.Object obj,
int expiration)
Add an object into cache by key with expiration time specified
|
<T> T |
cached(java.lang.String key)
Return cached object by key.
|
void |
cacheForHalfHour(java.lang.String key,
java.lang.Object obj)
Add an object into cache by key and expired after half hour
|
void |
cacheForOneHour(java.lang.String key,
java.lang.Object obj)
Add an object into cache by key and expired after one hour
|
void |
cacheForOneMinute(java.lang.String key,
java.lang.Object obj)
Add an object into cache by key and expired after one minute
|
void |
cacheForTenMinutes(java.lang.String key,
java.lang.Object obj)
Add an object into cache by key and expired after 10 minutes
|
void |
checkCsrf(org.osgl.http.H.Session session) |
static void |
clearCurrent() |
static void |
clearLocal() |
org.osgl.http.H.Cookie |
cookie(java.lang.String name) |
static ActionContext |
create(App app,
org.osgl.http.H.Request request,
ActResponse<?> resp)
Create an new
AppContext and return the new instance |
MissingAuthenticationHandler |
csrfFailureHandler() |
static ActionContext |
current() |
void |
disableCORS() |
void |
dissolve()
Dissolve session and flash into cookies.
|
ActionContext |
enableCache() |
void |
evictCache(java.lang.String key)
Evict cached object
|
org.osgl.http.H.Flash |
flash() |
java.lang.String |
flash(java.lang.String key) |
org.osgl.http.H.Flash |
flash(java.lang.String key,
java.lang.String value) |
ActionContext |
flashViolationMessage() |
ActionContext |
flashViolationMessage(java.lang.String separator) |
ActionContext |
forceCsrfCheckingFailureHandler(MissingAuthenticationHandler handler) |
ActionContext |
forceMissingAuthenticationHandler(MissingAuthenticationHandler handler) |
ActionContext |
forceResponseStatus(org.osgl.http.H.Status status) |
RequestHandler |
handler() |
ActionContext |
handler(RequestHandler handler) |
java.lang.Boolean |
hasTemplate() |
boolean |
isAjax() |
boolean |
isByPassImplicitTemplateVariable() |
boolean |
isLoggedIn() |
boolean |
isOptionsMethod() |
boolean |
isPathVar(java.lang.String name) |
boolean |
isSessionDissolved() |
boolean |
isSessionResolved() |
boolean |
jsonEncoded() |
java.util.Locale |
locale(boolean required) |
void |
login(java.lang.String username)
Update the context session to mark a user logged in
|
void |
logout()
Logout the current session.
|
java.lang.String |
methodPath() |
MissingAuthenticationHandler |
missingAuthenticationHandler() |
org.osgl.mvc.result.Result |
nullValueResult() |
org.osgl.mvc.result.Result |
nullValueResultIgnoreRenderArgs() |
ActionContext |
param(java.lang.String name,
java.lang.String value) |
java.util.Set<java.lang.String> |
paramKeys() |
java.lang.String |
paramVal(java.lang.String name) |
java.lang.String[] |
paramVals(java.lang.String name) |
int |
pathVarCount() |
int |
port() |
java.lang.String |
portId() |
void |
preCheckCsrf() |
ActResponse<?> |
prepareRespForWrite() |
protected void |
releaseResources()
Clear all internal data store/cache and then remove this context from thread local
|
<T> T |
renderArg(java.lang.String name) |
ActionContext |
renderArg(java.lang.String name,
java.lang.Object val) |
java.util.Map<java.lang.String,java.lang.Object> |
renderArgs()
Returns all render arguments
|
org.osgl.http.H.Request |
req() |
void |
resolve()
Initialize params/renderArgs/attributes and then resolve session and flash from cookies
|
ActResponse<?> |
resp() |
Router |
router() |
ActionContext |
router(Router router) |
void |
saveLocal() |
org.osgl.http.H.Session |
session() |
java.lang.String |
session(java.lang.String key) |
org.osgl.http.H.Session |
session(java.lang.String key,
java.lang.String value) |
java.lang.String |
sessionId()
Returns HTTP session’s id
|
void |
setCsrfCookieAndRenderArgs() |
ActionContext |
setHasTemplate(boolean b) |
void |
startHandling() |
void |
startIntercepting() |
ActionContext.State |
state() |
org.osgl.http.H.Status |
successStatus() |
ActionContext |
templateChangeListener(org.osgl.Osgl.Visitor<org.osgl.http.H.Format> listener) |
ActionContext |
templatePath(java.lang.String templatePath)
Set path to template file
|
org.osgl.storage.ISObject |
upload(java.lang.String name) |
org.osgl.storage.ISObject |
upload(java.lang.String name,
int index) |
java.lang.String |
urlContext() |
ActionContext |
urlContext(java.lang.String context) |
ActionContext |
urlPathParam(java.lang.String name,
java.lang.String value) |
org.osgl.web.util.UserAgent |
userAgent() |
java.lang.String |
username() |
java.lang.String |
violationMessage() |
java.lang.String |
violationMessage(java.lang.String separator) |
_act_i18n, addDestroyable, addListener, addViolation, addViolations, app, attribute, attribute, attributes, cachedTemplate, cacheTemplate, config, currentContext, currentContextType, dataPattern, disableTemplateCaching, fieldOutputVarCount, fieldOutputVarCount, handlerMethod, handlerMethod, hasRenderArgs, hasViolation, i18n, i18n, i18n, i18n, i18n, i18n, i18n, i18n, i18n, i18n, locale, locale, me, pattern, pattern, progress, removeAttribute, setJobId, strBuf, templateContext, templateContext, templatePath, templatePathIsImplicit, violation, violationsaddSubResource, destroy, isDestroyed, reload, scopedebug, debug, error, error, fatal, fatal, info, info, isDebugEnabled, isTraceEnabled, trace, trace, warn, warnclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdestroy, isDestroyed, scopepublic static final java.lang.String ATTR_CSRF_TOKEN
public static final java.lang.String ATTR_CSR_TOKEN_PREFETCH
public static final java.lang.String ATTR_WAS_UNAUTHENTICATED
public static final java.lang.String ATTR_HANDLER
public static final java.lang.String ATTR_RESULT
public static final java.lang.String ATTR_EXCEPTION
public static final java.lang.String ATTR_CURRENT_FILE_INDEX
public static final java.lang.String REQ_BODY
public static final java.lang.String METHOD_GET_CURRENT
public ActionContext.State state()
public boolean isSessionDissolved()
public boolean isSessionResolved()
public org.osgl.http.H.Request req()
public ActResponse<?> resp()
public ActResponse<?> prepareRespForWrite()
public org.osgl.http.H.Cookie cookie(java.lang.String name)
public org.osgl.http.H.Session session()
public java.lang.String session(java.lang.String key)
public org.osgl.http.H.Session session(java.lang.String key,
java.lang.String value)
public java.lang.String sessionId()
Returns HTTP session’s id
sessionId in interface ActContext<ActionContext>sessionId in class ActContext.Base<ActionContext>public org.osgl.http.H.Flash flash()
public java.lang.String flash(java.lang.String key)
public org.osgl.http.H.Flash flash(java.lang.String key,
java.lang.String value)
public Router router()
public ActionContext router(Router router)
public MissingAuthenticationHandler missingAuthenticationHandler()
public MissingAuthenticationHandler csrfFailureHandler()
public ActionContext forceMissingAuthenticationHandler(MissingAuthenticationHandler handler)
public ActionContext forceCsrfCheckingFailureHandler(MissingAuthenticationHandler handler)
public ActionContext byPassImplicitVariable()
public boolean isByPassImplicitTemplateVariable()
public ActionContext urlContext(java.lang.String context)
public java.lang.String urlContext()
public <T> T renderArg(java.lang.String name)
renderArg in interface ActContext<ActionContext>renderArg in class ActContext.Base<ActionContext>public ActionContext renderArg(java.lang.String name, java.lang.Object val)
renderArg in interface ActContext<ActionContext>renderArg in class ActContext.Base<ActionContext>public java.util.Map<java.lang.String,java.lang.Object> renderArgs()
ActContextReturns all render arguments
renderArgs in interface ActContext<ActionContext>renderArgs in class ActContext.Base<ActionContext>public ActionContext templatePath(java.lang.String templatePath)
ActContextSet path to template file
templatePath in interface ActContext<ActionContext>templatePath in class ActContext.Base<ActionContext>templatePath - the path to template fileAppContextpublic ActionContext templateChangeListener(org.osgl.Osgl.Visitor<org.osgl.http.H.Format> listener)
public RequestHandler handler()
public ActionContext handler(RequestHandler handler)
public org.osgl.http.H.Format accept()
accept in interface ActContext<ActionContext>public ActionContext accept(org.osgl.http.H.Format fmt)
accept in interface ActContext<ActionContext>public java.lang.Boolean hasTemplate()
public ActionContext setHasTemplate(boolean b)
public ActionContext enableCache()
public int pathVarCount()
public boolean isPathVar(java.lang.String name)
public java.lang.String portId()
public int port()
public org.osgl.web.util.UserAgent userAgent()
public boolean jsonEncoded()
public boolean acceptJson()
public boolean acceptXML()
public boolean isAjax()
public boolean isOptionsMethod()
public java.lang.String username()
public boolean isLoggedIn()
public java.lang.String body()
public ActionContext param(java.lang.String name, java.lang.String value)
public ActionContext urlPathParam(java.lang.String name, java.lang.String value)
public java.util.Set<java.lang.String> paramKeys()
paramKeys in interface org.osgl.mvc.util.ParamValueProviderpublic java.lang.String paramVal(java.lang.String name)
paramVal in interface org.osgl.mvc.util.ParamValueProviderpublic java.lang.String[] paramVals(java.lang.String name)
paramVals in interface org.osgl.mvc.util.ParamValueProviderpublic java.util.Map<java.lang.String,java.lang.String[]> allParams()
public org.osgl.storage.ISObject upload(java.lang.String name)
public org.osgl.storage.ISObject upload(java.lang.String name,
int index)
public ActionContext addUpload(java.lang.String name, org.osgl.storage.ISObject sobj)
public org.osgl.http.H.Status successStatus()
public ActionContext forceResponseStatus(org.osgl.http.H.Status status)
public org.osgl.mvc.result.Result nullValueResult()
public org.osgl.mvc.result.Result nullValueResultIgnoreRenderArgs()
public void preCheckCsrf()
public void checkCsrf(org.osgl.http.H.Session session)
public void setCsrfCookieAndRenderArgs()
public void disableCORS()
public ActionContext applyContentType(org.osgl.mvc.result.Result result)
Apply content type to response with result provided.
If result is an error then it might not apply content type as requested: * If request is not ajax request, then use text/html * If request is ajax request then apply requested content type only when json or xml is requested * otherwise use text/html
result - the result used to check if it is error resultActionContext.public ActionContext applyContentType()
public ActionContext applyCorsSpec()
public ActionContext __appRenderArgNames(java.lang.String names)
Called by bytecode enhancer to set the name list of the render arguments that is update by the enhancer
names - the render argument names separated by “,”public java.util.List<java.lang.String> __appRenderArgNames()
public ActionContext __controllerInstance(java.lang.String className, java.lang.Object instance)
public java.lang.Object __controllerInstance(java.lang.String className)
public <T> T cached(java.lang.String key)
Return cached object by key. The key will be concatenated with current session id when fetching the cached object
T - the object typekey - public void cache(java.lang.String key,
java.lang.Object obj)
Add an object into cache by key. The key will be used in conjunction with session id if there is a session instance
key - the key to index the object within the cacheobj - the object to be cachedpublic void cache(java.lang.String key,
java.lang.Object obj,
int expiration)
Add an object into cache by key with expiration time specified
key - the key to index the object within the cacheobj - the object to be cachedexpiration - the seconds after which the object will be evicted from the cachepublic void cacheForOneHour(java.lang.String key,
java.lang.Object obj)
Add an object into cache by key and expired after one hour
key - the key to index the object within the cacheobj - the object to be cachedpublic void cacheForHalfHour(java.lang.String key,
java.lang.Object obj)
Add an object into cache by key and expired after half hour
key - the key to index the object within the cacheobj - the object to be cachedpublic void cacheForTenMinutes(java.lang.String key,
java.lang.Object obj)
Add an object into cache by key and expired after 10 minutes
key - the key to index the object within the cacheobj - the object to be cachedpublic void cacheForOneMinute(java.lang.String key,
java.lang.Object obj)
Add an object into cache by key and expired after one minute
key - the key to index the object within the cache+obj - the object to be cachedpublic void evictCache(java.lang.String key)
Evict cached object
key - the key indexed the cached object to be evictedpublic org.osgl.util.S.Buffer buildViolationMessage(org.osgl.util.S.Buffer builder)
public org.osgl.util.S.Buffer buildViolationMessage(org.osgl.util.S.Buffer builder,
java.lang.String separator)
public java.lang.String violationMessage(java.lang.String separator)
public java.lang.String violationMessage()
public ActionContext flashViolationMessage()
public ActionContext flashViolationMessage(java.lang.String separator)
public java.lang.String actionPath()
public ActionContext actionPath(java.lang.String path)
public java.lang.String methodPath()
methodPath in interface ActContext<ActionContext>public void startIntercepting()
public void startHandling()
public void login(java.lang.String username)
Update the context session to mark a user logged in
username - the usernamepublic void logout()
Logout the current session. After calling this method, the session will be cleared
public void resolve()
Initialize params/renderArgs/attributes and then resolve session and flash from cookies
public java.util.Locale locale(boolean required)
locale in interface ActContext<ActionContext>locale in class ActContext.Base<ActionContext>public void dissolve()
Dissolve session and flash into cookies.
Note this method must be called before any content has been committed to response output stream/writer
protected void releaseResources()
Clear all internal data store/cache and then remove this context from thread local
releaseResources in class ActContext.Base<ActionContext>public void saveLocal()
public static void clearLocal()
public static ActionContext current()
public static void clearCurrent()
public static ActionContext create(App app, org.osgl.http.H.Request request, ActResponse<?> resp)
Create an new AppContext and return the new instance
Copyright © 2014–2017 ActFramework. All rights reserved.