工作流内部部分代码
上一篇 /
下一篇 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技术