org.modeshape.jcr
Class JndiRepositoryFactory
java.lang.Object
org.modeshape.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.modeshape.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.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
protected static final Logger log
JndiRepositoryFactory
public JndiRepositoryFactory()
getObjectInstance
public JcrRepository getObjectInstance(Object obj,
Name name,
Context nameCtx,
Hashtable<?,?> environment)
throws IOException,
SAXException,
javax.jcr.RepositoryException,
NamingException
- 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
- Parameters:
obj - the reference to the JNDI configuration information; must be a non-null instance of Referencename - ignorednameCtx - ignoredenvironment - 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.