use of javax.jcr.Repository in project jackrabbit by apache.
the class RepositoryAccessServlet method getRepositoryByRMI.
/**
* Checks if the repository is available via RMI and returns it.
* @return the repository or <code>null</code>
* @throws ServletException if this servlet is not properly configured.
*/
private Repository getRepositoryByRMI() throws ServletException {
BootstrapConfig config = getConfig();
if (!config.getRmiConfig().isValid() || !config.getRmiConfig().enabled()) {
return null;
}
// acquire via RMI
String rmiURI = config.getRmiConfig().getRmiUri();
if (rmiURI == null) {
return null;
}
log.info(" trying to retrieve repository using rmi. uri={}", rmiURI);
ClientFactoryDelegater cfd;
try {
Class clazz = Class.forName(getServerFactoryDelegaterClass());
cfd = (ClientFactoryDelegater) clazz.newInstance();
} catch (Throwable e) {
log.error("Unable to locate RMI ClientRepositoryFactory. Is jcr-rmi.jar missing?", e);
return null;
}
try {
Repository r = cfd.getRepository(rmiURI);
log.info("Acquired repository via RMI.");
return r;
} catch (Exception e) {
log.error("Error while retrieving repository using RMI: {}", rmiURI, e);
return null;
}
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class RepositoryAccessServlet method getRepositoryByJNDI.
/**
* Checks if the repository is available via JNDI and returns it.
* @return the repository or <code>null</code>
* @throws ServletException if this servlet is not properly configured.
*/
private Repository getRepositoryByJNDI() throws ServletException {
BootstrapConfig config = getConfig();
if (!config.getJndiConfig().isValid() || !config.getJndiConfig().enabled()) {
return null;
}
// acquire via JNDI
String repositoryName = config.getRepositoryName();
InitialContext ctx = getInitialContext();
if (ctx == null) {
return null;
}
try {
Repository r = (Repository) ctx.lookup(repositoryName);
log.info("Acquired repository via JNDI.");
return r;
} catch (NamingException e) {
log.error("Error while retrieving repository using JNDI (name={})", repositoryName, e);
return null;
}
}
use of javax.jcr.Repository in project jackrabbit-oak by apache.
the class RepositoryStartupServlet method createRepository.
/**
* Creates the repository instance for the given config and homedir.
* Subclasses may override this method of providing own implementations of
* a {@link Repository}.
*
* @param configJson input source of the repository config
* @param homedir the repository home directory
* @return a new jcr repository.
* @throws RepositoryException if an error during creation occurs.
*/
protected Repository createRepository(File configJson, File homedir) throws RepositoryException {
Map<String, Object> config = new HashMap<String, Object>();
config.put(OakOSGiRepositoryFactory.REPOSITORY_HOME, homedir.getAbsolutePath());
config.put(OakOSGiRepositoryFactory.REPOSITORY_CONFIG_FILE, configJson.getAbsolutePath());
config.put(OakOSGiRepositoryFactory.REPOSITORY_BUNDLE_FILTER, getBootstrapConfig().getBundleFilter());
config.put(OakOSGiRepositoryFactory.REPOSITORY_SHUTDOWN_ON_TIMEOUT, getBootstrapConfig().isShutdownOnTimeout());
config.put(OakOSGiRepositoryFactory.REPOSITORY_TIMEOUT_IN_SECS, getBootstrapConfig().getStartupTimeout());
configureActivator(config);
//TODO oak-jcr also provides a dummy RepositoryFactory. Hence this
//cannot be used
//return JcrUtils.getRepository(config);
Repository repository = new OakOSGiRepositoryFactory().getRepository(config);
configWebConsoleSecurityProvider(repository);
return repository;
}
use of javax.jcr.Repository in project jackrabbit-oak by apache.
the class RepositoryAccessServlet method getRepositoryByRMI.
/**
* Checks if the repository is available via RMI and returns it.
* @return the repository or <code>null</code>
* @throws ServletException if this servlet is not properly configured.
*/
private Repository getRepositoryByRMI() throws ServletException {
BootstrapConfig config = getConfig();
if (!config.getRmiConfig().isValid() || !config.getRmiConfig().enabled()) {
return null;
}
// acquire via RMI
String rmiURI = config.getRmiConfig().getRmiUri();
if (rmiURI == null) {
return null;
}
log.info(" trying to retrieve repository using rmi. uri={}", rmiURI);
ClientFactoryDelegater cfd;
try {
Class clazz = Class.forName(getServerFactoryDelegaterClass());
cfd = (ClientFactoryDelegater) clazz.newInstance();
} catch (Throwable e) {
log.error("Unable to locate RMI ClientRepositoryFactory. Is jcr-rmi.jar missing?", e);
return null;
}
try {
Repository r = cfd.getRepository(rmiURI);
log.info("Acquired repository via RMI.");
return r;
} catch (Exception e) {
log.error("Error while retrieving repository using RMI: {}", rmiURI, e);
return null;
}
}
use of javax.jcr.Repository in project jackrabbit-oak by apache.
the class RemotingInitializer method remotingServlet.
@Bean
public ServletRegistrationBean remotingServlet() {
ServletRegistrationBean bean = new ServletRegistrationBean(new JcrRemotingServlet() {
@Override
public Repository getRepository() {
return repository;
}
@Override
public ServletContext getServletContext() {
return RemotingInitializer.this.getServletContext();
}
}, "/server/*");
bean.addInitParameter(JcrRemotingServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, "/server");
bean.addInitParameter(JcrRemotingServlet.INIT_PARAM_BATCHREAD_CONFIG, "/remoting/batchread.properties");
bean.addInitParameter(JcrRemotingServlet.INIT_PARAM_PROTECTED_HANDLERS_CONFIG, "/remoting/protectedHandlersConfig.xml");
bean.addInitParameter(JcrRemotingServlet.INIT_PARAM_HOME, davHome);
return bean;
}
Aggregations