Class SessionProvider
- java.lang.Object
-
- org.exoplatform.services.jcr.ext.common.SessionProvider
-
- All Implemented Interfaces:
org.exoplatform.services.jcr.core.SessionLifecycleListener
public class SessionProvider extends Object implements org.exoplatform.services.jcr.core.SessionLifecycleListener
Created by The eXo Platform SAS
Provides JCR Session for client program. Usually it is per client thread object Session creates with Repository.login(..) method and then can be stored in some cache if neccessary.- Version:
- $Id: SessionProvider.java 34445 2009-07-24 07:51:18Z dkatayev $
- Author:
- Gennady Azarenkov
- eXo level API
- Platform
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.exoplatform.services.log.LogLOGstatic StringSESSION_PROVIDERConstant for handlers.
-
Constructor Summary
Constructors Constructor Description SessionProvider(org.exoplatform.services.security.ConversationState userState)Creates SessionProvider for certain identity.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Calls logout() method for all cached sessions.static SessionProvidercreateAnonimProvider()Helper for creating Anonymous session provider.static SessionProvidercreateProvider(List<org.exoplatform.services.jcr.access.AccessControlEntry> accessList)Gives aSessionProviderfor a given list ofAccessControlEntry.static SessionProvidercreateSystemProvider()Helper for creating System session provider.org.exoplatform.services.jcr.core.ManageableRepositorygetCurrentRepository()StringgetCurrentWorkspace()javax.jcr.SessiongetSession(String workspaceName, org.exoplatform.services.jcr.core.ManageableRepository repository)Gets the session from an internal cache if a similar session has already been used or creates a new session and puts it into the internal cache.voidonCloseSession(org.exoplatform.services.jcr.core.ExtendedSession session)voidsetCurrentRepository(org.exoplatform.services.jcr.core.ManageableRepository currentRepository)Sets the current repository Repository.voidsetCurrentWorkspace(String currentWorkspace)Sets the current Workspace
-
-
-
Field Detail
-
LOG
protected static final org.exoplatform.services.log.Log LOG
-
SESSION_PROVIDER
public static final String SESSION_PROVIDER
Constant for handlers.- See Also:
- Constant Field Values
-
-
Method Detail
-
createSystemProvider
public static SessionProvider createSystemProvider()
Helper for creating System session provider.- Returns:
- a system session provider
-
createAnonimProvider
public static SessionProvider createAnonimProvider()
Helper for creating Anonymous session provider.- Returns:
- an anonymous session provider
-
createProvider
public static SessionProvider createProvider(List<org.exoplatform.services.jcr.access.AccessControlEntry> accessList)
Gives aSessionProviderfor a given list ofAccessControlEntry.- Parameters:
accessList- list ofAccessControlEntry- Returns:
- a
SessionProviderallowing to provide sessions with the corresponding ACL.
-
getSession
public javax.jcr.Session getSession(String workspaceName, org.exoplatform.services.jcr.core.ManageableRepository repository) throws javax.jcr.LoginException, javax.jcr.NoSuchWorkspaceException, javax.jcr.RepositoryException
Gets the session from an internal cache if a similar session has already been used or creates a new session and puts it into the internal cache.- Parameters:
workspaceName- the workspace namerepository- the repository instance- Returns:
- a session corresponding to the given repository and workspace
- Throws:
javax.jcr.LoginException- if an error occurs while trying to login to the workspacejavax.jcr.NoSuchWorkspaceException- if the requested workspace doesn't existjavax.jcr.RepositoryException- if any error occurs
-
close
public void close()
Calls logout() method for all cached sessions. Session will be removed from cache by the listener (this provider) via ExtendedSession.logout().
-
onCloseSession
public void onCloseSession(org.exoplatform.services.jcr.core.ExtendedSession session)
- Specified by:
onCloseSessionin interfaceorg.exoplatform.services.jcr.core.SessionLifecycleListener
-
getCurrentRepository
public org.exoplatform.services.jcr.core.ManageableRepository getCurrentRepository()
- Returns:
- returns the current Repository
-
getCurrentWorkspace
public String getCurrentWorkspace()
- Returns:
- returns the current Workspace
-
setCurrentRepository
public void setCurrentRepository(org.exoplatform.services.jcr.core.ManageableRepository currentRepository)
Sets the current repository Repository.- Parameters:
currentRepository- the current repository
-
setCurrentWorkspace
public void setCurrentWorkspace(String currentWorkspace)
Sets the current Workspace- Parameters:
currentWorkspace- the current workspace
-
-