use of org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet in project jackrabbit by apache.
the class RepositoryStubImpl method getRepository.
@Override
public Repository getRepository() throws RepositoryStubException {
if (repository == null) {
repository = super.getRepository();
}
if (connector == null) {
connector = new SocketConnector();
connector.setHost("localhost");
String pvalue = System.getProperty("org.apache.jackrabbit.jcr2dav.RepositoryStubImpl.port", "0");
int port = pvalue.equals("") ? 0 : Integer.parseInt(pvalue);
connector.setPort(port);
}
if (server == null) {
server = new Server();
server.addConnector(connector);
ServletHolder holder = new ServletHolder(new JcrRemotingServlet() {
protected Repository getRepository() {
return repository;
}
});
holder.setInitParameter(JCRWebdavServerServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, "");
holder.setInitParameter(JCRWebdavServerServlet.INIT_PARAM_MISSING_AUTH_MAPPING, "");
holder.setInitParameter(JcrRemotingServlet.INIT_PARAM_PROTECTED_HANDLERS_CONFIG, protectedRemoveImplClass);
Context context = new Context(server, "/");
context.addServlet(holder, "/*");
server.addHandler(context);
try {
server.start();
} catch (Exception e) {
throw new RepositoryStubException(e);
}
}
if (client == null) {
try {
Map<String, String> parameters = new HashMap<String, String>();
String uri = "http://localhost:" + connector.getLocalPort() + "/";
String parmName = System.getProperty(this.getClass().getName() + ".REPURIPARM", JcrUtils.REPOSITORY_URI);
parameters.put(parmName, uri);
parameters.put(PROP_ACCESSCONTROL_PROVIDER_CLASS, acProviderImplClass);
client = JcrUtils.getRepository(parameters);
} catch (Exception e) {
throw new RepositoryStubException(e);
}
}
return client;
}
use of org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet 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