Class ThreadLocalSessionHolder

java.lang.Object
org.tentackle.session.ThreadLocalSessionHolder
All Implemented Interfaces:
Serializable, SessionHolder

public class ThreadLocalSessionHolder extends Object implements SessionHolder
A session holder returning the thread-local session.
Nice if no domain context available, e.g. for low-level AbstractDbObjects.
Author:
harald
See Also:
  • Constructor Details

    • ThreadLocalSessionHolder

      public ThreadLocalSessionHolder()
      Creates a thread-local session holder.
  • Method Details

    • getSession

      public Session getSession()
      Description copied from interface: SessionHolder
      Gets the session.
      The thread-local session is returned if the session is null.
      Specified by:
      getSession in interface SessionHolder
      Returns:
      the session.
    • setSession

      public void setSession(Session session)
      Description copied from interface: SessionHolder
      Sets the session.
      Specified by:
      setSession in interface SessionHolder
      Parameters:
      session - the session, null if thread-local
    • isSessionThreadLocal

      public boolean isSessionThreadLocal()
      Description copied from interface: SessionHolder
      Returns whether the session is thread-local.
      Specified by:
      isSessionThreadLocal in interface SessionHolder
      Returns:
      true if thread-local
    • setSessionImmutable

      public void setSessionImmutable(boolean sessionImmutable)
      Description copied from interface: SessionHolder
      Sets the session to immutable.
      Specified by:
      setSessionImmutable in interface SessionHolder
      Parameters:
      sessionImmutable - true if session cannot be changed anymore
    • isSessionImmutable

      public boolean isSessionImmutable()
      Description copied from interface: SessionHolder
      Returns whether the session is immutable.
      Specified by:
      isSessionImmutable in interface SessionHolder
      Returns:
      true if immutable
    • getSessionInfo

      public SessionInfo getSessionInfo()
      Description copied from interface: SessionHolder
      Gets the session info associated to the session.
      Specified by:
      getSessionInfo in interface SessionHolder
      Returns:
      the session info
    • getSessionInstanceNumber

      public int getSessionInstanceNumber()
      Description copied from interface: SessionHolder
      Gets the unique instance number of the Session.

      Delegating getSession().getInstanceNumber() to getSessionInstanceNumber allows to override getSession and dynamically retrieve the thread's session without changing the sorting order.

      Specified by:
      getSessionInstanceNumber in interface SessionHolder
      Returns:
      the session's instance number