Interface RepositoryFactory
-
- All Known Subinterfaces:
JackrabbitRepositoryFactory
- All Known Implementing Classes:
GenericRepositoryFactory,JndiRepositoryFactory,OakRepositoryFactory
public interface RepositoryFactoryRepositoryFactoryis a factory forRepositoryobjects.An implementation of this interface 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 mechanism, 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 implementsRepositoryFactory.Examples how to obtain repository instances
Explicitly specifying the repository factory implementation:
Map parameters = new HashMap(); parameters.put("com.vendor.address", "vendor://localhost:9999/repo"); RepositoryFactory factory = (RepositoryFactory) Class.forName("com.vendor.RepositoryFactoryImpl"); Repository repo = factory.getRepository(parameters);Using ServiceLoader from Java SE 6:
Note: on Java SE prior to version 6, one may use the classMap 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; } }javax.imageio.spi.ServiceRegistryto look up the availableRepositoryFactoryimplementations.- Since:
- JCR 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RepositorygetRepository(java.util.Map parameters)Attempts to establish a connection to a repository using the givenparameters.
-
-
-
Method Detail
-
getRepository
Repository getRepository(java.util.Map parameters) throws RepositoryException
Attempts to establish a connection to a repository using the givenparameters.Parameters are passed in a
MapofStringkey/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. For example an address parameter might becom.vendor.address.The implementation must return
nullif it does not understand the given parameters. The implementation may also returnnullif a default repository instance is requested (indicated bynullparameters) and this factory is not able to identify a default repository.An implementation of this method must be thread-safe.
- Parameters:
parameters- map of string key/value pairs as repository arguments ornullif none are provided and a client wishes to connect to a default repository.- Returns:
- a repository instance or
nullif this implementation does not understand the passedparameters. - Throws:
RepositoryException- if if no suitable repository is found or another error occurs.
-
-