org.jboss.dna.jcr
Class JndiRepositoryFactory
java.lang.Object
   org.jboss.dna.jcr.JndiRepositoryFactory
org.jboss.dna.jcr.JndiRepositoryFactory
- All Implemented Interfaces: 
- ObjectFactory
- 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.
 
 
   <GlobalNamingResources>
         <!-- Other configuration omitted -->
      <Resource name="jcr/local" auth="Container"
           type="javax.jcr.Repository"
           factory="org.jboss.dna.jcr.JndiRepositoryFactory"
           configFile="/tck/default/configRepository.xml"
           repositoryName="Test Repository Source"
           />
   </GlobalNamingResources>
 
 
 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.
 
 
 
 
JndiRepositoryFactory
public JndiRepositoryFactory()
getObjectInstance
public JcrRepository getObjectInstance(Object obj,
                                       Name name,
                                       Context nameCtx,
                                       Hashtable<?,?> environment)
                                throws IOException,
                                       SAXException,
                                       javax.jcr.RepositoryException,
                                       NamingException
- Creates an JcrRepositoryusing the reference information specified.
 This method first attempts to convert the objparameter into areference to JNDI configuration
 information. If that is successful, aJcrEnginewill 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 theconfigFilekey in the
 reference. After the configuration is successful, theJcrEngine will be queriedfor
 the repository with the name specified by the value of the @{code repositoryName} key in the reference.
 
 
- 
- Specified by:
- getObjectInstancein interface- ObjectFactory
 
- 
- Parameters:
- obj- the reference to the JNDI configuration information; must be a non-null instance of- Reference
- name- ignored
- nameCtx- ignored
- environment- ignored
- Returns:
- the repository; never null
- Throws:
- 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.