Class JndiRepositoryFactory

  extended by org.jboss.dna.jcr.JndiRepositoryFactory
All Implemented Interfaces:

public class JndiRepositoryFactory
extends Object
implements ObjectFactory

The JndiRepositoryFactory class provides a means of initializing and accessing repositories in a JNDI tree.

Example JNDI Configurations

Tomcat 5.5

The following configuration can be added to added to server.xml in Tomcat 5.5 to initialize a JcrRepository and add it to the JNDI tree.

         <!-- Other configuration omitted -->
      <Resource name="jcr/local" auth="Container"
           repositoryName="Test Repository Source"
This will create a repository loaded from the resource "/tck/default/configRepository.xml" (which must be accessible through the classpath) and return the JCR repository named "Test Repository Source". The name of the repository is important as a single configuration file may contain configuration information for many JCR repositories.

Constructor Summary
Method Summary
 JcrRepository getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)
          Creates an JcrRepository using the reference information specified.
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public JndiRepositoryFactory()
Method Detail


public JcrRepository getObjectInstance(Object obj,
                                       Name name,
                                       Context nameCtx,
                                       Hashtable<?,?> environment)
                                throws IOException,
Creates an JcrRepository using the reference information specified.

This method first attempts to convert the obj parameter into a reference to JNDI configuration information. If that is successful, a JcrEngine will be created (if not previously created by a call to this method) and it will be configured from the resource at the location specified by the configFile key in the reference. After the configuration is successful, the JcrEngine will be queried for the repository with the name specified by the value of the @{code repositoryName} key in the reference.

Specified by:
getObjectInstance in interface ObjectFactory
obj - the reference to the JNDI configuration information; must be a non-null instance of Reference
name - ignored
nameCtx - ignored
environment - ignored
the repository; never null
IOException - if there is an error or problem reading the configuration resource at the supplied path
SAXException - if the contents of the configuration resource are not valid XML
NamingException - if there is an error registering the namespace listener
javax.jcr.RepositoryException - if the JcrEngine could not be started, the named repository does not exist in the given configuration resource, or the named repository could not be created

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