server.setConnectors(new Connector[] { http, https });
// Serve via servlet
final EnumSet<DispatcherType> dispatchers = EnumSet.range(
DispatcherType.FORWARD, DispatcherType.ERROR);
final ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SESSIONS
| ServletContextHandler.SECURITY);
// final SessionIdManager idManager = new HashSessionIdManager();
// final SessionManager sessionManager = new HashSessionManager();
// SessionHandler sessionHandler = new
// SessionHandler(sessionManager);
// sessionManager.setSessionIdManager(idManager);
// sessionManager.setSessionHandler(sessionHandler);
// handler.setSessionHandler(sessionHandler);
context.setContextPath("/");
final FilterHolder fh = new FilterHolder(WebFilter.class);
// let the filter know who to use to auto authenticate against when
// accessed by host machine
fh.setInitParameter(ActorType.ID.name(),
String.valueOf(actorExtractor.extract().getId()));
context.addFilter(fh, "/*", dispatchers);
final ServletHolder sh = new ServletHolder(
UGateWebSocketServlet.class);
context.addServlet(sh,
"/" + UGateWebSocketServlet.class.getSimpleName());
final ServletHolder sh2 = new ServletHolder(
UGateAjaxUpdaterServlet.class);
context.addServlet(sh2, "/*");
context.setErrorHandler(new ErrorHandler() {
@Override
public void handle(String target, Request baseRequest,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
// delegate errors to the filter