| RepositoryFactory is a factory class for Repository
implementations.
A concrete implementation of this class must have a zero-argument
constructor. Repository factories may be installed in an instance of the Java
platform as extensions, that is, jar files placed into any of the usual
extension directories. Factories may also be made available by adding them to
the applet or application class path or by some other platform-specific
means. Repository factories are looked up via the current thread's context
class loader.
A repository factory should identify itself with a factory-configuration file
named javax.jcr.RepositoryFactory in the resource directory
META-INF/services. The file should contain a list of fully-qualified concrete
repository-factory class names, one per line. A line is terminated by any one
of a line feed ('\n'), a carriage return ('\r'), or a carriage return
followed immediately by a line feed. Space and tab characters surrounding
each name, as well as blank lines, are ignored. The comment character is '#'
('\u0023'); on each line all characters following the first comment character
are ignored. The file must be encoded in UTF-8.
If a particular concrete repository factory class is named in more than one
configuration file, or is named in the same configuration file more than
once, then the duplicates will be ignored. The configuration file naming a
particular factory need not be in the same jar file or other distribution
unit as the factory itself. The factory must be accessible from the same
class loader that was initially queried to locate the configuration file;
this is not necessarily the class loader that loaded the file.
Examples how to obtain repository instances
Use repository factory based on parameters:
Map parameters = new HashMap();
parameters.put("address", "vendor://localhost:9999/myrepo");
Repository repo = RepositoryFactory.getRepository(parameters);
Get a default repository available in this environment:
Repository repo = RepositoryFactory.getRepository();
Manually instanciate a specific repository factory and connect to the
repository:
Map parameters = new HashMap();
parameters.put("address", "vendor://localhost:9999/myrepo");
RepositoryFactory factory = new com.vendor.RepositoryFactory();
Repository repo = factory.connect(parameters);
|