eXo JCR :: Component :: Extension Service 1.16.0-CR2

org.exoplatform.services.jcr.ext.common
Class SessionProvider

java.lang.Object
  extended by org.exoplatform.services.jcr.ext.common.SessionProvider
All Implemented Interfaces:
SessionLifecycleListener

public class SessionProvider
extends Object
implements 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

Field Summary
static String SESSION_PROVIDER
          Constant for handlers.
 
Constructor Summary
SessionProvider(org.exoplatform.services.security.ConversationState userState)
          Creates SessionProvider for certain identity.
 
Method Summary
 void close()
          Calls logout() method for all cached sessions.
static SessionProvider createAnonimProvider()
          Helper for creating Anonymous session provider.
static SessionProvider createProvider(List<AccessControlEntry> accessList)
          Gives a SessionProvider for a given list of AccessControlEntry.
static SessionProvider createSystemProvider()
          Helper for creating System session provider.
 ManageableRepository getCurrentRepository()
           
 String getCurrentWorkspace()
           
 javax.jcr.Session getSession(String workspaceName, 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.
 void onCloseSession(ExtendedSession session)
           
 void setCurrentRepository(ManageableRepository currentRepository)
          Sets the current repository Repository.
 void setCurrentWorkspace(String currentWorkspace)
          Sets the current Workspace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_PROVIDER

public static final String SESSION_PROVIDER
Constant for handlers.

See Also:
Constant Field Values
Constructor Detail

SessionProvider

public SessionProvider(org.exoplatform.services.security.ConversationState userState)
Creates SessionProvider for certain identity.

Parameters:
userState -
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<AccessControlEntry> accessList)
Gives a SessionProvider for a given list of AccessControlEntry.

Parameters:
accessList - list of AccessControlEntry
Returns:
a SessionProvider allowing to provide sessions with the corresponding ACL.

getSession

public javax.jcr.Session getSession(String workspaceName,
                                    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 name
repository - 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 workspace
javax.jcr.NoSuchWorkspaceException - if the requested workspace doesn't exist
javax.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(ExtendedSession session)
Specified by:
onCloseSession in interface SessionLifecycleListener

getCurrentRepository

public ManageableRepository getCurrentRepository()
Returns:
returns the current Repository

getCurrentWorkspace

public String getCurrentWorkspace()
Returns:
returns the current Workspace

setCurrentRepository

public void setCurrentRepository(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

eXo JCR :: Component :: Extension Service 1.16.0-CR2

Copyright © 2014 eXo Platform SAS. All Rights Reserved.