/* ------------------------------------------------------------ */ public ServletContextHandler( HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler, int options) { super((ContextHandler.Context) null); _options = options; _scontext = new Context(); _sessionHandler = sessionHandler; _securityHandler = securityHandler; _servletHandler = servletHandler; _objFactory = new DecoratedObjectFactory(); _objFactory.addDecorator(new DeprecationWarning()); if (contextPath != null) setContextPath(contextPath); if (parent instanceof HandlerWrapper) ((HandlerWrapper) parent).setHandler(this); else if (parent instanceof HandlerCollection) ((HandlerCollection) parent).addHandler(this); // Link the handlers relinkHandlers(); if (errorHandler != null) setErrorHandler(errorHandler); }
/** @param servletHandler The servletHandler to set. */ public void setServletHandler(ServletHandler servletHandler) { if (isStarted()) throw new IllegalStateException("STARTED"); Handler next = null; if (_servletHandler != null) { next = _servletHandler.getHandler(); _servletHandler.setHandler(null); replaceHandler(_servletHandler, servletHandler); } _servletHandler = servletHandler; if (next != null && _servletHandler.getHandler() == null) _servletHandler.setHandler(next); relinkHandlers(); }
/** @param gzipHandler The {@link GzipHandler} to set on this context. */ public void setGzipHandler(GzipHandler gzipHandler) { if (isStarted()) throw new IllegalStateException("STARTED"); Handler next = null; if (_gzipHandler != null) { next = _gzipHandler.getHandler(); _gzipHandler.setHandler(null); replaceHandler(_gzipHandler, gzipHandler); } _gzipHandler = gzipHandler; if (next != null && _gzipHandler.getHandler() == null) _gzipHandler.setHandler(next); relinkHandlers(); }
/** * Insert a HandlerWrapper before the first Session,Security or ServletHandler but after any other * HandlerWrappers. */ public void insertHandler(HandlerWrapper handler) { HandlerWrapper h = this; // Skip any injected handlers while (h.getHandler() instanceof HandlerWrapper) { HandlerWrapper wrapper = (HandlerWrapper) h.getHandler(); if (wrapper instanceof SessionHandler || wrapper instanceof SecurityHandler || wrapper instanceof ServletHandler) break; h = wrapper; } h.setHandler(handler); relinkHandlers(); }