protected Handler addStatsHandler(Handler handler) { // Graceful shutdown is implemented via the statistics handler, // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=420142 final StatisticsHandler statisticsHandler = new StatisticsHandler(); statisticsHandler.setHandler(handler); return statisticsHandler; }
private AssetsHandler() { resourceHandler.setCacheControl("max-age=31536000,public"); resourceHandler.setEtags(false); }
/** * Adds a handler. * * @param handler the handler to add */ public void addHandler(AbstractHandler handler) { HandlerList handlers = new HandlerList(); handlers.addHandler(handler); for (Handler h : mServer.getHandlers()) { handlers.addHandler(h); } mServer.setHandler(handlers); }
public static Handler getJettyRequestLogHandler() { // Ref: http://www.eclipse.org/jetty/documentation/9.2.6.v20141205/configuring-jetty-request-logs.html RequestLogHandler requestLogHandler = new RequestLogHandler(); requestLogHandler.setRequestLog(new JettyRequestLog()); return requestLogHandler; } }
/** * Add the given handler to the end of the list of handlers. * * @param handler The handler to add */ public void addHandlerAtEnd(Handler handler) { handlers.addHandler(handler); }
private void loadRequestLogging() { // This makes the request log handler decorate whatever other handlers are already set up final RequestLogHandler requestLogHandler = new HttpChannelOptionalRequestLogHandler(); requestLogHandler.setRequestLog( requestLog ); requestLogHandler.setServer( jetty ); requestLogHandler.setHandler( jetty.getHandler() ); jetty.setHandler( requestLogHandler ); }
private void setAssetsDir(String assetsDir) { resourceHandler.setResourceBase(assetsDir); } }
public static WebAppContext getCurrentWebAppContext() { ContextHandler.Context context=ContextHandler.getCurrentContext(); if (context!=null) { ContextHandler handler = context.getContextHandler(); if (handler instanceof WebAppContext) return (WebAppContext)handler; } return null; }
private ErrorHandler createErrorHandler() { // Error handler to show detailed errors. // Should probably be turned off in production. final ErrorHandler errorHandler = new ErrorHandler(); errorHandler.setShowStacks(true); errorHandler.setShowMessageInTitle(true); return errorHandler; }
private Handler applyWrapper(Handler handler, HandlerWrapper wrapper) { wrapper.setHandler(handler); return wrapper; }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { super.handle(target, baseRequest, request, response); } });
private void setContextAttributes(ServletContextHandler context, Configuration conf) { context.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf); context.getServletContext().setAttribute(ADMINS_ACL, adminsAcl); }
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (shouldNotHandle()) return; this.resourceHandler.handle(target, baseRequest, request, response); }
@Override protected void doStart() throws Exception { super.doStart(); for (String key : handlers.keySet()) { handlers.get(key).start(); } }
@Override protected void doStop() throws Exception { super.doStop(); for (String key : handlers.keySet()) { handlers.get(key).stop(); } }
/** * Inform this container that the server has been started. * This method must be implicitly called after the server containing this container is started. * * @throws java.lang.Exception if a problem occurred during server startup. */ @Override protected void doStart() throws Exception { super.doStart(); appHandler.onStartup(this); }
/** * Inform this container that the server is being stopped. * This method must be implicitly called before the server containing this container is stopped. * * @throws java.lang.Exception if a problem occurred during server shutdown. */ @Override public void doStop() throws Exception { super.doStop(); appHandler.onShutdown(this); appHandler = null; }
private Handler applyWrapper(Handler handler, HandlerWrapper wrapper) { wrapper.setHandler(handler); return wrapper; }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // use the ResourceHandler to handle the request. This method calls doResponseHeaders internally super.handle(target, baseRequest, request, response); }