/** Adds a rewrite dispatch rule */ public void add(RewriteFilter dispatchAction) { if (dispatchAction.isRequest()) { RewriteDispatch rewrite = createRewriteDispatch(); rewrite.addAction(dispatchAction); } }
/** Adds a rewrite dispatch rule */ public void add(DispatchRule dispatchRule) { if (dispatchRule.isRequest()) { RewriteDispatch rewrite = createRewriteDispatch(); rewrite.addRule(dispatchRule); } }
/** Creates the invocation. */ @Override public Invocation buildInvocation(Invocation invocation) throws ConfigException { if (_configException != null) { FilterChain chain = new ExceptionFilterChain(_configException); invocation.setFilterChain(chain); invocation.setDependency(AlwaysModified.create()); return invocation; } else if (!_lifecycle.waitForActive(_startWaitTime)) { log.fine(this + " container is not active"); int code = HttpServletResponse.SC_SERVICE_UNAVAILABLE; FilterChain chain = new ErrorFilterChain(code); invocation.setFilterChain(chain); invocation.setWebApp(getErrorWebApp()); invocation.setDependency(AlwaysModified.create()); return invocation; } FilterChain chain; WebAppController controller = getWebAppController(invocation); WebApp webApp = getWebApp(invocation, controller, true); boolean isAlwaysModified; if (webApp != null) { invocation = webApp.buildInvocation(invocation); chain = invocation.getFilterChain(); isAlwaysModified = false; } else if (controller != null) { int code = HttpServletResponse.SC_SERVICE_UNAVAILABLE; chain = new ErrorFilterChain(code); ContextFilterChain contextChain = new ContextFilterChain(chain); contextChain.setErrorPageManager(getErrorPageManager()); chain = contextChain; invocation.setFilterChain(contextChain); isAlwaysModified = true; } else { int code = HttpServletResponse.SC_NOT_FOUND; chain = new ErrorFilterChain(code); ContextFilterChain contextChain = new ContextFilterChain(chain); contextChain.setErrorPageManager(getErrorPageManager()); chain = contextChain; invocation.setFilterChain(contextChain); isAlwaysModified = true; } if (_rewriteDispatch != null) { String uri = invocation.getURI(); String queryString = invocation.getQueryString(); FilterChain rewriteChain = _rewriteDispatch.map(DispatcherType.REQUEST, uri, queryString, chain); if (rewriteChain != chain) { // server/13sf, server/1kq1 WebApp rootWebApp = findWebAppByURI("/"); if (rootWebApp == null) { // server/1u12 rootWebApp = getErrorWebApp(); } invocation.setWebApp(rootWebApp); // server/1k21 vs server/1kk7 // if (rootWebApp != webApp) rewriteChain = rootWebApp.createWebAppFilterChain(rewriteChain, invocation, true); invocation.setFilterChain(rewriteChain); isAlwaysModified = false; } } if (isAlwaysModified) invocation.setDependency(AlwaysModified.create()); return invocation; }