Search in sources :

Example 66 with ServletHolder

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

the class ChatServletTest method setUp.

@Before
public void setUp() throws Exception {
    tester.setContextPath("/");
    ServletHolder dispatch = tester.addServlet(ChatServlet.class, "/chat/*");
    dispatch.setInitParameter("asyncTimeout", "500");
    tester.start();
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder) Before(org.junit.Before)

Example 67 with ServletHolder

use of org.eclipse.jetty.servlet.ServletHolder in project elastic-job by dangdangdotcom.

the class RestfulServer method getServletHolder.

private ServletHolder getServletHolder(final String packages) {
    ServletHolder result = new ServletHolder(ServletContainer.class);
    result.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, Joiner.on(",").join(RestfulServer.class.getPackage().getName(), packages));
    result.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", PackagesResourceConfig.class.getName());
    result.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", Boolean.TRUE.toString());
    result.setInitParameter("resteasy.scan.providers", Boolean.TRUE.toString());
    result.setInitParameter("resteasy.use.builtin.providers", Boolean.FALSE.toString());
    return result;
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder) PackagesResourceConfig(com.sun.jersey.api.core.PackagesResourceConfig)

Example 68 with ServletHolder

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

the class MultiPartConfigAnnotationHandler method getServletHolderForClass.

private ServletHolder getServletHolderForClass(Class clazz) {
    ServletHolder holder = null;
    ServletHolder[] holders = _context.getServletHandler().getServlets();
    if (holders != null) {
        for (ServletHolder h : holders) {
            if (h.getClassName() != null && h.getClassName().equals(clazz.getName())) {
                holder = h;
            }
        }
    }
    return holder;
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder)

Example 69 with ServletHolder

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

the class WebSocketServer method main.

public static void main(String[] args) throws Exception {
    Server server = new Server(8080);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    server.setHandler(context);
    // Add the echo socket servlet to the /echo path map
    context.addServlet(new ServletHolder(EchoServlet.class), "/echo");
    server.start();
    context.dumpStdErr();
    server.join();
}
Also used : Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 70 with ServletHolder

use of org.eclipse.jetty.servlet.ServletHolder 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)

Aggregations

ServletHolder (org.eclipse.jetty.servlet.ServletHolder)287 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)158 Server (org.eclipse.jetty.server.Server)111 Test (org.junit.Test)77 FilterHolder (org.eclipse.jetty.servlet.FilterHolder)46 ServerConnector (org.eclipse.jetty.server.ServerConnector)45 HttpServletRequest (javax.servlet.http.HttpServletRequest)38 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)25 HttpClient (org.eclipse.jetty.client.HttpClient)23 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)23 IOException (java.io.IOException)22 CountDownLatch (java.util.concurrent.CountDownLatch)22 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)22 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)19 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)18 DefaultServlet (org.eclipse.jetty.servlet.DefaultServlet)18 HttpServletResponse (javax.servlet.http.HttpServletResponse)17 BeforeClass (org.junit.BeforeClass)17 File (java.io.File)15 ServletException (javax.servlet.ServletException)15