webx roadmap

SpringExt

自定义Spring Schema的例子

基于Spring可扩展Schema提供自定义配置支持

使用SpringExt扩展Webx的示例

扩展点和捐献

一个namespace下可以声明多个element。

扩展点:将namespace和接口关联起来。
捐献:将element和实现关联起来。

webx archetype

tutorial1


tutorial11.PNG
mvn archetype:generate -DgroupId=com.alibaba.webx -DartifactId=tutorial1 -Dversion=1.0-SNAPSHOT -Dpackage=com.alibaba.webx.tutorial1 -DarchetypeArtifactId=archetype-webx-quickstart -DarchetypeGroupId=com.alibaba.citrus.sample -DarchetypeVersion=1.8 -DinteractiveMode=false

login-webx3-tutorial

该示例是tutorial1示例中的“5. Form Validation”部分的内容。


login-webx3-tutorial.PNG
mvn archetype:generate -DgroupId=com.alibaba.webx -DartifactId=login-webx3-tutorial -Dversion=1.0-SNAPSHOT -Dpackage=com.alibaba.webx.tutorial -DarchetypeArtifactId=archetype-webx-quickstart -DarchetypeGroupId=com.alibaba.citrus.sample -DinteractiveMode=false

petstore

git clone https://github.com/webx/citrus-sample.git
cd citrus-sample/petstore
mvn clean install
cd web
mvn jetty:run-war

第五章

web应用根目录
就是指的是web项目的根目录。
/WEB-INF/web.xml
上述的/不是相对于操作系统而言,而是针对web项目而言。

charset

每一端都有input chaset 和output charset。这就好比socket通信,每一端都有输入流和输出流。

如何将url转为target

AnalyzeURLValve:取得target,action,actionEvent。
(1)通过request.getServletPath()+request.getPathInfo()获取请求的pathInfo,并通过MappingRuleService将pathInfo转为target。
(2)取得请求中的action参数。通过MappingRuleService得到最后的action。
(3)得到请求中的actionEvent。

对开发者的要求:
(1)配置MappingRuleService的映射规则。即<services:mapping-rules>

如何将target映射到action

PerformActionValve:根据action参数找到具体的action类,然后执行其execute()方法。
ModuleLoaderService.getModule(action).execute()
Module就是一个含execute()方法的接口。

<direct-module-rule>元素表示直接映射module,这是最简单的模块映射规则。
它映射Module的原理是:将URL路径"/"替换成".",除去文件名后缀,将最后一个单词首字母改成大写,以符合模块命名的规则。
比如http://abc.com/helloapp/path/hello.htm

webx根据你访问的URL target “path/hello.htm”,定位到 Module “path.hello.class”

    <services:module-loader>
        <ml-factories:class-modules>
            <search-packages type="$1" packages="com.alibaba.sample.petstore.web.common.module.*" />
        </ml-factories:class-modules>
    </services:module-loader>

webx相关blog

petstore-web的src目录如下:

src
└─main
    ├─java
    │  └─com
    │      └─alibaba
    │          └─sample
    │              └─petstore
    │                  └─web
    │                      ├─common
    │                      │  └─util
    │                      ├─home
    │                      │  └─module
    │                      │      └─screen
    │                      ├─servlet
    │                      ├─store
    │                      │  └─module
    │                      │      ├─action
    │                      │      ├─control
    │                      │      └─screen
    │                      └─user
    │                          └─module
    │                              ├─action
    │                              └─screen
    └─webapp
        ├─common
        │  └─templates
        │      ├─layout
        │      └─screen
        ├─home
        │  ├─css
        │  ├─images
        │  └─templates
        │      ├─control
        │      ├─layout
        │      └─screen
        ├─META-INF
        │  └─autoconf
        ├─store
        │  ├─css
        │  ├─images
        │  └─templates
        │      ├─control
        │      ├─layout
        │      └─screen
        │          └─edit
        ├─user
        │  ├─css
        │  └─templates
        │      ├─control
        │      ├─layout
        │      └─screen
        └─WEB-INF
            ├─common
            │  └─$petstore_upload
            ├─home
            ├─store
            └─user

WEB-INF目录


main下的两个目录分别是java和webapp。

从代码结构来看,整个petstore-web分成了3个模块(子应用),分别是home、user、store等3个模块。另外还有一个公共模块common。

java部分

java部分在com.alibaba.sample.petstore.web下有四个主要的子包common、home、user、store,分别对应4个模块。
然后在每个子包下面才是action、control、screen等module。

com.alibaba.sample.petstore.web.子模块.module.action.LoginAction;
com.alibaba.sample.petstore.web.子模块.module.screen.LoginAction;
com.alibaba.sample.petstore.web.子模块.module.control.LoginAction;

webapp部分

webapp目录下有4个子模块目录和WEB-INF目录。
四个子模块目录分别是common、home、user、store。每个里面都是存放的该模块的css、img、template等资源。

WEB-INF目录下的内容:

  • web.xml
  • 3个子模块目录(每个里面都是form.xml),每个子模块对应一个webx-*.xml
  • 公共子目录common,里面存放了共用的配置文件;以及一个总的webx.xml

每个子模块的webx-*.xml中都有一个装载模块的配置<services:module-loader>,对应着java中的package。

例如webx-home.xml中的配置片段是:<search-packages type="$1" packages="com.alibaba.sample.petstore.web.home.module.*" />
例如webx-user.xml中的配置片段是:<search-packages type="$1" packages="com.alibaba
posted @ 2017-07-06 22:36  凝静志远  阅读(564)  评论(0编辑  收藏  举报