Search in sources :

Example 6 with Context

use of org.mortbay.jetty.servlet.Context 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 Context

use of org.mortbay.jetty.servlet.Context 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 Context

use of org.mortbay.jetty.servlet.Context in project ghostdriver by detro.

the class CallbackHttpServer method start.

public void start() throws Exception {
    server = new Server(0);
    Context context = new Context(server, "/");
    addServlets(context);
    server.start();
}
Also used : Context(org.mortbay.jetty.servlet.Context) Server(org.mortbay.jetty.Server)

Example 9 with Context

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

the class LitmusTest method testLitmus.

public void testLitmus() throws Exception {
    File dir = new File("target", "litmus");
    String litmus = System.getProperty("litmus", "litmus");
    if (Boolean.getBoolean("jackrabbit.test.integration") && isLitmusAvailable(litmus)) {
        final Repository repository = JcrUtils.getRepository("jcr-jackrabbit://" + Text.escapePath(dir.getCanonicalPath()));
        // for the TransientRepository
        Session session = repository.login();
        try {
            SocketConnector connector = new SocketConnector();
            connector.setHost("localhost");
            connector.setPort(Integer.getInteger("litmus.port", 0));
            Server server = new Server();
            server.addConnector(connector);
            ServletHolder holder = new ServletHolder(new SimpleWebdavServlet() {

                @Override
                public Repository getRepository() {
                    return repository;
                }
            });
            holder.setInitParameter("resource-config", "/config.xml");
            Context context = new Context(server, "/");
            context.setResourceBase("src/test/resources");
            context.addServlet(holder, "/*");
            server.addHandler(context);
            server.start();
            try {
                int port = connector.getLocalPort();
                String url = "http://localhost:" + port + "/default";
                ProcessBuilder builder = new ProcessBuilder(litmus, url, "admin", "admin");
                builder.directory(dir);
                builder.redirectErrorStream();
                assertLitmus(builder, "basic", 0);
                assertLitmus(builder, "http", 0);
                assertLitmus(builder, "props", 0);
                // FIXME: JCR-2637: WebDAV shallow copy test failure
                assertLitmus(builder, "copymove", 1);
                // FIXME: JCR-2638: Litmus locks test failures
                assertLitmus(builder, "locks", 1);
            } finally {
                server.stop();
            }
        } finally {
            session.logout();
        }
    }
}
Also used : Context(org.mortbay.jetty.servlet.Context) Repository(javax.jcr.Repository) Server(org.mortbay.jetty.Server) ServletHolder(org.mortbay.jetty.servlet.ServletHolder) File(java.io.File) SocketConnector(org.mortbay.jetty.bio.SocketConnector) Session(javax.jcr.Session)

Aggregations

Context (org.mortbay.jetty.servlet.Context)9 Server (org.mortbay.jetty.Server)8 ServletHolder (org.mortbay.jetty.servlet.ServletHolder)7 SocketConnector (org.mortbay.jetty.bio.SocketConnector)3 SelectChannelConnector (org.mortbay.jetty.nio.SelectChannelConnector)3 IOException (java.io.IOException)2 Repository (javax.jcr.Repository)2 QueuedThreadPool (org.mortbay.thread.QueuedThreadPool)2 VoldemortServer (voldemort.server.VoldemortServer)2 TearDown (com.google.common.testing.TearDown)1 File (java.io.File)1 HashMap (java.util.HashMap)1 RepositoryException (javax.jcr.RepositoryException)1 Session (javax.jcr.Session)1 ServletException (javax.servlet.ServletException)1 JcrRemotingServlet (org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet)1 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)1 RepositoryStubException (org.apache.jackrabbit.test.RepositoryStubException)1 AbstractConnector (org.mortbay.jetty.AbstractConnector)1 Connector (org.mortbay.jetty.Connector)1