Webx mvc 源码

article/2025/9/29 0:40:33

Webx命名规范

这里写图片描述

Web请求响应

这里写图片描述
当Webx Framework接收到一个来自WEB的请求以后,实际上它主要做了两件事:
首先,它会增强request、response、session的功能,并把它们打包成更易使用的RequestContext对象。
其次,它会调用相应子应用的pipeline,用它来做进一步的处理。
假如在上面的过程中出现异常,则会触发Webx Framework处理异常的过程。
此外,Webx Framework还提供了一组辅助开发的功能,例如查看环境变量,查看schema等。这些功能只在开发模式生效,生产模式下自动关闭。

public class WebxFrameworkFilter extends FilterBean {private final Logger log = LoggerFactory.getLogger(this.getClass());private String parentContextAttribute;private WebxComponents components;private RequestURIFilter excludeFilter;private RequestURIFilter passthruFilter;private String internalPathPrefix;...protected final void init() throws Exception {WebApplicationContext parentContext = this.findParentContext();if(parentContext instanceof WebxComponentsContext) {this.components = ((WebxComponentsContext)parentContext).getWebxComponents();WebxConfiguration rootController = this.components.getParentWebxConfiguration();if(rootController != null) {this.internalPathPrefix = rootController.getInternalPathPrefix();this.internalPathPrefix = FileUtil.normalizeAbsolutePath(this.internalPathPrefix, true);}}WebxRootController rootController1 = this.components.getWebxRootController();if(this.passthruFilter != null) {if(rootController1 instanceof PassThruSupportable) {((PassThruSupportable)rootController1).setPassthruFilter(this.passthruFilter);} else {...}}}...@Overrideprotected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)throws IOException, ServletException {String path = getResourcePath(request);if (isExcluded(path)) {...return;} else {...}try {// 获取WebxRootController并且对request进行处理getWebxComponents().getWebxRootController().service(request, response, chain);} catch (IOException e) {throw e;} catch (ServletException e) {throw e;} catch (Exception e) {throw new ServletException(e);}}..
}

WebxRootController为接口,有一个实现了部分函数的抽象类AbstractWebxRootController

    public final void service(HttpServletRequest request, HttpServletResponse response, FilterChain chain)throws Exception {RequestContext requestContext = null;try {requestContext = assertNotNull(getRequestContext(request, response), "could not get requestContext");// 如果请求已经结束,则不执行进一步的处理。例如,当requestContext已经被重定向了,则立即结束请求的处理。if (isRequestFinished(requestContext)) {return;}// 请求未结束,则继续处理...request = requestContext.getRequest();response = requestContext.getResponse();// 如果是一个内部请求,则执行内部请求// webx内部请求,如报错,开发者模式页面if (handleInternalRequest(request, response)) {return;}// 如果不是内部的请求,并且没有被passthru,则执行handleRequest// handleRequest抽象方法if (isRequestPassedThru(request) || !handleRequest(requestContext)) {// 如果请求被passthru,或者handleRequest返回false(即pipeline放弃请求),// 则调用filter chain,将控制交还给servlet engine。giveUpControl(requestContext, chain);}} catch (Throwable e) {handleException(requestContext, request, response, e);} finally {commitRequest(requestContext);}}
package com.alibaba.citrus.webx.impl;import javax.servlet.http.HttpServletRequest;
import com.alibaba.citrus.service.requestcontext.RequestContext;
import com.alibaba.citrus.util.ServletUtil;
import com.alibaba.citrus.webx.WebxComponent;
import com.alibaba.citrus.webx.support.AbstractWebxRootController;
import com.alibaba.citrus.webx.util.WebxUtil;public class WebxRootControllerImpl extends AbstractWebxRootController {// 处理外部请求@Overrideprotected boolean handleRequest(RequestContext requestContext) throws Exception {// WebxFrameWorkFilter封装的request+response+sessionHttpServletRequest request = requestContext.getRequest();// Servlet mapping有两种匹配方式:前缀匹配和后缀匹配。// 对于前缀匹配,例如:/servlet/aaa/bbb,servlet path为/servlet,path info为/aaa/bbb// 对于前缀匹配,当mapping pattern为/*时,/aaa/bbb,servlet path为"",path info为/aaa/bbb// 对于后缀匹配,例如:/aaa/bbb.html,servlet path为/aaa/bbb.html,path info为null//// 对于前缀匹配,取其pathInfo;对于后缀匹配,取其servletPath。String path = ServletUtil.getResourcePath(request);// 再根据path查找componentWebxComponent component = getComponents().findMatchedComponent(path);boolean served = false;if (component != null) {try {WebxUtil.setCurrentComponent(request, component);served = component.getWebxController().service(requestContext);} finally {WebxUtil.setCurrentComponent(request, null);}}return served;}
}
public WebxComponent findMatchedComponent(String path) {if (!path.startsWith("/")) {path = "/" + path;}WebxComponent defaultComponent = getDefaultComponent();WebxComponent matched = null;// 前缀匹配componentPath。// 子应用for (WebxComponent c

http://chatgpt.dhexx.cn/article/07jX70Di.shtml

相关文章

WebX源码研读

WebX是公司应用最为广泛的web框架,目前已经开源。一直以为webX是基于spring MVC的,但其实并不是,那么不同之处到底在何处,又是为什么这样实现?看过了源码,在这里梳理下思路 我以为,在业务层面上…

WebX框架使用说明

前言 标准MVC开源框架有很多(Struts、SpringMVC、Webx),对于生活在开源世界里面的码农来说SpringMVC、Struts是接触比较多,也是最熟悉的框架。 知己知彼 以配置SpringMVC为例,我们常常关注的点主要有以下几个方面&a…

webx学习总结

webx学习总结 一 Webx的概括 WEBX是阿里巴巴的部框架,“就是把页面与Service之间的一些Servlet等公共的东西抽象出,提供相的服务以提高发效率(《接口之Webx介》—何晓峰 )”,可以看出,webx和统的servlet-ac…

Webx MVC分析

Webx框架&#xff1a;http://openwebx.org/ petstore:webx3/webx-sample/petstore/tags/3.0/petstore 编译之后&#xff1a;mvn jetty:run即可, 访问&#xff1a; http://localhost:8081/ Webx MVC(以webx3为基础) 1、webx3的入口点 <filter> <filter-name>…

Webx MVC

首先在Webx中&#xff0c;使用WebxContextLoaderListener替代Spring的ContextLoaderListener&#xff1a; <listener><listener-class>com.alibaba.citrus.webx.context.WebxContextLoaderListener</listener-class></listener><filter><filt…

Webx学习

六月中就要去阿里巴巴实习了,部门使用的web框架是Webx,喜大普奔的发现Webx是开源的,所以认真学习一下。主要参考指导手册 Webx总体介绍 设计理念 这里有许多框架设计的真知灼见! 一个框架的好坏,往往并不是由他所实现的具体功能好坏所决定的,而是由其所使用的基础框架…

webx mysql_idea使用Maven启动maven项目、 webx框架项目

一、打开 二、点击号选择maven 三、 (1)、Working directory : 选择项目路径 (2)、Command line: clean jetty:run-war -Djetty.port8086 -Dautoconfig.charsetUTF-8 -Dmaven.test.skip (3)、VM Options: -server -XX:PermSize256M -XX:MaxPermSize512M (4)、点击Environment V…

webx mysql_Webx项目的获取与验证

在JavaWeb环境配置后就可进行Webx实例项目的获取与研读了。 1.创建一个初始的Demo工程。 1)下载 Webx Maven 项目的目录结构Artifact插件。 2) 创建WebxDemo项目 打开命令行工具(Windows cmd或Unix/Linux bash)&#xff0c;输入如下命令&#xff1a; mvn archetype:generate -D…

Webx框架

Webx是一个框架&#xff0c;它可用来做下面的事情&#xff1a; 创建一个全功能的Web应用 Webx提供了创建一个Web应用所需要的所有必要功能. 创建一个新的Web框架 Webx允许你定制、甚至重写大部分的Webx框架逻辑&#xff0c;从而实现全新的功能&#xff0c;或者和其它应用框…

Webx简介(转)

经常会到博客来看看大家的一些文章&#xff0c;都写的相当精彩&#xff0c;有水平&#xff0c;感觉大家好像都写了&#xff0c;自己没什么写的&#xff0c;后来跟师傅婉佩沟通&#xff0c;才了解到这样想是错的&#xff0c;每个人针对每个东西可能想法观点都不同&#xff0c;写…

WebX入门指南

[说明] 本文围绕WebX的Web框架展开&#xff0c;试图将整个开发中使用的软件栈或者说生态系统串联起来。本文中不讲解原理性的东西&#xff0c;只是讲解各种场景下如何使用WebX相关的技术。入门指南中涉及到的实践指南和原理指南&#xff0c;不会展开&#xff0c;在后续博文中&a…

WebX框架解析及使用教程

WebX框架是阿里巴巴集团开发的&#xff0c;它建立在SpringEx的基础上&#xff0c;具有超强的扩展能力。 一、Webx的层次结构&#xff08;从里到外&#xff09; &#xff08;1&#xff09;SpringExt&#xff1a;基于Spring&#xff0c;提供扩展组件的能力 &#xff08;2&#xf…

VSCode中Emmet使用

文章目录 HTML部分1. 添加类&#xff0c;id&#xff0c;文本和属性2. 嵌套和分组3. 隐式标签4. 定义多个元素* 和 编号$5. 添加虚拟文字6. 其它 CSS部分1. 属性和属性值的缩写2. 属性值的单位其它 HTML部分 1. 添加类&#xff0c;id&#xff0c;文本和属性 div.box#box > …

linux vim emmet,emmet-vim

最近啊&#xff0c;我投奔了网页的开发&#xff0c;看了一本《head first HTML and CSS》的书&#xff0c;感觉非常不错&#xff0c;然后又配置了一些vim里面用到的插件&#xff0c;现在我把学习到的东西记录下来&#xff01; 首先&#xff0c;我不会在这里写emmet 的具体操作方…

Emmet 语法

Emmet语法前身是Zen coding&#xff0c;来提高html和css的编写速度&#xff0c;vscode内部已经集成该语法了 1、快速生成html结构语法 生成标签&#xff1a; 直接输入标签名&#xff0c;再按TAB键&#xff0c;such as 你打个 div 再按tab&#xff0c;就会直接生成 (这里打不出…

emmet写法

1.写一个递增的img路径 img[srcimage/com/$$.png]*10 效果

6.Emmet 语法与快速格式化代码

Emmet语法可以让我们在写网页的时候速度更快&#xff0c;我当前写网页的工具是pycharm&#xff0c;在pycharm中使用Emmet&#xff0c;我们需要点击File,然后点击Setting 搜索emmet&#xff0c;保证这里是勾选状态 安装后如果不进行其他设置&#xff0c;emmet自动被勾选 目录 …

Emmet语法总结

1 Emmet简介 Emmet是一个Web开发工具&#xff0c;用于加快HTML和CSS代码的编写速度。使用Emmet能够通过简短的表达式生成HTML或CSS代码片段。另外&#xff0c;截至2022年&#xff0c;主流的编辑器工具如Visual Studio Code、WebStorm都已经集成了Emmet工具&#xff0c;无需手动…

Linux 配置全面讲解(安装JDK、Mysql、Nginx)

1 Linux概述 1.1 Linux介绍 Linux是一套免费使用和自由传播的类Unix操作系统&#xff0c;是一个基于POSIX和UNIX的多用户、多任务、支持多线程和多CPU的操作系统。它能运行主要的UNIX工具软件、应用程序和网络协议。它支持32位和64位硬件。Linux继承了Unix以网络为核心的设计思…

【JAVA秒会技术之ConcurrentHashMap】JDK1.7与JDK1.8源码区别

前言 以前写过介绍HashMap的文章&#xff0c;文中提到过HashMap在put的时候&#xff0c;插入的元素超过了容量&#xff08;由负载因子决定&#xff09;的范围就会触发扩容操作&#xff0c;就是rehash&#xff0c;这个会重新将原数组的内容重新hash到新的扩容数组中&#xff0c;…