Valve请求,用于控制过程的操作。它采用责任设计模式链(类别似至struts拦截器)。valve阀装置,阀控制水流量(网络请求)趋势。

他们阀门定义。

public class MyValve implements Valve {
public void invoke(PipelineContext pipelineContext) throws Exception {
System.out.println("valve started.");
pipelineContext.invokeNext(); // 调用后序 valves
System.out.println("valve ended.");
}
} <services:pipeline xmlns="http://www.alibaba.com/schema/services/pipeline/valves">
...
<valve class="com.alibaba.myapp.pipeline.MyValve" />
...
</services:pipeline>

调用一个阀。能够通过Autowired获取一个阀。

@Autowired
private Pipeline myPipeline;
public void invokePipeline() {
PipelineInvocationHandle invocation = myPipeline.newInvocation();
invocation.invoke();
}

一个valve能够调用另外一个Pipeline。

能够中断随意一个pipeline调用。

pipelineContext.breakPipeline(0); // level=0,中断当前 pipeline
pipelineContext.breakPipeline(1); // level=1,中断上一级 pipeline
pipelineContext.breakPipeline("label"); // 中断到指定 label 的上级 pipeline
// 以上调用相当于:
pipelineContext.breakPipeline(pipelineContext.findLabel("label"));
pipelineContext.breakPipeline(Pipeline.TOP_LABEL); // 终止全部 pipelines

内置valve。

loop。

<loop loopCounterName="count" maxLoopCount="10">
<valve />
<break-if test="..." />
</loop> <while maxLoopCount="10">
<conditions:condition class="..." />
<valve />
</while> <if>
<conditions:condition class="..." />
<valve />
</if> <choose>
<when test="1 == 2">
<valve />
</when>
<when>
<conditions:condition class="..." />
<valve />
</when>
<otherwise>
<valve />
</otherwise>
</choose> 在循环中使用
<exit /> 在循环中使用
<break-if test="count &gt; 2" />
<break-if toLabel="MY_LOOP">
<conditions:condition class="..." />
</break-if>
<break-unless test="count &lt;= 2" /> <try-catch-finally>
<try>
<valve />
</try>
<catch exceptionName="myexception">
<valve />
</catch>
<finally>
<valve />
</finally>
</try-catch-finally> 条件支持jexl和自己定义的condition类。 <if>
<conditions:jexl-condition expr="loopCount == 2" />
<break />
</if> 等价:
<if test="loopCount == 2">
<break />
</if> <all-of>
<condition1 />
<condition2 />
<condition3 />
</all-of> <any-of>
<condition1 />
<condition2 />
<condition3 />
</any-of> <none-of>
<condition1 />
<condition2 />
<condition3 />
</none-of>

以下介绍一下常见的阀门。

analyzeURL。

分析URL,作用是得到target。

它有一个homepage參数,作用是默认页面。

choose。相当于java中的switch语句。条件能够通过两种属性指定,target-extension-condition或者target-condition。以下是choose语句的样例。

<choose>
<when>
<pl-conditions:target-extension-condition extension="null, vm, jsp" />
...
</when>
<when>
<pl-conditions:target-extension-condition extension="do" />
...
</when>
<otherwise>
...
</otherwise>
</choose>

performAction。运行Action来处理表单。

webx中的Action和其它框架中的不一样。这里仅仅处理表单。其它的框架中可能还会在Action中渲染页面。

performTemplateScreen。它的作用是查找相应的Screen代码,并运行。假设target为xxx/yyy/zzz那么框架会依次寻找screen.xxx.yyy.Zzz、screen.xxx.yyy.Default、screen.xxx.Default、screen.Default。并调用它的execute(Context,HttpServletRequest)方法。在哪里寻找这些类呢?能够在webx.xml中的module-loader/search-packages中指定根包。

renderTemplate。渲染模板。假设target是xxx/yyy/zzz那么框架会依次尝试寻找/templates/screen/xxx/yyy/zzz、/templates/screen/xxx/yyy/default、/templates/screen/xxx/default、/templates/screen/default。假设没有找到模板,会报404的错误。找到screen模板以后,框架还会尝试寻找layout:/templates/layout/xxx/yyy/zzz、/templates/layout/xxx/yyy/default等。

breakUnlessTargetRedirected。在对循环条件。假设有内部发生重定向,所以圈外。

版权声明:本文博客原创文章。博客,未经同意,不得转载。

Webx框架:Valve详细解释的更多相关文章

  1. WebX框架的页面授权

    WebX框架的页面授权 什么是页面授权,简单来说就是对于一个Web应用程序里,哪些页面可以被哪些人在什么情况下访问进行限制.举个简单的例子,有些页面只有用户登录以后才能访问,而另外一些页面无论是否用户 ...

  2. 深入webx框架(li)

    目录 1.Webx简介 2.创建webx应用   一.Webx简介 Webx本质上就是一个Web框架,它建立在Java Servlet API基础之上.上图所示是webx的架构图.webx本身类似于s ...

  3. Webx框架自带的petstore

    Webx框架:http://openwebx.org/ petstore:webx3/webx-sample/petstore/tags/3.0/petstore 编译之后:mvn jetty:run ...

  4. Nginx location配置详细解释

    nginx location配置详细解释 语法规则: location [=|~|~*|^~] /uri/ { - } = 开头表示精确匹配 ^~ 开头表示uri以某个常规字符串开头,理解为匹配 ur ...

  5. Spring中IOC和AOP的详细解释(转)

    原文链接:Spring中IOC和AOP的详细解释 我们是在使用Spring框架的过程中,其实就是为了使用IOC,依赖注入,和AOP,面向切面编程,这两个是Spring的灵魂. 主要用到的设计模式有工厂 ...

  6. Spring学习13-中IOC(工厂模式)和AOP(代理模式)的详细解释

    我们是在使用Spring框架的过程中,其实就是为了使用IOC,依赖注入,和AOP,面向切面编程,这两个是Spring的灵魂. 主要用到的设计模式有工厂模式和代理模式. IOC是工厂模式参考:设计模式- ...

  7. #pragma详细解释(一)

    #pragma详细解释 #pragma详细解释(一) 2010-04-18 14:21:00|  分类: 默认分类 |  标签: |字号大中小订阅     在#Pragma是预处理指令它的作用是设定编 ...

  8. Webx框架:Spring Schema 和 Spring Ext

    webx诞生的原因是当时市面上没有好用的web框架.如今的Web框架有非常多.然后它们背后的思想都是相似的,并且越来越趋同. Spring Schema 在传统的spring中,配置bean时须要手动 ...

  9. 关于javascript中静态成员和实例成员的详细解释

    关于javascript中静态成员和实例成员的详细解释  在我们了解什么是静态成员和实例成员之前,我们首先来了解一下什么是实例? 实例就是由构造函数创建出来的对象. 例如案例中 p 就是实例: fun ...

随机推荐

  1. Bootstrap 是一个用于快速开发 Web 应用程序和网站的前端框架

    Bootstrap 是一个用于快速开发 Web 应用程序和网站的前端框架.Bootstrap 是基于 HTML.CSS.JAVASCRIPT 的. 历史 Bootstrap 是由 Twitter 的 ...

  2. hdu1114(完全背包)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1114 分析:很裸的一道完全背包题,只是这里求装满背包后使得价值最少,只需初始化数组dp为inf:dp[ ...

  3. 事务的使用示例及WinForm实现中的若干问题

    --事务的使用示例 create database MyDB go use MyDB create table account ( Id int identity primary key, balan ...

  4. C++ Preprosessor import

    #import Attributes Provides links to attributes used with the #import directive. Microsoft Specific ...

  5. Entity Framework6使用SQL Server Compact免安装部署

    原文:Entity Framework6使用SQL Server Compact免安装部署 使用Nuget安装以下包: EntityFramework.6.0.2 EntityFramework.Sq ...

  6. WPF换肤之八:创建3D浏览效果

    原文:WPF换肤之八:创建3D浏览效果 上节中,我们展示了WPF中的异步以及界面线程交互的方式,使得应用程序的显示更加的流畅.这节我们主要讲解如何设计一个具有3D浏览效果的天气信息浏览器. 效果显示 ...

  7. Windows phone 8 学习笔记(5) 图块与通知

    原文:Windows phone 8 学习笔记(5) 图块与通知 基于metro风格的Windows phone 8 应用提到了图块的概念,它就是指启动菜单中的快速启动图标.一般一个应用必须有一个默认 ...

  8. include设置属性在relativelayout布局中无效

    转自:http://4265337.blog.163.com/blog/static/195375820127935731114/ 再来说一个在使用这两个标签时最容易出现的问题. 经常会有同学在Rel ...

  9. Wooden Sticks(杭州电1051)

    Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  10. Android编程之LayoutInflater的inflate方法实例

    假设你不关心其内部实现,仅仅看怎样使用的话,直接看这篇就可以. 接上篇,接下来,就用最最简单的样例来说明一下: 用两个布局文件main 和 test: 当中,main.xml文件为: <?xml ...