Search in sources :

Example 1 with DefaultServlet

use of org.eclipse.jetty.servlet.DefaultServlet in project jetty.project by eclipse.

the class JarServer method main.

public static void main(String[] args) throws Exception {
    Server server = new Server(8080);
    ServletContextHandler context = new ServletContextHandler();
    Resource.setDefaultUseCaches(true);
    Resource base = Resource.newResource("jar:file:src/main/resources/content.jar!/");
    context.setBaseResource(base);
    context.addServlet(new ServletHolder(new DefaultServlet()), "/");
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] { context, new DefaultHandler() });
    server.setHandler(handlers);
    server.start();
    server.join();
}
Also used : HandlerList(org.eclipse.jetty.server.handler.HandlerList) Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) Resource(org.eclipse.jetty.util.resource.Resource) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler)

Example 2 with DefaultServlet

use of org.eclipse.jetty.servlet.DefaultServlet in project druid by druid-io.

the class MiddleManagerJettyServerInitializer method initialize.

@Override
public void initialize(Server server, Injector injector) {
    final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS);
    root.addServlet(new ServletHolder(new DefaultServlet()), "/*");
    JettyServerInitUtils.addExtensionFilters(root, injector);
    root.addFilter(GuiceFilter.class, "/*", null);
    final HandlerList handlerList = new HandlerList();
    handlerList.setHandlers(new Handler[] { JettyServerInitUtils.getJettyRequestLogHandler(), JettyServerInitUtils.wrapWithDefaultGzipHandler(root), new DefaultHandler() });
    server.setHandler(handlerList);
}
Also used : HandlerList(org.eclipse.jetty.server.handler.HandlerList) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler)

Example 3 with DefaultServlet

use of org.eclipse.jetty.servlet.DefaultServlet in project druid by druid-io.

the class QueryJettyServerInitializer method initialize.

@Override
public void initialize(Server server, Injector injector) {
    final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS);
    root.addServlet(new ServletHolder(new DefaultServlet()), "/*");
    JettyServerInitUtils.addExtensionFilters(root, injector);
    root.addFilter(GuiceFilter.class, "/*", null);
    final HandlerList handlerList = new HandlerList();
    final Handler[] handlers = new Handler[extensionHandlers.size() + 2];
    handlers[0] = JettyServerInitUtils.getJettyRequestLogHandler();
    handlers[handlers.length - 1] = JettyServerInitUtils.wrapWithDefaultGzipHandler(root);
    for (int i = 0; i < extensionHandlers.size(); i++) {
        handlers[i + 1] = extensionHandlers.get(i);
    }
    handlerList.setHandlers(handlers);
    server.setHandler(handlerList);
}
Also used : HandlerList(org.eclipse.jetty.server.handler.HandlerList) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) Handler(org.eclipse.jetty.server.Handler) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 4 with DefaultServlet

use of org.eclipse.jetty.servlet.DefaultServlet in project druid by druid-io.

the class RouterJettyServerInitializer method initialize.

@Override
public void initialize(Server server, Injector injector) {
    final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS);
    root.addServlet(new ServletHolder(new DefaultServlet()), "/*");
    asyncQueryForwardingServlet.setTimeout(httpClientConfig.getReadTimeout().getMillis());
    ServletHolder sh = new ServletHolder(asyncQueryForwardingServlet);
    //NOTE: explicit maxThreads to workaround https://tickets.puppetlabs.com/browse/TK-152
    sh.setInitParameter("maxThreads", Integer.toString(httpClientConfig.getNumMaxThreads()));
    root.addServlet(sh, "/druid/v2/*");
    JettyServerInitUtils.addExtensionFilters(root, injector);
    // Can't use '/*' here because of Guice conflicts with AsyncQueryForwardingServlet path
    root.addFilter(GuiceFilter.class, "/status/*", null);
    final HandlerList handlerList = new HandlerList();
    handlerList.setHandlers(new Handler[] { JettyServerInitUtils.getJettyRequestLogHandler(), JettyServerInitUtils.wrapWithDefaultGzipHandler(root) });
    server.setHandler(handlerList);
}
Also used : HandlerList(org.eclipse.jetty.server.handler.HandlerList) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 5 with DefaultServlet

use of org.eclipse.jetty.servlet.DefaultServlet in project Synthese_2BIN by TheYoungSensei.

the class MyServer method main.

public static void main(String[] args) throws Exception {
    // lie le server � un port
    Server server = new Server(8000);
    // instancie un WebAppContext pour configurer le server
    WebAppContext context = new WebAppContext();
    // O� se trouvent les fichiers (ils seront servis par un DefaultServlet)
    context.setResourceBase("www");
    // MaServlet r�pondra aux requ�tes commen�ant par /chemin/
    context.addServlet(new ServletHolder(new MachineServlet()), "/Machine");
    // Le DefaultServlet sert des fichiers (html, js, css, images, ...). Il est en g�n�ral ajout� en dernier pour que les autres servlets soient prioritaires sur l�interpr�tation des URLs.
    context.addServlet(new ServletHolder(new DefaultServlet()), "/");
    // ce server utilise ce context
    server.setHandler(context);
    // allons-y
    server.start();
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet)

Aggregations

DefaultServlet (org.eclipse.jetty.servlet.DefaultServlet)20 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)19 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)10 HandlerList (org.eclipse.jetty.server.handler.HandlerList)7 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)6 File (java.io.File)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 Server (org.eclipse.jetty.server.Server)4 FilterHolder (org.eclipse.jetty.servlet.FilterHolder)4 Json (org.apache.druid.guice.annotations.Json)3 Authenticator (org.apache.druid.server.security.Authenticator)3 AuthenticatorMapper (org.apache.druid.server.security.AuthenticatorMapper)3 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)3 DispatcherType (javax.servlet.DispatcherType)2 HttpServer (org.apache.samza.coordinator.server.HttpServer)2 Handler (org.eclipse.jetty.server.Handler)2 Before (org.junit.Before)2 JmxReporter (com.codahale.metrics.JmxReporter)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 GroovityServletContainer (com.disney.groovity.servlet.container.GroovityServletContainer)1