Search in sources :

Example 76 with ServletHolder

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

the class RequestConfiguration_Test method setUp.

@BeforeClass
public static void setUp() throws Exception {
    server = new Server(10043);
    ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
    CallbackStatement statement = mock(CallbackStatement.class);
    CallbackSerlvet servlet = new CallbackSerlvet(resource, statement);
    context.addServlet(new ServletHolder(servlet), "/");
    server.start();
    int timer = 0;
    while (!server.isRunning() && timer < TIMEOUT) {
        Thread.sleep(1000);
        timer++;
    }
}
Also used : Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) CallbackStatement(com.eclipsesource.restfuse.internal.callback.CallbackStatement) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) CallbackSerlvet(com.eclipsesource.restfuse.internal.callback.CallbackSerlvet) BeforeClass(org.junit.BeforeClass)

Example 77 with ServletHolder

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

the class RequestContextConfiguration_Test method setUp.

@BeforeClass
public static void setUp() throws Exception {
    server = new Server(10045);
    ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
    CallbackStatement statement = mock(CallbackStatement.class);
    CallbackSerlvet servlet = new CallbackSerlvet(resource, statement);
    context.addServlet(new ServletHolder(servlet), "/");
    server.start();
    int timer = 0;
    while (!server.isRunning() && timer < TIMEOUT) {
        Thread.sleep(1000);
        timer++;
    }
}
Also used : Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) CallbackStatement(com.eclipsesource.restfuse.internal.callback.CallbackStatement) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) CallbackSerlvet(com.eclipsesource.restfuse.internal.callback.CallbackSerlvet) BeforeClass(org.junit.BeforeClass)

Example 78 with ServletHolder

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

the class HttpTestStatement_Test method setUp.

@BeforeClass
public static void setUp() throws Exception {
    server = new Server(10042);
    ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
    CallbackStatement statement = mock(CallbackStatement.class);
    CallbackSerlvet servlet = new CallbackSerlvet(new DefaultCallbackResource(), statement);
    context.addServlet(new ServletHolder(servlet), "/");
    server.start();
    int timer = 0;
    while (!server.isRunning() && timer < TIMEOUT) {
        Thread.sleep(1000);
        timer++;
    }
}
Also used : Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) CallbackStatement(com.eclipsesource.restfuse.internal.callback.CallbackStatement) DefaultCallbackResource(com.eclipsesource.restfuse.DefaultCallbackResource) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) CallbackSerlvet(com.eclipsesource.restfuse.internal.callback.CallbackSerlvet) BeforeClass(org.junit.BeforeClass)

Example 79 with ServletHolder

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

the class TestWebAppProxyServlet method start.

/**
   * Simple http server. Server should send answer with status 200
   */
@BeforeClass
public static void start() throws Exception {
    server = new Server(0);
    ((QueuedThreadPool) server.getThreadPool()).setMaxThreads(10);
    ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/foo");
    server.setHandler(context);
    context.addServlet(new ServletHolder(TestServlet.class), "/bar");
    ((ServerConnector) server.getConnectors()[0]).setHost("localhost");
    server.start();
    originalPort = ((ServerConnector) server.getConnectors()[0]).getLocalPort();
    LOG.info("Running embedded servlet container at: http://localhost:" + originalPort);
    // This property needs to be set otherwise CORS Headers will be dropped
    // by HttpUrlConnection
    System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) Server(org.eclipse.jetty.server.Server) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) BeforeClass(org.junit.BeforeClass)

Example 80 with ServletHolder

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

the class ZeppelinServer method setupRestApiContextHandler.

private static void setupRestApiContextHandler(WebAppContext webapp, ZeppelinConfiguration conf) {
    final ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
    cxfServletHolder.setInitParameter("javax.ws.rs.Application", ZeppelinServer.class.getName());
    cxfServletHolder.setName("rest");
    cxfServletHolder.setForcedPath("rest");
    webapp.setSessionHandler(new SessionHandler());
    webapp.addServlet(cxfServletHolder, "/api/*");
    String shiroIniPath = conf.getShiroPath();
    if (!StringUtils.isBlank(shiroIniPath)) {
        webapp.setInitParameter("shiroConfigLocations", new File(shiroIniPath).toURI().toString());
        SecurityUtils.initSecurityManager(shiroIniPath);
        webapp.addFilter(ShiroFilter.class, "/api/*", EnumSet.allOf(DispatcherType.class));
        webapp.addEventListener(new EnvironmentLoaderListener());
    }
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) EnvironmentLoaderListener(org.apache.shiro.web.env.EnvironmentLoaderListener) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) DispatcherType(javax.servlet.DispatcherType) File(java.io.File) CXFNonSpringJaxrsServlet(org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet)

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