/** Creates a sub invocation, handing unmapped URLs and stopped webApps. */ private WebApp buildSubInvocation(Invocation invocation) { if (!_lifecycle.waitForActive(_startWaitTime)) { UnavailableException e; e = new UnavailableException(invocation.getURI()); FilterChain chain = new ExceptionFilterChain(e); invocation.setFilterChain(chain); invocation.setDependency(AlwaysModified.create()); return null; } WebAppController appController = getWebAppController(invocation); if (appController == null) { String url = invocation.getURI(); FileNotFoundException e = new FileNotFoundException(url); FilterChain chain = new ExceptionFilterChain(e); invocation.setFilterChain(chain); invocation.setDependency(AlwaysModified.create()); return null; } WebApp webApp = appController.subrequest(); if (webApp == null) { UnavailableException e; e = new UnavailableException(invocation.getURI()); FilterChain chain = new ExceptionFilterChain(e); invocation.setFilterChain(chain); invocation.setDependency(AlwaysModified.create()); return null; } return webApp; }
/** 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; }