ModeShape URL RFC
bcarothers May 30, 2010 2:00 PMOne of the additional features provided by JCR2 is the ability to get access to a JCR repository through a standard RepositoryFactory interface. JCR implementations (like ModeShape) would provide their own implementation of this interface and register it as a service. This would remove the need to have any implementation-specific code in one's application to use JCR. Instead, you could just use a snippet like this example from the JCR2 specification:
Map parameters = new HashMap();
parameters.put("com.vendor.address", "vendor://localhost:9999/repo");
Repository repo = null;
for (RepositoryFactory factory : ServiceLoader.load(RepositoryFactory.class)) {
repo = factory.getRepository(parameters);
if (repo != null) {
// factory accepted parameters
break;
}
This is easy enough to implement, but the spec doesn't say anything about what the parameters should be. I started out with a bunch of different individual parameters (e.g., org.modeshape.jcr.CONFIG_FILE, org.modeshape.jcr.JNDI_NAME, org.modeshape.jcr.REPOSITORY_NAME), but I thought it might be better to just provide a good old JDBC-style URL.
To that end, I propose that the ModeShape 2.0 RepositoryFactory implementation take one parameter (org.modeshape.jcr.URL) with a value that matches this format:
jcr:modeshape:<protocol>://<path>[?<repository name>]
The value of <protocol> would either be "jndi" or "file". The <path> is either the JNDI name of the JcrEngine (if <protocol> is "jndi") or the relative or absolute path to the file or resource containing the configuration information (if <protocol> is "file"). Finally, <repository name> would be used to access a named JCR repository, but could be omitted if the JcrEngine only had one repository.
So a sample JNDI URL is: "jcr:modeshape:jndi://my/jndi/path?My Repository" and a sample file URL is "jcr:modeshape:file://src/test/resources/configRepository.xml?Test Repository Source".
Please consider this a solicitation of feedback for this approach including:
- whether it's better to go with one URL or many other parameters
- the URL format
- the parameters in the URL
Thanks in advance!