|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.repository.util.AbstractSessionFactory
public abstract class AbstractSessionFactory
A SessionFactory implementation that creates Session
instances using Repository
instances.
This factory using a naming convention where the name supplied to the createSession(String)
contains both the name of
the repository and the name of the workspace. Typically, this is repositoryName/workspaceName
, where
repositoryName
is the name under which the Repository instance was bound, and workspaceName
is the
name of the workspace. Note that this method looks for the last delimiter in the whole name to distinguish between the
repository and workspace names.
For example, if "java:comp/env/repository/dataRepository/myWorkspace
" is passed to the
createSession(String)
method, this factory will look for a Repository
instance registered with the name "
java:comp/env/repository/dataRepository
" and use it to create a session
to the
workspace named "myWorkspace
".
By default, this factory creates an anonymous JCR session. To use sessions with specific Credentials
, simply
register
credentials for the appropriate repository/workspace name. For
security reasons, it is not possible to retrieve the Credentials once registered with this factory.
Field Summary | |
---|---|
protected static char[] |
DEFAULT_DELIMITERS
|
Constructor Summary | |
---|---|
AbstractSessionFactory()
Create an instance of the factory with the default delimiters. |
|
AbstractSessionFactory(char... workspaceDelimiters)
Create an instance of the factory by supplying naming context and the characters that may be used to delimit the workspace name from the repository name. |
Method Summary | |
---|---|
javax.jcr.Session |
createSession(String name)
|
protected abstract void |
doRegisterRepository(String name,
javax.jcr.Repository repository)
|
protected abstract void |
doUnregisterRepository(String name)
|
protected abstract javax.jcr.Repository |
findRegisteredRepository(String name)
|
protected int |
getIndexOfLastWorkspaceDelimiter(String name)
|
protected String |
getRepositoryName(String name)
|
protected String |
getWorkspaceName(String name)
|
boolean |
registerCredentials(String name,
javax.jcr.Credentials credentials)
Register the credentials to be used for the named repository and workspace. |
boolean |
registerCredentials(String name,
String username,
char[] password)
Register the credentials for the repository and workspace given by the supplied name, username and password. |
void |
registerRepository(String name,
javax.jcr.Repository repository)
Convenience method to bind a repository in JNDI. |
boolean |
removeCredentials(String name)
Remove any credentials associated with the named repository and workspace. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static char[] DEFAULT_DELIMITERS
Constructor Detail |
---|
public AbstractSessionFactory()
public AbstractSessionFactory(char... workspaceDelimiters)
workspaceDelimiters
- the delimiters, or null/empty if the default delimiter of '/' should be used.
IllegalArgumentException
- if the context parameter is nullMethod Detail |
---|
public void registerRepository(String name, javax.jcr.Repository repository)
name
- the name of the repository, without the workspace name component.repository
- the repository to be bound, or null if an existing repository should be unbound.protected abstract void doRegisterRepository(String name, javax.jcr.Repository repository) throws SystemFailureException
SystemFailureException
protected abstract void doUnregisterRepository(String name) throws SystemFailureException
SystemFailureException
protected abstract javax.jcr.Repository findRegisteredRepository(String name) throws SystemFailureException
SystemFailureException
public boolean registerCredentials(String name, String username, char[] password)
registerCredentials(name, new SimpleCredentials(username,password))
, although if
username
is null then this is equivalent to registerCredentials(name,null)
.
name
- the name of the repository and workspaceusername
- the username to use, or null if the existing credentials for the named workspace should be removedpassword
- the password, may be null or empty
registerCredentials(String, Credentials)
,
removeCredentials(String)
public boolean registerCredentials(String name, javax.jcr.Credentials credentials)
create sessions
.
name
- the name of the repository and workspacecredentials
- the credentials to use, or null if the existing credentials for the named workspace should be removed
registerCredentials(String, String, char[])
,
removeCredentials(String)
public boolean removeCredentials(String name)
registerCredentials(name,null)
.
name
- the name of the repository and workspace
registerCredentials(String, Credentials)
public javax.jcr.Session createSession(String name) throws javax.jcr.RepositoryException
createSession
in interface SessionFactory
javax.jcr.RepositoryException
protected String getWorkspaceName(String name)
protected String getRepositoryName(String name)
protected int getIndexOfLastWorkspaceDelimiter(String name)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |