Class ServletThreadContext

java.lang.Object
net.jrouter.http.servlet.ServletThreadContext

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

    Modifier and Type
    Method
    Description
    static <T extends net.jrouter.ActionInvocation>
    T
    返回Action运行时上下文。
    static <T> Map<String,T>
    返回ThreadContext中的Map容器。
    static Exception
    Get the exception.
    static jakarta.servlet.http.HttpServletRequest
    Gets the HTTP servlet request object.
    static jakarta.servlet.http.HttpServletResponse
    Gets the HTTP servlet response object.
    static jakarta.servlet.ServletContext
    Gets the servlet context.
    static jakarta.servlet.http.HttpSession
    Gets the HTTP servlet session object.
    static jakarta.servlet.http.HttpSession
    getSession(boolean create)
    Gets the HTTP servlet session object.
    static void
    移除前线程副本中的ServletThreadContext。
    static void
    setActionInvocation(net.jrouter.ActionInvocation<?> actionInvocation)
    设置Action运行时上下文。
    static void
    Store the exception.
    static void
    setRequest(jakarta.servlet.http.HttpServletRequest request)
    Sets the HTTP servlet request object.
    static void
    setResponse(jakarta.servlet.http.HttpServletResponse response)
    Sets the HTTP servlet response object.
    static void
    setServletContext(jakarta.servlet.ServletContext servletContext)
    Sets the current servlet context object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 - true to create a new session for this request if necessary; false to return null if 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

      public static <T> Map<String,T> getContextMap()
      返回ThreadContext中的Map容器。
      Returns:
      the context map。
    • getException

      public static Exception getException()
      Get the exception.
      Returns:
      the exception
    • setException

      public static void setException(Exception exception)
      Store the exception.
      Parameters:
      exception - The exception