org.jboss.dna.repository.util
Class JndiSessionFactory

java.lang.Object
  extended by org.jboss.dna.repository.util.AbstractSessionFactory
      extended by org.jboss.dna.repository.util.JndiSessionFactory
All Implemented Interfaces:
SessionFactory

public class JndiSessionFactory
extends AbstractSessionFactory

A SessionFactory implementation that creates Session instances using Repository instances registered in JNDI.

This factory using a naming convention where the name supplied to the AbstractSessionFactory.createSession(String) contains both the name of the repository and the name of the workspace. Typically, this is repositoryName/workspaceName, where repositoryName is the JNDI 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 AbstractSessionFactory.createSession(String) method, this factory will look for a Repository instance registered in JDNI 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.

Author:
Randall Hauch

Constructor Summary
JndiSessionFactory()
          Create an instance of the factory by creating a new InitialContext.
JndiSessionFactory(char... workspaceDelimiters)
          Create an instance of the factory by supplying the characters that may be used to delimit the workspace name from the repository name.
JndiSessionFactory(Context context)
          Create an instance of the factory using the supplied JNDI context.
JndiSessionFactory(Context context, 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
 
Methods inherited from class org.jboss.dna.repository.util.AbstractSessionFactory
createSession, registerCredentials, registerCredentials, registerRepository, removeCredentials
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JndiSessionFactory

public JndiSessionFactory()
                   throws NamingException
Create an instance of the factory by creating a new InitialContext. This is equivalent to calling new JndiSessionFactory(new InitialContext()).

Throws:
NamingException - if there is a problem creating the InitialContext.

JndiSessionFactory

public JndiSessionFactory(char... workspaceDelimiters)
                   throws NamingException
Create an instance of the factory by supplying the characters that may be used to delimit the workspace name from the repository name. This constructor initializes the factory with a new InitialContext, and is equivalent to calling new JndiSessionFactory(new InitialContext(),workspaceDelimiters).

Parameters:
workspaceDelimiters - the delimiters, or null/empty if the default delimiter of '/' should be used.
Throws:
NamingException - if there is a problem creating the InitialContext.

JndiSessionFactory

public JndiSessionFactory(Context context)
Create an instance of the factory using the supplied JNDI context.

Parameters:
context - the naming context
Throws:
IllegalArgumentException - if the context parameter is null

JndiSessionFactory

public JndiSessionFactory(Context context,
                          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.

Parameters:
context - the naming context
workspaceDelimiters - the delimiters, or null/empty if the default delimiter of '/' should be used.
Throws:
IllegalArgumentException - if the context parameter is null


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.