Search in sources :

Example 6 with ServletHolder

use of org.mortbay.jetty.servlet.ServletHolder in project voldemort by voldemort.

the class HttpService method startInner.

@Override
public void startInner() {
    try {
        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setLowResourceMaxIdleTime(3000);
        connector.setPort(this.port);
        connector.setReuseAddress(true);
        QueuedThreadPool threadPool = new QueuedThreadPool();
        threadPool.setName("VoldemortHttp");
        threadPool.setMaxThreads(this.numberOfThreads);
        Server httpServer = new Server();
        httpServer.setConnectors(new Connector[] { connector });
        httpServer.setThreadPool(threadPool);
        httpServer.setSendServerVersion(false);
        httpServer.setSendDateHeader(false);
        Context context = new Context(httpServer, "/", Context.NO_SESSIONS);
        context.setAttribute(VoldemortServletContextListener.SERVER_KEY, server);
        context.setAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY, velocityEngine);
        context.addServlet(new ServletHolder(new AdminServlet(server, velocityEngine)), "/admin");
        context.addServlet(new ServletHolder(new StoreServlet(requestHandler)), "/stores");
        context.addServlet(new ServletHolder(new ReadOnlyStoreManagementServlet(server, velocityEngine)), "/read-only/mgmt");
        context.addServlet(new ServletHolder(new StatusServlet(server, velocityEngine)), "/server-status");
        this.context = context;
        this.httpServer = httpServer;
        this.httpServer.start();
        logger.info("HTTP service started on port " + this.port);
    } catch (Exception e) {
        String errorMessage = " Error starting service on port " + this.port;
        throw new VoldemortException(errorMessage, e);
    }
}
Also used : Context(org.mortbay.jetty.servlet.Context) StatusServlet(voldemort.server.http.gui.StatusServlet) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) AdminServlet(voldemort.server.http.gui.AdminServlet) Server(org.mortbay.jetty.Server) VoldemortServer(voldemort.server.VoldemortServer) QueuedThreadPool(org.mortbay.thread.QueuedThreadPool) ServletHolder(org.mortbay.jetty.servlet.ServletHolder) ReadOnlyStoreManagementServlet(voldemort.server.http.gui.ReadOnlyStoreManagementServlet) VoldemortException(voldemort.VoldemortException) VoldemortException(voldemort.VoldemortException)

Example 7 with ServletHolder

use of org.mortbay.jetty.servlet.ServletHolder in project voldemort by voldemort.

the class ServerTestUtils method getJettyServer.

public static Context getJettyServer(String clusterXml, String storesXml, String storeName, RequestFormatType requestFormat, int port) throws Exception {
    StoreRepository repository = getStores(storeName, clusterXml, storesXml);
    // initialize servlet
    Server server = new Server(port);
    server.setSendServerVersion(false);
    Context context = new Context(server, "/", Context.NO_SESSIONS);
    RequestHandler handler = getSocketRequestHandlerFactory(clusterXml, storesXml, repository).getRequestHandler(requestFormat);
    context.addServlet(new ServletHolder(new StoreServlet(handler)), "/stores");
    server.start();
    return context;
}
Also used : Context(org.mortbay.jetty.servlet.Context) Server(org.mortbay.jetty.Server) VoldemortServer(voldemort.server.VoldemortServer) RequestHandler(voldemort.server.protocol.RequestHandler) ServletHolder(org.mortbay.jetty.servlet.ServletHolder) StoreRepository(voldemort.server.StoreRepository) StoreServlet(voldemort.server.http.StoreServlet)

Example 8 with ServletHolder

use of org.mortbay.jetty.servlet.ServletHolder in project jackrabbit by apache.

the class Main method prepareWebapp.

private void prepareWebapp(File file, File repository, File tmp) {
    webapp.setContextPath("/");
    webapp.setWar(file.getPath());
    webapp.setExtractWAR(false);
    webapp.setTempDirectory(tmp);
    ServletHolder servlet = new ServletHolder(JackrabbitRepositoryServlet.class);
    servlet.setInitOrder(1);
    servlet.setInitParameter("repository.home", repository.getPath());
    String conf = command.getOptionValue("conf");
    if (conf != null) {
        servlet.setInitParameter("repository.config", conf);
    }
    webapp.addServlet(servlet, "/repository.properties");
}
Also used : ServletHolder(org.mortbay.jetty.servlet.ServletHolder)

Example 9 with ServletHolder

use of org.mortbay.jetty.servlet.ServletHolder 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;
}
Also used : Context(org.mortbay.jetty.servlet.Context) Repository(javax.jcr.Repository) Server(org.mortbay.jetty.Server) HashMap(java.util.HashMap) ServletHolder(org.mortbay.jetty.servlet.ServletHolder) RepositoryStubException(org.apache.jackrabbit.test.RepositoryStubException) SocketConnector(org.mortbay.jetty.bio.SocketConnector) JcrRemotingServlet(org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet) RepositoryStubException(org.apache.jackrabbit.test.RepositoryStubException) RepositoryException(javax.jcr.RepositoryException) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

Example 10 with ServletHolder

use of org.mortbay.jetty.servlet.ServletHolder in project nutch by apache.

the class TestProtocolHttp method setUp.

public void setUp(boolean redirection) throws Exception {
    conf = new Configuration();
    conf.addResource("nutch-default.xml");
    conf.addResource("nutch-site-test.xml");
    http = new Http();
    http.setConf(conf);
    server = new Server();
    if (redirection) {
        root = new Context(server, "/redirection", Context.SESSIONS);
        root.setAttribute("newContextURL", "/redirect");
    } else {
        root = new Context(server, "/", Context.SESSIONS);
    }
    ServletHolder sh = new ServletHolder(org.apache.jasper.servlet.JspServlet.class);
    root.addServlet(sh, "*.jsp");
    root.setResourceBase(RES_DIR);
}
Also used : Context(org.mortbay.jetty.servlet.Context) Configuration(org.apache.hadoop.conf.Configuration) Server(org.mortbay.jetty.Server) ServletHolder(org.mortbay.jetty.servlet.ServletHolder)

Aggregations

ServletHolder (org.mortbay.jetty.servlet.ServletHolder)13 Server (org.mortbay.jetty.Server)9 Context (org.mortbay.jetty.servlet.Context)8 SelectChannelConnector (org.mortbay.jetty.nio.SelectChannelConnector)4 SocketConnector (org.mortbay.jetty.bio.SocketConnector)3 IOException (java.io.IOException)2 Repository (javax.jcr.Repository)2 FilterHolder (org.mortbay.jetty.servlet.FilterHolder)2 QueuedThreadPool (org.mortbay.thread.QueuedThreadPool)2 VoldemortServer (voldemort.server.VoldemortServer)2 TearDown (com.google.common.testing.TearDown)1 File (java.io.File)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 RepositoryException (javax.jcr.RepositoryException)1 Session (javax.jcr.Session)1 ServletException (javax.servlet.ServletException)1 Configuration (org.apache.hadoop.conf.Configuration)1 JcrRemotingServlet (org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet)1