Class SessionManager


  • class SessionManager
    extends java.lang.Object
    The SessionManager is used to manage the sessions that are used during the serialization process. Sessions are stored in thread locals so that should a Converter delegate back in to the same persister instance, it will acquire the same session object. This ensures that converters can be used to resolve cycles in the object graph with the CycleStrategy and also ensures there is no overhead creating new session objects.
    See Also:
    Session
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  SessionManager.Reference
      The Reference object is used to store sessions and count references to them.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.ThreadLocal<SessionManager.Reference> local
      This is the thread local used to store the sessions objects.
    • Constructor Summary

      Constructors 
      Constructor Description
      SessionManager()
      Constructor for the SessionManager object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      This is used to close the session on the thread local.
      private Session create​(boolean strict)
      This is used to create a new Session object.
      Session open()
      This is used to open a new Session object.
      Session open​(boolean strict)
      This is used to open a new Session object.
      • Methods inherited from class java.lang.Object

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

      • local

        private java.lang.ThreadLocal<SessionManager.Reference> local
        This is the thread local used to store the sessions objects.
    • Constructor Detail

      • SessionManager

        public SessionManager()
        Constructor for the SessionManager object. This is used to create a session manager that stores sessions in a thread local so that it can be reused on multiple invocations to the Persister object. References are maintained to each session created so that it is closed when there are no longer any more references to the session.
    • Method Detail

      • open

        public Session open()
                     throws java.lang.Exception
        This is used to open a new Session object. If the session exists within the thread local it is returned and a reference count to the session is increased. This ensures that the session is not disposed of until all references to it are closed. By default this creates a strict session.
        Returns:
        this returns a strict session from the manager
        Throws:
        java.lang.Exception
      • open

        public Session open​(boolean strict)
                     throws java.lang.Exception
        This is used to open a new Session object. If the session exists within the thread local it is returned and a reference count to the session is increased. This ensures that the session is not disposed of until all references to it are closed. The strictness of the session can be specified.
        Parameters:
        strict - this determines if the session is strict
        Returns:
        this returns a session from the manager
        Throws:
        java.lang.Exception
      • create

        private Session create​(boolean strict)
                        throws java.lang.Exception
        This is used to create a new Session object. On creation of the session it is placed on a thread local so that it can be acquired by the current thread when required.
        Parameters:
        strict - this determines if the session is strict
        Returns:
        this returns a new session from the manager
        Throws:
        java.lang.Exception
      • close

        public void close()
                   throws java.lang.Exception
        This is used to close the session on the thread local. If the session still has references to it then the reference count is decreased and the session remains open. This ensures that we can make recursive calls in to the Persister and still use the same session object.
        Throws:
        java.lang.Exception