YAWL的研究总结(之二)


接(之一) http://blog.csdn.net/james999/archive/2004/10/11/132598.aspx 

首先更正(之一)的一些错误: Task 元素 可以没有指向Decomposition元素,则表明者是一个 empty task ,直接运行

        这两天阅读YAWL的代码是在是“头痛”啊,yawl的代码没有一行注释,于是我要边跟踪程序,边阅读代码,边自己补充一些注释。—— 最可气的是,yawl的资料几乎没有什么,除了他自己网站的一点文档,其他实质性文档没有:没有结构体系的介绍、没有模型描述语言的介绍 。



YNet

    public final class YNet extends Ydecomposition<o:p></o:p>

<o:p> </o:p>

    Ynet对象表示了 Control Flow的信息。其就是对 processControlElements xml元素中的Task流程的记载。<o:p></o:p>

<o:p> </o:p>

YAWLCancel 处理

    有关Cancelxml定义<o:p></o:p>

                   <task id="cancel"><o:p></o:p>

                       <flowsInto><o:p></o:p>

                            <nextElementRef id="fin_make_itinerary"/><o:p></o:p>

                       </flowsInto><o:p></o:p>

                       <join code="and"/><o:p></o:p>

                       <split code="and"/><o:p></o:p>

                       <removesTokens id="register"/><o:p></o:p>

                       <removesTokens id="ableToCancel"/><o:p></o:p>

                       <removesTokens id="do_itinerary_segment"/><o:p></o:p>

                       <removesTokens id="pay"/><o:p></o:p>

                       <decomposesTo id="cancel"/><o:p></o:p>

                   </task><o:p></o:p>

<o:p> </o:p>

YAWLMultipleInstanceExternalTaskFactsType

    一段样例的Task定义如下<o:p></o:p>

<task id="record" xsi:type="MultipleInstanceExternalTaskFactsType"><o:p></o:p>

     <flowsInto><o:p></o:p>

         <nextElementRef id="selectSongs"/><o:p></o:p>

     </flowsInto><o:p></o:p>

     <join code="xor"/><o:p></o:p>

     <split code="and"/><o:p></o:p>

     <startingMappings><o:p></o:p>

         <mapping><o:p></o:p>

              <expression query="&lt;nameOfPerformer&gt;{for $d in /data/nameOfArtist return $d/text()}&lt;/nameOfPerformer&gt;"/><o:p></o:p>

              <mapsTo>nameOfPerformer</mapsTo><o:p></o:p>

         </mapping><o:p></o:p>

         <mapping><o:p></o:p>

              <expression query="/data/nameOfRecord"/><o:p></o:p>

              <mapsTo>nameOfRecord</mapsTo><o:p></o:p>

         </mapping><o:p></o:p>

     </startingMappings><o:p></o:p>

     <decomposesTo id="RecordSong"/><o:p></o:p>

     <minimum>1</minimum><o:p></o:p>

     <maximum>10</maximum><o:p></o:p>

     <threshold>4</threshold><o:p></o:p>

     <creationMode code="dynamic"/><o:p></o:p>

     <miDataInput><o:p></o:p>

         <expression query="&lt;songlist&gt;{if ( count(/data/songlist/*) &gt; 0) then /data/songlist/* else /data/songList_backup/* }&lt;/songlist&gt;"/><o:p></o:p>

         <splittingExpression query="for $d in /songlist/* return &lt;songLocal&gt; { for $e in $d/* return $e } &lt;/songLocal&gt;"/><o:p></o:p>

         <formalInputParam>songLocal</formalInputParam><o:p></o:p>

     </miDataInput><o:p></o:p>

     <miDataOutput><o:p></o:p>

         <formalOutputExpression query="/data/songLocal"/><o:p></o:p>

         <outputJoiningExpression query="&lt;songlist&gt;{for $d in /data/songLocal return &lt;song&gt;{ for $e in $d/* return $e }&lt;/song&gt;}&lt;/songlist&gt;"/><o:p></o:p>

         <resultAppliedToLocalVariable>songlist</resultAppliedToLocalVariable><o:p></o:p>

     </miDataOutput><o:p></o:p>

</task><o:p></o:p>

<o:p> </o:p>

    注意,在YAWL解析task xml元素的时候,有关MultipleInstanceExternalTaskFactsType 的相关属性,是跟随在其Task对象(YexternalTask类)内的。而不想其他一些属性,比如flowsIntoinputMapping等等之类,是存放于Ynet对象(记录整个流程相关信息)<o:p></o:p>

<o:p> </o:p>

    Moreover, it is possible to indicate that the task terminates the moment a certain threshold of instances has completed. The momentthis threshold is reached, all running instances are terminated and the task completes.If no threshold is specified, the task completes once all instances have completed.<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

<o:p> </o:p>

YAWLSpecification解析原理

Root Net元素会编译成为 YNet对象。Decomposition的类型如果为“NetFactsType”,则也编译为Ynet对象,如果为“WebServiceGatewayFactsType”,则编译为YAWLServiceGateway 对象。<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

<o:p> </o:p>

<o:p> </o:p>

YAWLToken处理机制

    当然,Token是存储在 ConditionPlace)之中。<o:p></o:p>

    YAWLplace接口是 Ycondition,其实现类是 au.edu.qut.yawl.elements.YexternalCondition<o:p></o:p>

<o:p> </o:p>

这个Condition类中有一个YidentifierBag对象: protected YIdentifierBag _bag;<o:p></o:p>

    利用YIdentifierBag对象来记录 当前Condition中所包含的 Token,以及这个Token的值(或者说叫作数量)。<o:p></o:p>

    来看看YidentifierBag处理原则:<o:p></o:p>

    /**<o:p></o:p>

     * 新增Token对象<o:p></o:p>

     * @param identifier 代表Token对象<o:p></o:p>

     */       <o:p></o:p>

     public void addIdentifier(YIdentifier identifier){<o:p></o:p>

         /**<o:p></o:p>

          * 不光新增token,而且还记录这个token的数量(相当于记录多个token<o:p></o:p>

          */<o:p></o:p>

        int amount = 0;<o:p></o:p>

        if(_idToQtyMap.containsKey(identifier)){<o:p></o:p>

            amount = ((Integer) _idToQtyMap.get(identifier)).intValue();<o:p></o:p>

        }<o:p></o:p>

        _idToQtyMap.put(identifier, new Integer(++amount));<o:p></o:p>

        identifier.addLocation(_condition);<o:p></o:p>

     }<o:p></o:p>

<o:p> </o:p>

    <o:p></o:p>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值