use of org.apache.jackrabbit.commons.repository.JNDIRepositoryFactory in project jackrabbit by apache.
the class JNDIRepositoryServlet method getRepository.
/**
* Returns a JNDI repository based on the configured init parameters.
*
* @return JNDI repository
*/
protected Repository getRepository() throws RepositoryException {
try {
String location = Repository.class.getName().replace('.', '/');
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())) {
environment.put(name, getInitParameter(name));
}
}
return new JNDIRepositoryFactory(new InitialContext(environment), location).getRepository();
} catch (NamingException e) {
throw new RepositoryException("Repository not found: Invalid JNDI context", e);
}
}
Aggregations