use of org.mortbay.jetty.servlet.ServletHolder 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.ServletHolder in project dubbo by alibaba.
the class JettyContainer method start.
public void start() {
String serverPort = ConfigUtils.getProperty(JETTY_PORT);
int port;
if (serverPort == null || serverPort.length() == 0) {
port = DEFAULT_JETTY_PORT;
} else {
port = Integer.parseInt(serverPort);
}
connector = new SelectChannelConnector();
connector.setPort(port);
ServletHandler handler = new ServletHandler();
String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
if (resources != null && resources.length() > 0) {
FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
resourceHolder.setInitParameter("resources", resources);
}
ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
pageHolder.setInitOrder(2);
Server server = new Server();
server.addConnector(connector);
server.addHandler(handler);
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
}
}
use of org.mortbay.jetty.servlet.ServletHolder in project incubator-dubbo-ops by apache.
the class JettyContainer method start.
public void start() {
String serverPort = ConfigUtils.getProperty(JETTY_PORT);
int port;
if (serverPort == null || serverPort.length() == 0) {
port = DEFAULT_JETTY_PORT;
} else {
port = Integer.parseInt(serverPort);
}
connector = new SelectChannelConnector();
connector.setPort(port);
ServletHandler handler = new ServletHandler();
String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
if (resources != null && resources.length() > 0) {
FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
resourceHolder.setInitParameter("resources", resources);
}
ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
pageHolder.setInitOrder(2);
Server server = new Server();
server.addConnector(connector);
server.addHandler(handler);
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
}
}
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);
}
use of org.mortbay.jetty.servlet.ServletHolder in project incubator-myriad by apache.
the class TestObjectFactory method getJettyServer.
public static Server getJettyServer() {
Server server = new Server();
ServletHandler context = new ServletHandler();
ServletHolder holder = new ServletHolder(DefaultServlet.class);
holder.setInitParameter("resourceBase", System.getProperty("user.dir"));
holder.setInitParameter("dirAllowed", "true");
context.setServer(server);
context.addServlet(holder);
server.setHandler(context);
return server;
}
Aggregations