Search in sources :

Example 1 with JNDIRemoteRepositoryFactory

use of org.apache.jackrabbit.rmi.repository.JNDIRemoteRepositoryFactory in project jackrabbit by apache.

the class JNDIRemoteRepositoryServlet method getRepository.

/**
     * Returns the remote repository in the configured JNDI location.
     *
     * @return repository
     * @throws RepositoryException if the repository could not be accessed
     */
@Override
protected Repository getRepository() throws RepositoryException {
    String location = "//localhost/" + RemoteRepository.class.getName().replace('.', '/');
    try {
        Hashtable environment = new Hashtable();
        Enumeration names = getInitParameterNames();
        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            if (name.equals("location")) {
                location = getInitParameter(name);
            } else if (!name.equals(Repository.class.getName()) && !name.equals(LocalAdapterFactory.class.getName())) {
                environment.put(name, getInitParameter(name));
            }
        }
        return new JNDIRemoteRepositoryFactory(getLocalAdapterFactory(), new InitialContext(environment), location).getRepository();
    } catch (NamingException e) {
        throw new RepositoryException("Repository not found: Invalid JNDI context", e);
    }
}
Also used : Enumeration(java.util.Enumeration) Hashtable(java.util.Hashtable) NamingException(javax.naming.NamingException) RepositoryException(javax.jcr.RepositoryException) JNDIRemoteRepositoryFactory(org.apache.jackrabbit.rmi.repository.JNDIRemoteRepositoryFactory) InitialContext(javax.naming.InitialContext)

Aggregations

Enumeration (java.util.Enumeration)1 Hashtable (java.util.Hashtable)1 RepositoryException (javax.jcr.RepositoryException)1 InitialContext (javax.naming.InitialContext)1 NamingException (javax.naming.NamingException)1 JNDIRemoteRepositoryFactory (org.apache.jackrabbit.rmi.repository.JNDIRemoteRepositoryFactory)1