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();
}
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();
}
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);
}
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();
}
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);
}
Aggregations