17.29. Repository Providers
The ModeShape REST and ModeShape WebDAV servers can provide access to other JCR repositories by implementing the org.modeshape.web.jcr.spi.RepositoryProvider interface.
There are four methods defined by the RepositoryProvider interface:
startup
, getJcrRepositoryNames
, getSession
and shutdown
. When org.modeshape.web.jcr.ModeShapeJcrDeployer
starts, it will call the RepositoryProvider
startup
method which will load the configuration (for example, from a web.xml
file) and initialize the repository.
As an example, here's the ModeShape JCR provider implementation of this method with exception handling omitted for brevity.
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
The name of configuration file for the
JcrEngine
is read from the servlet context and used to initialize the engine. Once the repository has been started, it is ready to accept the main methods that provide the interface to the repository.
The first method returns the set of repository names supported by this repository.
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
The ModeShape JCR repository does support multiple repositories on the same server. Other JCR implementations that don't support multiple repositories are free to return a singleton set containing any string from this method.
public Set<String> getJcrRepositoryNames() { return new HashSet<String>(jcrEngine.getRepositoryNames()); }
public Set<String> getJcrRepositoryNames() {
return new HashSet<String>(jcrEngine.getRepositoryNames());
}
The other required method returns an open JCR Session for the user from the current request in a given repository and workspace. The provider can use the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
The
HttpServletRequest
to get the authentication credentials for the HTTP user.
getSession(...)
method is used by most of the REST server methods to access the JCR repository and return results as needed.
Finally, the
shutdown()
method signals that the web context is being undeployed and the JCR repository should shutdown and clean up any resources that are in use.