时间:2023-07-12 09:03:02 | 来源:网站运营
时间:2023-07-12 09:03:02 来源:网站运营
牛逼!硬核图解 Tomcat 整体架构:// Calling the containerconnector.getService().getContainer().getPipeline().getFirst().invoke(request, response);
wrapper 容器的最后一个 valve 创建一个 filter 链,并调用 doFilter 方法,最终会调用到 servlet 的 service 方法。 final class StandardWrapperValve extends ValveBase { @Override public final void invoke(Request request, Response response) throws IOException, ServletException { // ... ApplicationFilterChain filterChain = ApplicationFilterFactory.createFilterChain(request, wrapper, servlet); // Call the filter chain for this request // NOTE: This also calls the servlet's service() method Container container = this.container; try { if ((servlet != null) && (filterChain != null)) { // Swallow output if needed if (context.getSwallowOutput()) { try { SystemLogHandler.startCapture(); if (request.isAsyncDispatching()) { request.getAsyncContextInternal().doInternalDispatch(); } else { // dofilter filterChain.doFilter(request.getRequest(), response.getResponse()); } } finally { String log = SystemLogHandler.stopCapture(); if (log != null && log.length() > 0) { context.getLogger().info(log); } } } else { if (request.isAsyncDispatching()) { request.getAsyncContextInternal().doInternalDispatch(); } else { // dofilter filterChain.doFilter (request.getRequest(), response.getResponse()); } } } } catch() { // ... } }}
ServletContext 是 tomcat 中的一个成员变量,spring 中的 ApplicationContext 是 servlet 规范中的 ServletContext 属性。原作者:rhspher
原文链接:牛逼!硬核图解 Tomcat 整体架构
原出处:码农code之路
侵删
关键词:整体,图解