finalFileItemIteratoriter= getItemIterator(ctx); finalFileItemFactoryfileItemFactory= Objects.requireNonNull(getFileItemFactory(), "No FileItemFactory has been set."); finalbyte[] buffer = newbyte[Streams.DEFAULT_BUFFER_SIZE]; while (iter.hasNext()) { finalFileItemStreamitem= iter.next();
try { if (container instanceof Context) { Loaderloader= ((Context) container).getLoader(); // Loader will be null for FailedContext instances if (loader == null) { return; }
// Ensure background processing for Contexts and Wrappers // is performed under the web app's class loader originalClassLoader = ((Context) container).bind(false, null); } // 调用 Container 的 backgroundProcess container.backgroundProcess(); // 然后寻找 children Container[] children = container.findChildren(); for (Container child : children) { // 如果 backgroundProcessorDelay <= 0 就调用执行 // 否则代表这个 Container 有之前第八篇说的 StartChild 这种 if (child.getBackgroundProcessorDelay() <= 0) { processChildren(child); } } } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.error(sm.getString("containerBase.backgroundProcess.error"), t); } finally { if (container instanceof Context) { ((Context) container).unbind(false, originalClassLoader); } } } }
super(); pipeline.setBasic(newStandardEngineValve()); /* Set the jmvRoute using the system property jvmRoute */ try { setJvmRoute(System.getProperty("jvmRoute")); } catch(Exception ex) { log.warn(sm.getString("standardEngine.jvmRouteFail")); } // By default, the engine will hold the reloading thread backgroundProcessorDelay = 10;
// Validate our current component state if (!getState().isAvailable()) { thrownewIllegalStateException (sm.getString("standardContext.notStarted", getName())); }
之前在 Windows 里用 vmware workstation 搭了个黑裙,然后硬盘直通,硬盘跑着倒还好,但是宿主机 Windows 隔一段时间就会重启,就去搜索了下,发现其实 Windows 里的事件查看器就有点像是 Linux 系统里的 dmesg 或者 journal 日志,然后根据重启的时间排查事件查看器里,Windows 日志 –> 系统,
// Process the request in the adapter if (getErrorState().isIoAllowed()) { try { rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE); getAdapter().service(request, response);
然后到 coyoteAdapter 的 service org.apache.catalina.connector.CoyoteAdapter#service
1 2 3 4 5 6 7 8 9 10 11 12 13
try { // Parse and set Catalina and configuration specific // request parameters postParseSuccess = postParseRequest(req, request, res, response); if (postParseSuccess) { //check valves if we support async request.setAsyncSupported( connector.getService().getContainer().getPipeline().isAsyncSupported()); // Calling the container // ----------> 到这就是调用 pipeline 去处理了,我们要关注上面的 postParseRequest connector.getService().getContainer().getPipeline().getFirst().invoke( request, response); }
while (mapRequired) { // This will map the the latest version by default connector.getService().getMapper().map(serverName, decodedURI, version, request.getMappingData());
// If there is no context at this point, either this is a 404 // because no ROOT context has been deployed or the URI was invalid // so no context could be mapped. if (request.getContext() == null) { // Allow processing to continue.
if (contextVersion == null) { // Return the latest version // The versions array is known to contain at least one element contextVersion = contextVersions[versionCount - 1]; } mappingData.context = contextVersion.object;
然后是 wrapper
1 2 3 4
// Wrapper mapping if (!contextVersion.isPaused()) { internalMapWrapper(contextVersion, uri, mappingData); }
Engineengine= service.getContainer(); if (engine == null) { return; }
findDefaultHost();
addListeners(engine);
Container[] conHosts = engine.findChildren(); for (Container conHost : conHosts) { Hosthost= (Host) conHost; if (!LifecycleState.NEW.equals(host.getState())) { // Registering the host will register the context and wrappers registerHost(host); } } }