PE框架学习(2)

来源:互联网 发布:淘宝一键复制店铺 编辑:程序博客网 时间:2024/05/16 01:40

PE开发基础:

开发平台PowerEngine:


开发新功能:


业务逻辑处理:

1、Transaction:交易
2、Chain:链、责任链
3、Command:命令
4、Template:模板
5、Action:动作

PE交易处理流程:

无论一个交易的发送渠道是HTTP还是TCP,最终针对每一个渠道的Adapter会将请求的Form(HTTP)或报文(TCP)转换成与渠道无关的Context。
当渠道Adapter将数据转换为渠道无关的Context后,将控制权交给PowerEngine核心控制模块,根据该交易的交易Id,来确认该交易需要经过的处理过程。
  1. 首先执行Chain中的一系列Commands,若有其中一个Command认为需结束处理,则处理立刻结束;
  2. 当Chain执行到Delegate Command时,开始执行Template;
  3. 不同的Template会调用不同的Actions,以完成实际的交易处理。
简言之,根据交易Id可以唯一地确定Template,根据Template可以唯一地确定Chain,一旦确定了Chain,系统就按流程图所示开始执行处理。

总结:首先根据<transcation>中的id号,找到模板(template),然后再根据模板找到责任链(chain),一旦确认chain就按照流程图执行,从chain中执行command,执行到deletegatecommand后结束,跳到模板,再去执行<action>,然后跳转到相应的jsp页面。(/posweb/WebContent/WEB-INF/zh_CN/pos/LoanBaseInformationQuery.jsp)

Transaction:

一个业务处理功能的入口。
关键点:
    交易id
    引用的模板
    定义的action
    数据交验
    返回页面的渠道
transaction定义:
<transaction id=“preManagerAdd" template="引用的模版Id"><!--交易级定义的Actions.由模版来确定这些Actions的调用方法。--><actions><ref name="act01" >交易级定义的Action</ref></actions><!--对每一个域的有效性检查--><fields><field name="域名1">Style名称</field>。。。</fields><!--渠道的定义--><channels><!--HTTP渠道的定义--><channel type="http"><param name="success">result.jsp</param>        ......</channel></channels></transaction>
举例:posaction工程
/posaction/src/config/pos/trs/pos.xml
<transaction id="LoanBaseInformationQuery" template="queryTemplate"><description>@funcName@trsName 贷款基本信息查询@author@version 1.0@remark@fromPages</description><actions>//交易级的action<ref name="action">LoanBaseInformationQueryAction</ref></actions><fields><field name="ContractNo"></field></fields><channels><channel type="http"><param name="success">pos/LoanBaseInformationQuery</param></channel></channels></transaction><action id="LoanBaseInformationQueryAction"class="com.csii.ibs.pos.action.LoanBaseInformationQueryAction" parent="BaseQueryAction"></action>

Template:

Template定义:
<template id="模版Id" class="Full qualified class name of this Template" chain="引用的责任链Id">
各个Template:
emptyTemplate(空模板):
pageLoaderTemplate(初始化模板):
queryTemplate(查询模板)
trsConfirmTemplate(确认模板)
twoPhaseTrsTemplate(防重复提交)
entryTrsWorkflow(审核提交模板)

*交易级同名的Action将覆盖模版级

/poscommon/src/config/template.xml
<template id="queryTemplate" class="com.csii.pe.template.ExecutableSequenceTemplate" chain="chainForRoleControlMV"><actions>//模板级的action<ref name="action">Placeholder</ref>    <ref name="preAction">WriteQueryTrsJournal</ref></actions></template>

Chain:

系统级的交易逻辑抽象,如:交易的权限、登陆控制、日志和输入检查等 。
Chain定义:
<chain id="chain Id.">
<commands>
<ref>引用的command Id.</ref>
.......
</commands>
</chain>
-------------------------------------------------------------------------------------------------------------
/poscommon/src/config/chain.xml
<chain id="chainForRoleControlMV"><commands><ref>MultiVersionViewCommand</ref><ref>roleControlCommand</ref><ref>validationCommand</ref><ref>ruleCommand</ref><ref>delegateCommand</ref><ref>${chain.monitor}</ref></commands></chain>

Command:

Command定义:
<command id="command Id." class=" Full qualified class name of this Template" />
系统默认定义的commands:
  • DelegateCommand:每一个Chain必须有一个而且仅限于一个DelegateComand;
  • ValidationCommand:执行系统级的基于Style的有效性检查;
  • LoginControlCommand:用于控制用户访问服务的频率,主要用于登录交易。
  • RoleControlCommand:用于控制用户访问服务的权限,主要用于控制需要用户登录的交易的权限控制。对不需要用户登录的交易,不用该Command。
/poscommon/src/config/chain.xml
//......<command id="delegateCommand" class="com.csii.pe.chain.command.DelegateCommand" />//.......

Action:

Action是PowerEngine业务处理的最小单元,Action也是具体单个应用开发者需要直接面对的对象,通过Action实现交易单元处理,是交易的具体动作。
Action的定义:
<action id=“action Id” class=“Full qualified class name of this action”>   
<param name="property name">property value</param>
......
<ref name="property name">引用的对象的Id</ref>
......
</action>

Action只是一个Marker Interface。为了Action能进行特定的处理,开发人员应该实现相应的Interface。
init ()
Execute()
Submit()
Prepare()

Bean定义继承方式:
<action id="BaseQueryAction" class="com.csii.ibs.action.IbsQueryAction"><ref name="trsCodeResolver">hostTrsCodeResolver</ref><ref name="returnCodeValidator">hostReturnCodeValidator</ref><ref name="transportBean">${BaseQueryAction.hostTransportBean}</ref></action>继承<action id="ActBalAction" class="com.csii.ibs.query.action.ActBalAction" parent="BaseQueryAction"></action>等同<action id="ActBalAction" class="com.csii.ibs.query.action.ActBalAction" parent="BaseQueryAction"><ref name="trsCodeResolver">hostTrsCodeResolver</ref><ref name="returnCodeValidator">hostReturnCodeValidator</ref><ref name="transportBean">${BaseQueryAction.hostTransportBean}</ref></action>
Action:
BaseQueryAction(IbsQueryAction)
BaseTwoPhaseAction(IbsTwoPhaseAction)
CachedPagableQueryAction
DBPagableQueryAction

/poscommon/src/config/action.xml
<action id="WriteQueryTrsJournal" class="com.csii.ibs.common.jnl.WriteQueryTrsJournal">    <ref name="idFactory">idFactory</ref>    <param name="jnlSql">common.insertQryLog</param></action>


































2 0
原创粉丝点击