类 SessionManager

java.lang.Object
org.xmeta.ui.session.SessionManager
直接已知子类:
DefaultSessionManager

public abstract class SessionManager
extends Object
会话管理者,表示的是UI交互中的会话,还需进一步设计。 一个系统里可能会存在多种会话环境,比如HTTP,NETTY,RAP等等,判断当前属于哪一种会话的方法如下: 1.是否设置了ThreadLocal<SessionManager>,如HTTP和NETTY的情况。 2.遍历所有已注册的SessionManager,当有SessionManager.accept(actionContext)时使用。 3.使用默认的defaultSessionManager。
作者:
zyx
  • 构造器详细资料

  • 方法详细资料

    • getSession

      public static Session getSession​(ActionContext actionContext)
      获取默认环境的会话,是本地会话,公用一个Session。
      参数:
      actionContext - 上下文
      返回:
      会话
    • remove

      public static Session remove​(ActionContext actionContext)
    • registSessionManager

      public static void registSessionManager​(SessionManager sessionManager)
    • getSessionManagers

      public static List<SessionManager> getSessionManagers()
    • getSessionManager

      public static SessionManager getSessionManager​(ActionContext actionContext)
      根据环境返回会话管理器,如果不存在返回默认的会话管理器。 1.先从ThreadLocal中获取会话。 2.其次注册的会话管理器列表中判断,如果会话管理器接受上下文那么返回。 3.返回默认的会话管理器。
      参数:
      actionContext - 变量上下文
      返回:
      会话管理器
    • pushLocalSessionManager

      public static void pushLocalSessionManager​(SessionManager sessionManager)
      设置当前线程的会话管理器。 注意,必须在finally里中
      参数:
      sessionManager - 会话管理器
    • associateWith

      public static Runnable associateWith​(Runnable runnable)
      包装一个Runnable,当它执行时使用当前线程的最后的一个SessionManager。
      参数:
      runnable - Runnable
      返回:
      包装后的Runnable
    • associateWith

      public static Callable<?> associateWith​(Callable<?> callable)
      包装一个Callable,当它运行时使用当前线程的最后一个SessionManager。
      参数:
      callable - Callable
      返回:
      包装后Callable
    • popLocalSessionManager

      public static void popLocalSessionManager()
      弹出当前线程的会话管理器。
    • getDefaultSessionManager

      public static SessionManager getDefaultSessionManager()
      返回默认的会话管理器。
      返回:
      默认会话管理器
    • get

      public abstract Session get​(ActionContext actionContext)
      获取一个指定的会话,其中name可以为null,如果Session不存在那么创建一个。。
      参数:
      actionContext - 变量上下文
      返回:
      会话
    • delete

      public abstract Session delete​(ActionContext actionContext)
      删除当前会话。
      参数:
      actionContext - 变量上下文
      返回:
      会话
    • accept

      public abstract boolean accept​(ActionContext actionContext)
      是否接受当前环境,即会话管理器是否是当前环境的会话管理器。
      参数:
      actionContext - 变量上下文
      返回:
      返回是否能够管理Session