@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.Util
ActContext.Base<CTX extends ActContext.Base>, ActContext.Listener
Modifier and Type | Field and Description |
---|---|
static String |
ATTR_CSR_TOKEN_PREFETCH |
static String |
ATTR_CSRF_TOKEN |
static String |
ATTR_CURRENT_FILE_INDEX |
static String |
ATTR_EXCEPTION |
static String |
ATTR_HANDLER |
static String |
ATTR_PATH_VARS |
static String |
ATTR_RESULT |
static String |
ATTR_WAS_UNAUTHENTICATED |
static String |
METHOD_GET_CURRENT |
static String |
REQ_BODY |
Modifier and Type | Method and Description |
---|---|
List<String> |
__appRenderArgNames() |
ActionContext |
__appRenderArgNames(String names)
Called by bytecode enhancer to set the name list of the render arguments that is update by the enhancer
|
Object |
__controllerInstance(String className) |
ActionContext |
__controllerInstance(String className,
Object instance) |
org.osgl.http.H.Format |
accept() |
ActionContext |
accept(org.osgl.http.H.Format fmt) |
boolean |
acceptJson() |
boolean |
acceptXML() |
String |
actionPath() |
ActionContext |
actionPath(String path) |
ActionContext |
addUpload(String name,
org.osgl.storage.ISObject sobj) |
Map<String,String[]> |
allParams() |
ActionContext |
applyContentType() |
ActionContext |
applyCorsSpec() |
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,
String separator) |
void |
cache(String key,
Object obj)
Add an object into cache by key.
|
void |
cache(String key,
Object obj,
int expiration)
Add an object into cache by key with expiration time specified
|
<T> T |
cached(String key)
Return cached object by key.
|
void |
cacheForHalfHour(String key,
Object obj)
Add an object into cache by key and expired after half hour
|
void |
cacheForOneHour(String key,
Object obj)
Add an object into cache by key and expired after one hour
|
void |
cacheForOneMinute(String key,
Object obj)
Add an object into cache by key and expired after one minute
|
void |
cacheForTenMinutes(String key,
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(String name) |
static ActionContext |
create(App app,
org.osgl.http.H.Request request,
org.osgl.http.H.Response 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(String key)
Evict cached object
|
org.osgl.http.H.Flash |
flash() |
String |
flash(String key) |
org.osgl.http.H.Flash |
flash(String key,
String value) |
ActionContext |
flashViolationMessage() |
ActionContext |
flashViolationMessage(String separator) |
ActionContext |
forceCsrfCheckingFailureHandler(MissingAuthenticationHandler handler) |
ActionContext |
forceMissingAuthenticationHandler(MissingAuthenticationHandler handler) |
ActionContext |
forceResponseStatus(org.osgl.http.H.Status status) |
RequestHandler |
handler() |
ActionContext |
handler(RequestHandler handler) |
Boolean |
hasTemplate() |
boolean |
isAjax() |
boolean |
isLoggedIn() |
boolean |
isOptionsMethod() |
boolean |
isSessionDissolved() |
boolean |
isSessionResolved() |
boolean |
jsonEncoded() |
Locale |
locale(boolean required) |
void |
login(String username)
Update the context session to mark a user logged in
|
void |
logout()
Logout the current session.
|
String |
methodPath() |
MissingAuthenticationHandler |
missingAuthenticationHandler() |
org.osgl.mvc.result.Result |
nullValueResult() |
org.osgl.mvc.result.Result |
nullValueResultIgnoreRenderArgs() |
ActionContext |
param(String name,
String value) |
Set<String> |
paramKeys() |
String |
paramVal(String name) |
String[] |
paramVals(String name) |
int |
port() |
String |
portId() |
void |
preCheckCsrf() |
protected void |
releaseResources()
Clear all internal data store/cache and then remove this context from thread local
|
<T> T |
renderArg(String name) |
ActionContext |
renderArg(String name,
Object val) |
Map<String,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
|
org.osgl.http.H.Response |
resp() |
Router |
router() |
ActionContext |
router(Router router) |
void |
saveLocal() |
org.osgl.http.H.Session |
session() |
String |
session(String key) |
org.osgl.http.H.Session |
session(String key,
String value) |
void |
setCsrfCookieAndRenderArgs() |
ActionContext |
setHasTemplate(boolean b) |
void |
startHandling() |
void |
startIntercepting() |
ActionContext.State |
state() |
org.osgl.http.H.Status |
successStatus() |
ActionContext |
templatePath(String templatePath)
Set path to template file
|
org.osgl.storage.ISObject |
upload(String name) |
org.osgl.storage.ISObject |
upload(String name,
int index) |
String |
urlContext() |
ActionContext |
urlContext(String context) |
org.osgl.web.util.UserAgent |
userAgent() |
String |
username() |
String |
violationMessage() |
String |
violationMessage(String separator) |
_act_i18n, addDestroyable, addListener, addViolation, addViolations, app, attribute, attribute, attributes, cachedTemplate, cacheTemplate, config, currentContext, currentContextType, fieldOutputVarCount, fieldOutputVarCount, hasRenderArgs, hasViolation, i18n, i18n, i18n, i18n, i18n, i18n, i18n, i18n, i18n, i18n, locale, locale, me, removeAttribute, strBuf, templateContext, templateContext, templatePath, templatePathIsImplicit, violation, violations
addSubResource, destroy, isDestroyed, reload, scope
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
destroy, isDestroyed, scope
public static final String ATTR_CSRF_TOKEN
public static final String ATTR_CSR_TOKEN_PREFETCH
public static final String ATTR_WAS_UNAUTHENTICATED
public static final String ATTR_HANDLER
public static final String ATTR_PATH_VARS
public static final String ATTR_RESULT
public static final String ATTR_EXCEPTION
public static final String ATTR_CURRENT_FILE_INDEX
public static final String REQ_BODY
public static final String METHOD_GET_CURRENT
public ActionContext.State state()
public boolean isSessionDissolved()
public boolean isSessionResolved()
public org.osgl.http.H.Request req()
public org.osgl.http.H.Response resp()
public org.osgl.http.H.Cookie cookie(String name)
public org.osgl.http.H.Session session()
public org.osgl.http.H.Flash flash()
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 urlContext(String context)
public String urlContext()
public <T> T renderArg(String name)
renderArg
in interface ActContext<ActionContext>
renderArg
in class ActContext.Base<ActionContext>
public ActionContext renderArg(String name, Object val)
renderArg
in interface ActContext<ActionContext>
renderArg
in class ActContext.Base<ActionContext>
public Map<String,Object> renderArgs()
ActContext
Returns all render arguments
renderArgs
in interface ActContext<ActionContext>
renderArgs
in class ActContext.Base<ActionContext>
public ActionContext templatePath(String templatePath)
ActContext
Set path to template file
templatePath
in interface ActContext<ActionContext>
templatePath
in class ActContext.Base<ActionContext>
templatePath
- the path to template fileAppContext
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 Boolean hasTemplate()
public ActionContext setHasTemplate(boolean b)
public ActionContext enableCache()
public 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 String username()
public boolean isLoggedIn()
public String body()
public ActionContext param(String name, String value)
public Set<String> paramKeys()
paramKeys
in interface org.osgl.mvc.util.ParamValueProvider
public String paramVal(String name)
paramVal
in interface org.osgl.mvc.util.ParamValueProvider
public String[] paramVals(String name)
paramVals
in interface org.osgl.mvc.util.ParamValueProvider
public org.osgl.storage.ISObject upload(String name)
public org.osgl.storage.ISObject upload(String name, int index)
public ActionContext addUpload(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()
public ActionContext applyCorsSpec()
public ActionContext __appRenderArgNames(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 ActionContext __controllerInstance(String className, Object instance)
public <T> T cached(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(String key, 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(String key, 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(String key, 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(String key, 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(String key, 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(String key, 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(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, String separator)
public String violationMessage()
public ActionContext flashViolationMessage()
public ActionContext flashViolationMessage(String separator)
public String actionPath()
public ActionContext actionPath(String path)
public String methodPath()
methodPath
in interface ActContext<ActionContext>
public void startIntercepting()
public void startHandling()
public void login(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 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, org.osgl.http.H.Response resp)
Create an new AppContext
and return the new instance
Copyright © 2014-2017 ActFramework. All Rights Reserved.