Package net.jrouter.http.servlet
Class ServletThreadContext
java.lang.Object
net.jrouter.http.servlet.ServletThreadContext
ServletThreadContext是一个线程变量,使用了一个公共的
ThreadLocal。
ServletThreadContext包含一个ActionInvocation,存储线程安全的Action运行时上下文。
ServletThreadContext包含http的相关的变量。 ServletThreadContext包含一个contextMap变量,存储自定义的key-value。
ServletThreadContext包含一个Exception对象,存储发生的异常。-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends net.jrouter.ActionInvocation>
T返回Action运行时上下文。返回ThreadContext中的Map容器。static ExceptionGet the exception.static jakarta.servlet.http.HttpServletRequestGets the HTTP servlet request object.static jakarta.servlet.http.HttpServletResponseGets the HTTP servlet response object.static jakarta.servlet.ServletContextGets the servlet context.static jakarta.servlet.http.HttpSessionGets the HTTP servlet session object.static jakarta.servlet.http.HttpSessiongetSession(boolean create) Gets the HTTP servlet session object.static voidremove()移除前线程副本中的ServletThreadContext。static voidsetActionInvocation(net.jrouter.ActionInvocation<?> actionInvocation) 设置Action运行时上下文。static voidsetException(Exception exception) Store the exception.static voidsetRequest(jakarta.servlet.http.HttpServletRequest request) Sets the HTTP servlet request object.static voidsetResponse(jakarta.servlet.http.HttpServletResponse response) Sets the HTTP servlet response object.static voidsetServletContext(jakarta.servlet.ServletContext servletContext) Sets the current servlet context object.
-
Method Details
-
remove
public static void remove()移除前线程副本中的ServletThreadContext。 -
getActionInvocation
public static <T extends net.jrouter.ActionInvocation> T getActionInvocation()返回Action运行时上下文。- Type Parameters:
T- Action运行时上下文类型。- Returns:
- Action运行时上下文。
- See Also:
-
setActionInvocation
public static void setActionInvocation(net.jrouter.ActionInvocation<?> actionInvocation) 设置Action运行时上下文。- Parameters:
actionInvocation- Action运行时上下文。
-
getRequest
public static jakarta.servlet.http.HttpServletRequest getRequest()Gets the HTTP servlet request object.- Returns:
- the HTTP servlet request object.
-
setRequest
public static void setRequest(jakarta.servlet.http.HttpServletRequest request) Sets the HTTP servlet request object.- Parameters:
request- the HTTP servlet request object.
-
getSession
public static jakarta.servlet.http.HttpSession getSession()Gets the HTTP servlet session object.- Returns:
- the HTTP servlet session object.
-
getSession
public static jakarta.servlet.http.HttpSession getSession(boolean create) Gets the HTTP servlet session object.- Parameters:
create-trueto create a new session for this request if necessary;falseto returnnullif there's no current session- Returns:
- the HTTP servlet session object.
-
getResponse
public static jakarta.servlet.http.HttpServletResponse getResponse()Gets the HTTP servlet response object.- Returns:
- the HTTP servlet response object.
-
setResponse
public static void setResponse(jakarta.servlet.http.HttpServletResponse response) Sets the HTTP servlet response object.- Parameters:
response- the HTTP servlet response object.
-
getServletContext
public static jakarta.servlet.ServletContext getServletContext()Gets the servlet context.- Returns:
- the servlet context.
-
setServletContext
public static void setServletContext(jakarta.servlet.ServletContext servletContext) Sets the current servlet context object.- Parameters:
servletContext- The servlet context to use
-
getContextMap
返回ThreadContext中的Map容器。- Returns:
- the context map。
-
getException
Get the exception.- Returns:
- the exception
-
setException
Store the exception.- Parameters:
exception- The exception
-