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);
}
}
Aggregations