Search in sources :

Example 1 with Context

use of org.mortbay.jetty.servlet.Context in project CloudStack-archive by CloudStack-extras.

the class JettyVmDataServer method setupJetty.

private void setupJetty(int vmDataPort, int fileservingPort) throws Exception {
    _jetty = new Server();
    SelectChannelConnector connector0 = new SelectChannelConnector();
    connector0.setHost(_hostIp);
    connector0.setPort(fileservingPort);
    connector0.setMaxIdleTime(30000);
    connector0.setRequestBufferSize(8192);
    SelectChannelConnector connector1 = new SelectChannelConnector();
    connector1.setHost(_hostIp);
    connector1.setPort(vmDataPort);
    connector1.setThreadPool(new QueuedThreadPool(5));
    connector1.setMaxIdleTime(30000);
    connector1.setRequestBufferSize(8192);
    _jetty.setConnectors(new Connector[] { connector0, connector1 });
    Context root = new Context(_jetty, "/latest", Context.SESSIONS);
    root.setResourceBase(_vmDataDir);
    root.addServlet(new ServletHolder(new VmDataServlet(this, USER_DATA)), "/*");
    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setResourceBase("/var/lib/images/");
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] { root, resource_handler, new DefaultHandler() });
    _jetty.setHandler(handlers);
    _jetty.start();
// _jetty.join();
}
Also used : Context(org.mortbay.jetty.servlet.Context) HandlerList(org.mortbay.jetty.handler.HandlerList) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) Server(org.mortbay.jetty.Server) QueuedThreadPool(org.mortbay.thread.QueuedThreadPool) ServletHolder(org.mortbay.jetty.servlet.ServletHolder) ResourceHandler(org.mortbay.jetty.handler.ResourceHandler) DefaultHandler(org.mortbay.jetty.handler.DefaultHandler)

Example 2 with Context

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

the class NutchUiServer method startServer.

private static void startServer() throws Exception, InterruptedException {
    Server server = new Server(port);
    Context context = new Context(server, "/", Context.SESSIONS);
    context.addServlet(DefaultServlet.class, "/*");
    context.addEventListener(new ContextLoaderListener(getContext()));
    context.addEventListener(new RequestContextListener());
    WicketFilter filter = new WicketFilter();
    filter.setFilterPath("/");
    FilterHolder holder = new FilterHolder(filter);
    holder.setInitParameter("applicationFactoryClassName", APP_FACTORY_NAME);
    context.addFilter(holder, "/*", Handler.DEFAULT);
    server.setHandler(context);
    server.start();
    server.join();
}
Also used : WebApplicationContext(org.springframework.web.context.WebApplicationContext) Context(org.mortbay.jetty.servlet.Context) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) RequestContextListener(org.springframework.web.context.request.RequestContextListener) FilterHolder(org.mortbay.jetty.servlet.FilterHolder) Server(org.mortbay.jetty.Server) WicketFilter(org.apache.wicket.protocol.http.WicketFilter) ContextLoaderListener(org.springframework.web.context.ContextLoaderListener)

Example 3 with Context

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

Example 4 with Context

use of org.mortbay.jetty.servlet.Context in project incubator-myriad by apache.

the class MyriadWebServer method start.

public void start() throws Exception {
    this.jetty.addConnector(connector);
    ServletHandler servletHandler = new ServletHandler();
    String filterName = "MyriadGuiceFilter";
    FilterHolder holder = new FilterHolder(filter);
    holder.setName(filterName);
    FilterMapping filterMapping = new FilterMapping();
    filterMapping.setPathSpec("/*");
    filterMapping.setDispatches(Handler.ALL);
    filterMapping.setFilterName(filterName);
    servletHandler.addFilter(holder, filterMapping);
    Context context = new Context();
    context.setServletHandler(servletHandler);
    context.addServlet(DefaultServlet.class, "/");
    String staticDir = this.getClass().getClassLoader().getResource("webapp/public").toExternalForm();
    context.setResourceBase(staticDir);
    this.jetty.addHandler(context);
    this.jetty.start();
}
Also used : Context(org.mortbay.jetty.servlet.Context) ServletHandler(org.mortbay.jetty.servlet.ServletHandler) FilterHolder(org.mortbay.jetty.servlet.FilterHolder) FilterMapping(org.mortbay.jetty.servlet.FilterMapping)

Example 5 with Context

use of org.mortbay.jetty.servlet.Context in project registry by hortonworks.

the class AuthenticatorTestCase method startJetty.

protected void startJetty() throws Exception {
    server = new Server(0);
    context = new Context();
    context.setContextPath("/foo");
    server.setHandler(context);
    context.addFilter(new FilterHolder(TestFilter.class), "/*", 0);
    context.addServlet(new ServletHolder(TestServlet.class), "/bar");
    host = "localhost";
    port = getLocalPort();
    server.getConnectors()[0].setHost(host);
    server.getConnectors()[0].setPort(port);
    server.start();
    System.out.println("Running embedded servlet container at: http://" + host + ":" + port);
}
Also used : Context(org.mortbay.jetty.servlet.Context) FilterHolder(org.mortbay.jetty.servlet.FilterHolder) Server(org.mortbay.jetty.Server) ServletHolder(org.mortbay.jetty.servlet.ServletHolder)

Aggregations

Context (org.mortbay.jetty.servlet.Context)14 Server (org.mortbay.jetty.Server)11 ServletHolder (org.mortbay.jetty.servlet.ServletHolder)10 SelectChannelConnector (org.mortbay.jetty.nio.SelectChannelConnector)3 FilterHolder (org.mortbay.jetty.servlet.FilterHolder)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 QueuedThreadPool (org.mortbay.thread.QueuedThreadPool)2 VoldemortServer (voldemort.server.VoldemortServer)2 HessianServlet (com.caucho.hessian.server.HessianServlet)1 TearDown (com.google.common.testing.TearDown)1 List (java.util.List)1 Map (java.util.Map)1 ServletException (javax.servlet.ServletException)1 Configuration (org.apache.hadoop.conf.Configuration)1 WicketFilter (org.apache.wicket.protocol.http.WicketFilter)1 RestServlet (org.datanucleus.api.rest.RestServlet)1 AbstractConnector (org.mortbay.jetty.AbstractConnector)1 Connector (org.mortbay.jetty.Connector)1 SocketConnector (org.mortbay.jetty.bio.SocketConnector)1