Package org.openbravo.client.kernel
Class RequestContext
- java.lang.Object
-
- org.openbravo.client.kernel.RequestContext
-
public class RequestContext extends Object
The request context serves multiple purposes:- Provides the request and response object through a ThreadLocal. This means that these do not have to passed as parameters to methods.
- If there is no request/response object available then Mock versions are used. This makes it possible to run logic in a test environment outside of the servlet container.
- Makes it possible to set request parameters to simulate a request from a client to a server.
- Author:
- mtaal
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RequestContext.HttpServletRequestWrapper
static class
RequestContext.HttpSessionWrapper
-
Constructor Summary
Constructors Constructor Description RequestContext()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
clear()
static RequestContext
get()
Map<?,?>
getParameterMap()
javax.servlet.http.HttpServletRequest
getRequest()
String
getRequestContent()
String
getRequestParameter(String name)
javax.servlet.http.HttpServletResponse
getResponse()
This method makes only sense to be invoked from a Request in a servlet container, other cases response will be nullstatic javax.servlet.ServletContext
getServletContext()
javax.servlet.http.HttpSession
getSession()
Object
getSessionAttribute(String name)
Enumeration<?>
getSessionAttributeNames()
VariablesSecureApp
getVariablesSecureApp()
void
removeSessionAttribute(String name)
void
setRequest(javax.servlet.http.HttpServletRequest request)
void
setRequestContent(String requestContent)
void
setRequestParameter(String name, String value)
void
setResponse(javax.servlet.http.HttpServletResponse response)
static void
setServletContext(javax.servlet.ServletContext aServletContext)
void
setSessionAttribute(String name, Object value)
void
setVariableSecureApp(VariablesSecureApp variablesSecureApp)
-
-
-
Method Detail
-
getServletContext
public static javax.servlet.ServletContext getServletContext()
-
setServletContext
public static void setServletContext(javax.servlet.ServletContext aServletContext)
-
get
public static RequestContext get()
-
clear
public static void clear()
-
getRequestContent
public String getRequestContent()
-
getParameterMap
public Map<?,?> getParameterMap()
-
getSessionAttributeNames
public Enumeration<?> getSessionAttributeNames()
-
removeSessionAttribute
public void removeSessionAttribute(String name)
-
getSession
public javax.servlet.http.HttpSession getSession()
-
getRequest
public javax.servlet.http.HttpServletRequest getRequest()
-
setRequestContent
public void setRequestContent(String requestContent)
-
getVariablesSecureApp
public VariablesSecureApp getVariablesSecureApp()
-
setVariableSecureApp
public void setVariableSecureApp(VariablesSecureApp variablesSecureApp)
-
setRequest
public void setRequest(javax.servlet.http.HttpServletRequest request)
-
getResponse
public javax.servlet.http.HttpServletResponse getResponse()
This method makes only sense to be invoked from a Request in a servlet container, other cases response will be null
-
setResponse
public void setResponse(javax.servlet.http.HttpServletResponse response)
-
-