jrouter.servlet
类 ServletThreadContext

java.lang.Object
  继承者 jrouter.servlet.ServletThreadContext

public class ServletThreadContext
extends Object

ServletThreadContext是一个线程变量,使用了一个公共的ThreadLocal。 ServletThreadContext包含一个ActionInvocation,存储线程安全的Action运行时上下文。 ServletThreadContext包含http的相关的变量。 ServletThreadContext包含一个contextMap变量,存储自定义的key-value。 ServletThreadContext包含一个Exception对象,存储发生的异常。

另请参见:
ServletActionFactory.DefaultServletActionFactory, ServletActionFactory.DefaultServletActionInvocation

方法摘要
static
<T extends jrouter.ActionInvocation>
T
getActionInvocation()
          返回Action运行时上下文。
static Map<String,Object> getContextMap()
          返回ThreadContext中的Map容器。
static Exception getException()
          Get the exception.
static javax.servlet.http.HttpServletRequest getRequest()
          Gets the HTTP servlet request object.
static Map<String,String[]> getRequestParameters()
          Gets the HTTP servlet request parameters.
static javax.servlet.http.HttpServletResponse getResponse()
          Gets the HTTP servlet response object.
static javax.servlet.ServletContext getServletContext()
          Gets the servlet context.
static javax.servlet.http.HttpSession getSession()
          Gets the HTTP servlet session object.
static javax.servlet.http.HttpSession getSession(boolean create)
          Gets the HTTP servlet session object.
static void remove()
          移除前线程副本中的ServletThreadContext。
static void setActionInvocation(jrouter.ActionInvocation actionInvocation)
          设置Action运行时上下文。
static void setException(Exception exception)
          Store the exception.
static void setRequest(javax.servlet.http.HttpServletRequest request)
          Sets the HTTP servlet request object.
static void setResponse(javax.servlet.http.HttpServletResponse response)
          Sets the HTTP servlet response object.
static void setServletContext(javax.servlet.ServletContext servletContext)
          Sets the current servlet context object.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

方法详细信息

remove

public static void remove()
移除前线程副本中的ServletThreadContext。


getActionInvocation

public static <T extends jrouter.ActionInvocation> T getActionInvocation()
返回Action运行时上下文。

类型参数:
T - Action运行时上下文类型。
返回:
Action运行时上下文。
另请参见:
ServletActionFactory.DefaultServletActionFactory.createActionInvocation(java.lang.String, java.lang.Object...)

setActionInvocation

public static void setActionInvocation(jrouter.ActionInvocation actionInvocation)
设置Action运行时上下文。

参数:
actionInvocation - Action运行时上下文。

setRequest

public static void setRequest(javax.servlet.http.HttpServletRequest request)
Sets the HTTP servlet request object.

参数:
request - the HTTP servlet request object.

getRequest

public static javax.servlet.http.HttpServletRequest getRequest()
Gets the HTTP servlet request object.

返回:
the HTTP servlet request object.

getSession

public static javax.servlet.http.HttpSession getSession()
Gets the HTTP servlet session object.

返回:
the HTTP servlet session object.

getSession

public static javax.servlet.http.HttpSession getSession(boolean create)
Gets the HTTP servlet session object.

返回:
the HTTP servlet session object.

getRequestParameters

public static Map<String,String[]> getRequestParameters()
Gets the HTTP servlet request parameters.

返回:
the HTTP servlet request parameters.

setResponse

public static void setResponse(javax.servlet.http.HttpServletResponse response)
Sets the HTTP servlet response object.

参数:
response - the HTTP servlet response object.

getResponse

public static javax.servlet.http.HttpServletResponse getResponse()
Gets the HTTP servlet response object.

返回:
the HTTP servlet response object.

getServletContext

public static javax.servlet.ServletContext getServletContext()
Gets the servlet context.

返回:
the servlet context.

setServletContext

public static void setServletContext(javax.servlet.ServletContext servletContext)
Sets the current servlet context object.

参数:
servletContext - The servlet context to use

getContextMap

public static Map<String,Object> getContextMap()
返回ThreadContext中的Map容器。

返回:
the context map。

getException

public static Exception getException()
Get the exception.

返回:
the exception

setException

public static void setException(Exception exception)
Store the exception.

参数:
exception - The exception


Copyright © 2017. All rights reserved.