public class JndiRepositoryFactory extends Object implements ObjectFactory
JndiRepositoryFactory
class provides a means of initializing and accessing repositories
in a
JNDI tree.
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="/path/to/repository-config.json" repositoryName="Test Repository Source" /> </GlobalNamingResources>This will create a repository loaded from the or file "/path/to/configRepository.json" and return the JCR repository named "Test Repository Source". The name of the repository will be used to more quickly look up the repository if it has been previously loaded.
Note that if the "repositoryName" property is not specified or is empty, the factory will register the ModeShape engine at the
supplied location in JNDI. This approach is compatible with the traditional JNDI URLs used with the
JCR 2.0-style RepositoryFactory
.
Constructor and Description |
---|
JndiRepositoryFactory() |
Modifier and Type | Method and Description |
---|---|
Object |
getObjectInstance(Object obj,
Name name,
Context nameCtx,
Hashtable<?,?> environment)
Creates an
JcrRepository or ModeShape engine using the reference information specified. |
protected Set<String> |
parseStrings(String value) |
protected static final Logger LOG
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) throws IOException, SAXException, RepositoryException, NamingException
JcrRepository
or ModeShape engine 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 ModeShapeEngine
will be created (if not previously created by a call to this
method) and it will be configured from the resource or file at the location specified by the configFile
key in the
reference. After the configuration is successful, the ModeShapeEngine
will be
queried} for the repository with the name specified by the value of the @{code repositoryName} key in the reference.
getObjectInstance
in interface ObjectFactory
obj
- the reference to the JNDI configuration information; must be a non-null instance of Reference
name
- the name of the objectnameCtx
- used to register the ModeShape engine when no repository name is provided in the Reference objenvironment
- ignoredIOException
- if there is an error or problem reading the configuration resource at the supplied pathSAXException
- if the contents of the configuration resource are not valid XMLNamingException
- if there is an error registering the namespace listenerRepositoryException
- if the ModeShapeEngine could not be started
, the named
repository does not exist in the given configuration resource, or the named repository could not be createdCopyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.