Java Code Examples for org.eclipse.jetty.servlet.ServletContextHandler#setClassLoader()

The following examples show how to use org.eclipse.jetty.servlet.ServletContextHandler#setClassLoader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServletInstrumentationTest.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUpHandler(ServletContextHandler handler) {
    handler.setDisplayName(getClass().getSimpleName());
    handler.setClassLoader(getClass().getClassLoader());
    handler.addServlet(TestServlet.class, "/filter/test");
    handler.addServlet(TestServlet.class, "/test");
    handler.addServlet(BaseTestServlet.class, "/base");
    handler.addServlet(ForwardingServlet.class, "/forward");
    handler.addServlet(IncludingServlet.class, "/include");
    handler.addFilter(TestFilter.class, "/filter/*", EnumSet.of(DispatcherType.REQUEST));
}
 
Example 2
Source File: JettyCoreServer.java    From jvm-sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void initJettyContextHandler() {
    final String namespace = cfg.getNamespace();
    final ServletContextHandler context = new ServletContextHandler(NO_SESSIONS);

    final String contextPath = "/sandbox/" + namespace;
    context.setContextPath(contextPath);
    context.setClassLoader(getClass().getClassLoader());

    // web-socket-servlet
    final String wsPathSpec = "/module/websocket/*";
    logger.info("initializing ws-http-handler. path={}", contextPath + wsPathSpec);
    //noinspection deprecation
    context.addServlet(
            new ServletHolder(new WebSocketAcceptorServlet(jvmSandbox.getCoreModuleManager())),
            wsPathSpec
    );

    // module-http-servlet
    final String pathSpec = "/module/http/*";
    logger.info("initializing http-handler. path={}", contextPath + pathSpec);
    context.addServlet(
            new ServletHolder(new ModuleHttpServlet(cfg, jvmSandbox.getCoreModuleManager())),
            pathSpec
    );

    httpServer.setHandler(context);
}