Class Sessions

java.lang.Object
org.zkoss.zk.ui.Sessions
Direct Known Subclasses:
SessionsCtrl

public class Sessions extends Object
Utilities to access Session.
Author:
tomyeh
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static int
     
    protected static final ThreadLocal<Object>
    Used to the store the session for the current thread.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final int
    Returns the number of total alive session.
    static final Session
    Returns the session for the current thread, or null if not available.
    static final Session
    getCurrent(boolean create)
    Returns the session for the current thread, or null if not available.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _sess

      protected static final ThreadLocal<Object> _sess
      Used to the store the session for the current thread.
    • _cnt

      protected static int _cnt
  • Constructor Details

    • Sessions

      protected Sessions()
  • Method Details

    • getCount

      public static final int getCount()
      Returns the number of total alive session.
      Since:
      5.0.0
    • getCurrent

      public static final Session getCurrent()
      Returns the session for the current thread, or null if not available. It is the same as getSession(true).

      Note: it returns null if it is called in a working thread.

    • getCurrent

      public static final Session getCurrent(boolean create)
      Returns the session for the current thread, or null if not available.
      Parameters:
      create - whether to create a new session if not available. Notice that this method might return null if it is called in a working thread, even though create is true,
      Since:
      5.0.0