现在面向过程开发展示出他独特的魅力,我也是附庸风雅的自己鼓捣下,写了一个基于程序流程控制的Xml文档结构图,入下所示。希望对大家有所启发,他是面向对象基础的升级于升华。不知大家是否明白。 呵呵~~~~
<?xml version="1.0" encoding="UTF-8"?>
<flows namespace="haoxiaojie">
<flow id="parent-flow" abstract="true">
<!-- Filter:表明该流程是从Spring IOC 中 getBean 获取执行代码 -->
<step type="filter" name="spring-bean-id(1)" />
<step type="filter" name="spring-bean-id(2)" />
<step type="filter" name="spring-bean-id(3)" />
<step type="filter" name="spring-bean-id(4)" />
</flow>
<flow id="demo-flow" parent="parentFlow">
<step type="filter" name="spring-bean-id(5)" />
<!-- 如果满足 EL表达式的结果['hao'] == 'qiu' 则在当前程序处理流程中加入 sub-flow 的内容继续运行 -->
<step type="join" name="sub-flow" spel="['hao'] == 'qiu'" />
<!-- 如果满足 EL表达式的结果['sum'] != 99 则运行内嵌的节点Filter -->
<step type="join" name="" spel="['sum'] != 99">
<step type="filter" name="spring-bean-id" />
<step type="filter" name="spring-bean-id" />
</step>
<!-- type="condition" 为流程分支点,按照处理结果进行不同的分支处理 -->
<step type="condition" spel="['hao'].value">
<next on="hao" to="swtich-bean-1" />
<next on="qiu" to="swtich-bean-2" />
</step>
<step type="filter" name="swtich-bean-1" />
<step type="filter" name="swtich-bean-2" />
<!-- merger="true" 表明是否于合并 parent flow 同样配置的信息-->
<!-- end 正常处理完业务流程之后需要处理的代码配置 -->
<end merger="true">
<step type="filter" name="spring-bean-id" />
<step type="filter" name="spring-bean-id" />
</end>
<!-- fail 中间发生异常时需要处理的代码段 -->
<fail merger="false">
</fail>
<!-- listeners 在解析程序流过程中的监听事件,可以配置多个,按顺序触发 -->
<listeners merger="true">
<listener name="spring-listeners-bean" />
</listeners>
</flow>
<flow id="sub-flow" abstract="true">
<step type="filter" name="spring-bean-id(7)" />
<step type="filter" name="spring-bean-id(8)" />
<!-- 基于Spring PlatformTransactionManager 的数据库事务声明 开启事务 -->
<step type="transaction" name="start" />
<step type="filter" name="spring-bean-id(9)" />
<step type="filter" name="spring-bean-id(10)" />
<!-- 基于Spring PlatformTransactionManager 的数据库事务声明 提交事务 -->
<step type="transaction" name="cmmit" />
</flow>
</flows>