Search in sources :

Example 1 with OakServlet

use of org.apache.jackrabbit.oak.http.OakServlet in project jackrabbit-oak by apache.

the class HttpServer method addServlets.

private void addServlets(Oak oak, String path) {
    Jcr jcr = new Jcr(oak);
    // 1 - OakServer
    ContentRepository repository = jcr.createContentRepository();
    ServletHolder holder = new ServletHolder(new OakServlet(repository));
    context.addServlet(holder, path + "/*");
    // 2 - Webdav Server on JCR repository
    final Repository jcrRepository = jcr.createRepository();
    @SuppressWarnings("serial") ServletHolder webdav = new ServletHolder(new SimpleWebdavServlet() {

        @Override
        public Repository getRepository() {
            return jcrRepository;
        }
    });
    webdav.setInitParameter(SimpleWebdavServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, path + "/webdav");
    webdav.setInitParameter(AbstractWebdavServlet.INIT_PARAM_AUTHENTICATE_HEADER, "Basic realm=\"Oak\"");
    context.addServlet(webdav, path + "/webdav/*");
    // 3 - JCR Remoting Server
    @SuppressWarnings("serial") ServletHolder jcrremote = new ServletHolder(new JcrRemotingServlet() {

        @Override
        protected Repository getRepository() {
            return jcrRepository;
        }
    });
    jcrremote.setInitParameter(JCRWebdavServerServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, path + "/jcrremote");
    jcrremote.setInitParameter(AbstractWebdavServlet.INIT_PARAM_AUTHENTICATE_HEADER, "Basic realm=\"Oak\"");
    context.addServlet(jcrremote, path + "/jcrremote/*");
}
Also used : Repository(javax.jcr.Repository) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) SimpleWebdavServlet(org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) OakServlet(org.apache.jackrabbit.oak.http.OakServlet) JcrRemotingServlet(org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet)

Aggregations

Repository (javax.jcr.Repository)1 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)1 OakServlet (org.apache.jackrabbit.oak.http.OakServlet)1 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)1 JcrRemotingServlet (org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet)1 SimpleWebdavServlet (org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1