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;
}
Aggregations