4.1 Repository Object

To begin using a repository, an application must acquire a Repository object.

Access to a Repository object may be provided through a number of standard Java naming and discovery mechanisms, but must at the minimum be provided through an implementation of the RepositoryFactory interface.

Any implementation of RepositoryFactory must have a zero-argument public 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.

A repository factory implementation should support the Java Standard Edition Service Provider mechanism9, that is, an implementation should include the file META-INF/services/javax.jcr.RepositoryFactory. This file contains the fully qualified name of the class that implements RepositoryFactory.

Once the RepositoryFactory is acquired, the Repository object itself is acquired through

Repository RepositoryFactory.getRepository(Map parameters)

which attempts to retrieve a Repository object using the given parameters.

Parameters are passed in a Map of String key/value pairs. The keys are not specified by JCR and are implementation specific. However, vendors should use keys that are namespace qualified in the Java package style to distinguish their key names. Alternatively, a client may request a default repository instance by passing a null.

The implementation must return null if a default repository instance is requested and the factory is not able to identify such a repository or if parameters are passed and the factory does not understand them. See the associated Javadoc for example connection code.