Search in sources :

Example 1 with JULServletContextListener

use of org.killbill.commons.skeleton.listeners.JULServletContextListener in project killbill by killbill.

the class HttpServer method createServletContextHandler.

private ServletContextHandler createServletContextHandler(final String resourceBase, final Iterable<EventListener> eventListeners, final Map<FilterHolder, String> filterHolders) {
    final ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SESSIONS);
    context.setContextPath("/");
    if (resourceBase != null) {
        // Required if you want a webapp directory. See ContextHandler#getResource and http://docs.codehaus.org/display/JETTY/Embedding+Jetty
        final String webapp = this.getClass().getClassLoader().getResource(resourceBase).toExternalForm();
        context.setResourceBase(webapp);
    }
    // Jersey insists on using java.util.logging (JUL)
    final EventListener listener = new JULServletContextListener();
    context.addEventListener(listener);
    for (final EventListener eventListener : eventListeners) {
        context.addEventListener(eventListener);
    }
    for (final FilterHolder filterHolder : filterHolders.keySet()) {
        context.addFilter(filterHolder, filterHolders.get(filterHolder), EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC));
    }
    // Make sure Guice filter all requests
    final FilterHolder filterHolder = new FilterHolder(GuiceFilter.class);
    context.addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC));
    // Backend servlet for Guice - never used
    final ServletHolder sh = new ServletHolder(DefaultServlet.class);
    context.addServlet(sh, "/*");
    return context;
}
Also used : JULServletContextListener(org.killbill.commons.skeleton.listeners.JULServletContextListener) FilterHolder(org.eclipse.jetty.servlet.FilterHolder) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) EventListener(java.util.EventListener) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Aggregations

EventListener (java.util.EventListener)1 FilterHolder (org.eclipse.jetty.servlet.FilterHolder)1 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1 JULServletContextListener (org.killbill.commons.skeleton.listeners.JULServletContextListener)1