|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface RepositoryFactory
RepositoryFactory
is a factory class for Repository
implementations.
META-INF/services/javax.jcr.RepositoryFactory
. This file
contains the fully qualified name of the class that implements
RepositoryFactory
.
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:
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;
}
}
Note: on Java SE prior to version 6, one may use the
ServiceRegistry
class to look up
the available RepositoryFactory
implementations.
- Since:
- JCR 2.0
Method Summary
Repository
getRepository(Map parameters)
Attempts to establish a connection to a repository using the given
parameters
.
Method Detail
getRepository
Repository getRepository(Map parameters)
throws RepositoryException
- Attempts to establish a connection to a repository 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. For example
an address parameter might be com.vendor.address
.
The implementation must return null
if it does not
understand the given parameters. The implementation may also return
null
if a default repository instance is requested
(indicated by null
parameters
) and this factory
is not able to identify a default repository. An implementation should
throw an RepositoryException
if it is the right factory but
has trouble connecting to the repository.
An implementation of this method must be thread-safe.
- Parameters:
parameters
- map of arbitrary string key/value pairs as repository
arguments or null
if none are provided and
a client wishes to connect to a default repository.
- Returns:
- a repository instance or
null
if this implementation
does not understand the passed parameters
.
- Throws:
RepositoryException
- if getRepository fails or if no suitable
repository is found.
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.