Package org.apache.sling.jcr.base.util
Class RepositoryAccessor
- java.lang.Object
-
- org.apache.sling.jcr.base.util.RepositoryAccessor
-
public class RepositoryAccessor extends Object
Access a Repository via JNDI or RMI.
-
-
Field Summary
Fields Modifier and Type Field Description static StringJNDI_PREFIXPrefix for JNDI Repository URLsstatic StringREPOSITORY_URL_OVERRIDE_PROPERTYName of the property that the jcr client and server bundles to override their default configuration settings and connect to the specified repository instead (SLING-254 and SLING-260)static StringRMI_PREFIXPrefix for RMI Repository URLs
-
Constructor Summary
Constructors Constructor Description RepositoryAccessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.jackrabbit.rmi.client.ClientRepositoryFactorygetClientRepositoryFactory()Returns theClientRepositoryFactoryto access the remote JCR repository over RMI.protected org.apache.jackrabbit.rmi.client.LocalAdapterFactorygetLocalAdapterFactory()Returns theLocalAdapterFactoryused to convert Jackrabbit JCR RMI remote objects to local JCR API objects.javax.jcr.RepositorygetRepository(String repositoryName, Hashtable<String,Object> jndiContext)First try to access the Repository via JNDI (unless jndiContext is null), and if not successful try RMI.javax.jcr.RepositorygetRepositoryFromURL(String url)Acquire a Repository from the given URL
-
-
-
Field Detail
-
RMI_PREFIX
public static final String RMI_PREFIX
Prefix for RMI Repository URLs- See Also:
- Constant Field Values
-
JNDI_PREFIX
public static final String JNDI_PREFIX
Prefix for JNDI Repository URLs- See Also:
- Constant Field Values
-
REPOSITORY_URL_OVERRIDE_PROPERTY
public static final String REPOSITORY_URL_OVERRIDE_PROPERTY
Name of the property that the jcr client and server bundles to override their default configuration settings and connect to the specified repository instead (SLING-254 and SLING-260)- See Also:
- Constant Field Values
-
-
Method Detail
-
getRepository
public javax.jcr.Repository getRepository(String repositoryName, Hashtable<String,Object> jndiContext)
First try to access the Repository via JNDI (unless jndiContext is null), and if not successful try RMI.- Parameters:
repositoryName- JNDI name or RMI URL (must start with "rmi://") of the RepositoryjndiContext- if null, JNDI is not tried- Returns:
- a Repository, or null if not found
-
getRepositoryFromURL
public javax.jcr.Repository getRepositoryFromURL(String url)
Acquire a Repository from the given URL- Parameters:
url- for RMI, an RMI URL. For JNDI, "jndi://", followed by the JNDI repository name, followed by a colon and a comma-separated list of JNDI context values, for example:jndi://jackrabbit:java.naming.factory.initial=org.SomeClass,java.naming.provider.url=http://foo.com- Returns:
- the repository for the given url
- Throws:
NullPointerException- Ifurlisnull.
-
getLocalAdapterFactory
protected org.apache.jackrabbit.rmi.client.LocalAdapterFactory getLocalAdapterFactory()
Returns theLocalAdapterFactoryused to convert Jackrabbit JCR RMI remote objects to local JCR API objects.This method returns an instance of the
JackrabbitClientAdapterFactorywhich allows accessing Jackrabbit (or Jackrabbit-based) repositories over RMI. Extensions of this class may overwrite this method to use a different implementation.- Returns:
- the
LocalAdapterFactoryused to convert Jackrabbit JCR RMI remote objects to local JCR API objects.
-
getClientRepositoryFactory
protected org.apache.jackrabbit.rmi.client.ClientRepositoryFactory getClientRepositoryFactory()
Returns theClientRepositoryFactoryto access the remote JCR repository over RMI.This method creates an instance of the
ClientRepositoryFactoryclass initialized with theLocalAdapterFactoryreturned from thegetLocalAdapterFactory()method. Extensions may overwrite this method to return an extension of the Jackrabbit JCR RMIClientRepositoryFactoryclass.- Returns:
- the
ClientRepositoryFactoryto access the remote JCR repository over RMI.
-
-