Class ThreadLocalSessionHolder

  • All Implemented Interfaces:
    java.io.Serializable, SessionHolder

    public class ThreadLocalSessionHolder
    extends java.lang.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:
    Serialized Form
    • Constructor Detail

      • ThreadLocalSessionHolder

        public ThreadLocalSessionHolder()
    • Method Detail

      • getSession

        public Session getSession()
        Description copied from interface: SessionHolder
        Gets the session.
        The threadlocal 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 threadlocal
      • 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 threadlocal
      • 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
        The SessionInfo extends the UserInfo by a SecurityManager.
        Specified by:
        getSessionInfo in interface SessionHolder
        Returns:
        the SessionInfo associated to the Db.
      • 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