Class JCRSessionManager

java.lang.Object
org.exoplatform.forum.common.jcr.JCRSessionManager
All Implemented Interfaces:
SessionManager

public class JCRSessionManager extends Object implements SessionManager
  • Constructor Details

    • JCRSessionManager

      public JCRSessionManager(String workspace)
      Constructor
      Parameters:
      workspace -
  • Method Details

    • getWorkspaceName

      public String getWorkspaceName()
    • setWorkspaceName

      public void setWorkspaceName(String workspaceName)
    • getCurrentSession

      public javax.jcr.Session getCurrentSession()

      Returns the session currently associated with the current thread of execution.
      The current session is set with openSession()

      Specified by:
      getCurrentSession in interface SessionManager
      Returns:
      the current session if exists, null otherwise
    • currentSession

      public static javax.jcr.Session currentSession()
    • getSession

      public javax.jcr.Session getSession(org.exoplatform.services.jcr.ext.common.SessionProvider sessionProvider)
      Description copied from interface: SessionManager
      This method is here for backward compatibility, but will be removed to get rid of SessionProvider
      Specified by:
      getSession in interface SessionManager
      Returns:
    • openSession

      public javax.jcr.Session openSession()

      Open and returns a session to the model. When the current thread is already associated with a previously opened session the method will throw an IllegalStateException.

      Specified by:
      openSession in interface SessionManager
      Returns:
      a session to the model.
    • openOrReuseSession

      public javax.jcr.Session openOrReuseSession()
    • createSession

      public javax.jcr.Session createSession()
      Description copied from interface: SessionManager
      Create a new Session
      Specified by:
      createSession in interface SessionManager
      Returns:
    • closeSession

      public boolean closeSession()
      Description copied from interface: SessionManager

      Closes the current session and discard the changes done during the session.

      Specified by:
      closeSession in interface SessionManager
      Returns:
      a boolean indicating if the session was closed
      See Also:
    • closeSession

      public boolean closeSession(boolean save)
      Description copied from interface: SessionManager

      Closes the current session and optionally saves its content. If no session is associated then this method has no effects and returns false.

      Specified by:
      closeSession in interface SessionManager
      Parameters:
      save - if the session must be saved
      Returns:
      a boolean indicating if the session was closed
    • executeAndSave

      public <T> T executeAndSave(JCRTask<T> jcrTask)
      Description copied from interface: SessionManager
      Execute an jcr task and persists the changes. A Session.save() is called on the current at the end.
      Specified by:
      executeAndSave in interface SessionManager
      Returns:
    • execute

      public <T> T execute(JCRTask<T> jcrTask)
      Description copied from interface: SessionManager
      Execute a readonly jcr task. No Session.save()is called on the current session after the call.
      Specified by:
      execute in interface SessionManager
      Returns: