工作流内部部分代码

上一篇 / 下一篇  2007-01-03 21:22:11 / 个人分类:JAVA技术

查看( 1018 ) / 评论( 0 )

Using the the InMemoryWorklist

Here is a small example on how to use the InMemoryWorklist :

package test;

import openwfe.org.engine.workitem.WorkItem;
import openwfe.org.engine.workitem.LaunchItem;
import openwfe.org.engine.workitem.InFlowWorkItem;
import openwfe.org.engine.workitem.AttributeUtils;
import openwfe.org.embed.engine.Engine;
import openwfe.org.embed.worklist.Worklist;
import openwfe.org.embed.impl.engine.InMemoryEngine;
import openwfe.org.embed.impl.engine.AbstractEmbeddedParticipant;
import openwfe.org.embed.impl.worklist.InMemoryWorklist;


public class TestWorklist
{
    public static void main (String[] args)
        throws Exception
    {
        //
        // prepare engine

        Engine engine = new InMemoryEngine();

        // prepare worklists

        InMemoryWorklist wla = new InMemoryWorklist("a");
        InMemoryWorklist wlb = new InMemoryWorklist("b");

        // register participants

        engine.registerParticipant(wla);
        engine.registerParticipant(wlb);

        //
        // launch flow

        LaunchItem li = new LaunchItem();
        li.setWorkflowDefinitionUrl("field:__definition__");

        String flowDef = 
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
            "<process-definition name=\"test\" revision=\"0.0\">\n"+
            "   <sequence>\n"+
            "      <participant ref=\"a\" />\n"+
            "      <participant ref=\"b\" />\n"+
            "   </sequence>\n"+
            "</process-definition>";

        li.getAttributes().puts("__definition__", flowDef);

        engine.launch(li, true);

        //
        // play with the flow

        System.out.println("wla.countWorkItems() : "+wla.countWorkItems());
        System.out.println("wlb.countWorkItems() : "+wlb.countWorkItems());

        java.util.Iterator it = wla.iterator();

        InFlowWorkItem wi = (InFlowWorkItem)it.next();

        wla.forward(wi);

        System.out.println("\n ~~ forwarded workitem\n");

        System.out.println("wla.countWorkItems() : "+wla.countWorkItems());
        System.out.println("wlb.countWorkItems() : "+wlb.countWorkItems());
    }
}

As you can see, those embedded worklist are registrable in the engine as embedded participants may be.


TAG: JAVA技术

我来说两句

(可选)

日历

« 2024-04-16  
 123456
78910111213
14151617181920
21222324252627
282930    

我的存档

数据统计

  • 访问量: 28380
  • 日志数: 35
  • 图片数: 1
  • 建立时间: 2007-01-02
  • 更新时间: 2007-01-14

RSS订阅

Open Toolbar