|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object info.magnolia.context.MgnlContext
public class MgnlContext
This class allows obtaining of the current Request without passing the request around the world. A ThreadLocal variable is used to manage the request and to make sure it doesn't escape to another processing.
In a later version this class should not depend on servlets. The core should use the context to get and set attributes instead of using the request or session object directly. Magnolia could run then in a neutral and configurable context.
Nested Class Summary | |
---|---|
static interface |
MgnlContext.Op<T,E extends java.lang.Throwable>
A simple execution interface to be used with the doInSystemContext method. |
static interface |
MgnlContext.SystemContextOperation
Deprecated. since 4.2 - use the Op interface, which can return values, or extend VoidOp. |
static class |
MgnlContext.VoidOp
An Op that does not return values and can only throw RuntimeExceptions. |
Constructor Summary | |
---|---|
MgnlContext()
Do not instantiate this class. |
Method Summary | ||
---|---|---|
static
|
doInSystemContext(MgnlContext.Op<T,E> op)
Executes the given operation in the system context and sets it back to the original once done (also if an exception is thrown). |
|
static
|
doInSystemContext(MgnlContext.Op<T,E> op,
boolean releaseAfterExecution)
Executes the given operation in the system context and sets it back to the original once done (also if an exception is thrown). |
|
static void |
doInSystemContext(MgnlContext.SystemContextOperation op)
Deprecated. since 4.2 - use the Op interface, which can return values, or extend VoidOp. |
|
static void |
doInSystemContext(MgnlContext.SystemContextOperation op,
boolean releaseAfterExecution)
Deprecated. since 4.2 - use the Op interface, which can return values, or extend VoidOp. |
|
static AccessManager |
getAccessManager(java.lang.String repositoryId)
Get access manager for the specified repository on default workspace. |
|
static AccessManager |
getAccessManager(java.lang.String repositoryId,
java.lang.String workspaceId)
Get access manager for the specified repository on the specified workspace. |
|
static AggregationState |
getAggregationState()
Returns the AggregationState if we're in a WebContext, throws an IllegalStateException otherwise. |
|
static java.lang.Object |
getAttribute(java.lang.String name)
Get attribute value. |
|
static java.lang.Object |
getAttribute(java.lang.String name,
int scope)
Get the attribute from the specified scope. |
|
static java.lang.String |
getContextPath()
|
|
static HierarchyManager |
getHierarchyManager(java.lang.String repositoryId)
Get hierarchy manager initialized for this user. |
|
static HierarchyManager |
getHierarchyManager(java.lang.String repositoryId,
java.lang.String workspaceId)
Get hierarchy manager initialized for this user. |
|
static Context |
getInstance()
Get the current context of this thread. |
|
static java.util.Locale |
getLocale()
Get the context's locale object. |
|
static Messages |
getMessages()
|
|
static Messages |
getMessages(java.lang.String basename)
|
|
static java.lang.String |
getParameter(java.lang.String name)
Get parameter value as string. |
|
static java.util.Map<java.lang.String,java.lang.String> |
getParameters()
Get parameter value as a Map<String, String>. |
|
static java.lang.String[] |
getParameterValues(java.lang.String name)
|
|
static MultipartForm |
getPostedForm()
Get form object assembled by MultipartRequestFilter . |
|
static QueryManager |
getQueryManager(java.lang.String repositoryId)
Get QueryManager created for this user on the specified repository. |
|
static QueryManager |
getQueryManager(java.lang.String repositoryId,
java.lang.String workspaceId)
Get QueryManager created for this user on the specified repository and workspace. |
|
static SystemContext |
getSystemContext()
Get Magnolia system context. |
|
static User |
getUser()
A short cut for the current user. |
|
static WebContext |
getWebContext()
Throws an IllegalStateException if the current context is not set, or if it is not an instance of WebContext. |
|
static WebContext |
getWebContext(java.lang.String exceptionMessage)
Throws an IllegalStateException if the current context is not set, or if it is not an instance of WebContext. |
|
static WebContext |
getWebContextOrNull()
Returns the current context if it is set and is an instance of WebContext, returns null otherwise. |
|
static boolean |
hasAttribute(java.lang.String name)
Check if this attribute exists in the local scope. |
|
static boolean |
hasInstance()
Used to check if an instance is already set since getInstance() will always return a context. |
|
static void |
initAsWebContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.ServletContext servletContext)
Sets this context as a web context. |
|
static boolean |
isSystemInstance()
|
|
static boolean |
isWebContext()
Returns true if the current context is set and is an instance of WebContext. |
|
static void |
login(User user)
|
|
static void |
pop()
|
|
static void |
push(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
|
static void |
release()
Releases the current thread (if not a system context) and calls the releaseThread() method of the system context. |
|
static void |
removeAttribute(java.lang.String name)
Remove an attribute in the local scope. |
|
static void |
resetAggregationState()
Resets the current aggregation state if we're in a WebContext, throws an IllegalStateException otherwise. |
|
static void |
setAttribute(java.lang.String name,
java.lang.Object value)
Set attribute value, scope of the attribute is defined. |
|
static void |
setAttribute(java.lang.String name,
java.lang.Object value,
int scope)
Set attribute value, scope of the attribute is defined. |
|
static void |
setInstance(Context context)
Set context implementation instance. |
|
static void |
setLocale(java.util.Locale locale)
Set the locale for the current context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MgnlContext()
Method Detail |
---|
public static User getUser()
public static void setLocale(java.util.Locale locale)
public static java.util.Locale getLocale()
public static Messages getMessages()
public static Messages getMessages(java.lang.String basename)
public static void login(User user)
public static HierarchyManager getHierarchyManager(java.lang.String repositoryId)
public static HierarchyManager getHierarchyManager(java.lang.String repositoryId, java.lang.String workspaceId)
public static AccessManager getAccessManager(java.lang.String repositoryId)
public static AccessManager getAccessManager(java.lang.String repositoryId, java.lang.String workspaceId)
public static QueryManager getQueryManager(java.lang.String repositoryId)
public static QueryManager getQueryManager(java.lang.String repositoryId, java.lang.String workspaceId)
public static MultipartForm getPostedForm()
MultipartRequestFilter
.
public static java.lang.String getParameter(java.lang.String name)
public static java.lang.String[] getParameterValues(java.lang.String name)
public static java.util.Map<java.lang.String,java.lang.String> getParameters()
public static java.lang.String getContextPath()
public static AggregationState getAggregationState()
public static void resetAggregationState()
public static void setAttribute(java.lang.String name, java.lang.Object value)
public static void setAttribute(java.lang.String name, java.lang.Object value, int scope)
scope
- , highest level of scope from which this attribute is visible.public static java.lang.Object getAttribute(java.lang.String name)
public static java.lang.Object getAttribute(java.lang.String name, int scope)
public static boolean hasAttribute(java.lang.String name)
public static void removeAttribute(java.lang.String name)
public static void setInstance(Context context)
public static Context getInstance()
public static WebContext getWebContext()
getWebContext(String)
public static WebContext getWebContext(java.lang.String exceptionMessage)
getWebContext()
public static WebContext getWebContextOrNull()
public static boolean hasInstance()
public static boolean isSystemInstance()
public static boolean isWebContext()
public static SystemContext getSystemContext()
public static void doInSystemContext(MgnlContext.SystemContextOperation op)
public static <T,E extends java.lang.Throwable> T doInSystemContext(MgnlContext.Op<T,E> op) throws E extends java.lang.Throwable
E extends java.lang.Throwable
public static void doInSystemContext(MgnlContext.SystemContextOperation op, boolean releaseAfterExecution)
public static <T,E extends java.lang.Throwable> T doInSystemContext(MgnlContext.Op<T,E> op, boolean releaseAfterExecution) throws E extends java.lang.Throwable
releaseAfterExecution
- TODO document this parameter
E extends java.lang.Throwable
public static void initAsWebContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext servletContext)
request
- HttpServletRequestresponse
- HttpServletResponseservletContext
- ServletContext instancepublic static void release()
public static void push(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
public static void pop()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |