org.exoplatform.forum.common.jcr
Class JCRSessionManager

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

public class JCRSessionManager
extends Object
implements SessionManager

Created by The eXo Platform SAS Author : eXoPlatform exo@exoplatform.com Oct 16, 2009


Constructor Summary
JCRSessionManager(String workspace)
           
JCRSessionManager(String workspace, org.exoplatform.services.jcr.RepositoryService repositoryService)
          Constructor
 
Method Summary
 boolean closeSession()
          Closes the current session and discard the changes done during the session.
 boolean closeSession(boolean save)
          Closes the current session and optionally saves its content.
 javax.jcr.Session createSession()
          Create a new Session
static javax.jcr.Session currentSession()
           
<T> T
execute(JCRTask<T> jcrTask)
          Execute a readonly jcr task.
<T> T
executeAndSave(JCRTask<T> jcrTask)
          Execute an jcr task and persists the changes.
 javax.jcr.Session getCurrentSession()
          Returns the session currently associated with the current thread of execution.
The current session is set with openSession()
 javax.jcr.Session getSession(org.exoplatform.services.jcr.ext.common.SessionProvider sessionProvider)
          This method is here for backward compatibility, but will be removed to get rid of SessionProvider
 String getWorkspaceName()
           
 javax.jcr.Session openSession()
          Open and returns a session to the model.
 void setWorkspaceName(String workspaceName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCRSessionManager

public JCRSessionManager(String workspace,
                         org.exoplatform.services.jcr.RepositoryService repositoryService)
Constructor

Parameters:
workspace -
repositoryService -

JCRSessionManager

public JCRSessionManager(String workspace)
Method Detail

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.

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:
SessionManager.closeSession(boolean)

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:


Copyright © 2013 eXo Platform SAS. All Rights Reserved.