论坛首页 Java版 JBoss

Jbpm并发子流程又一解决方案

浏览 1060 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
时间:2007-07-24 关键字: JBPM 开源工作流引擎专栏

并发子流程一直是困扰Jbpm爱好者的一大难题,JeffreyHsu 曾给出一个通过循环fork的解决方案(http://www.javaeye.com/article/29917),实际上jbpm也可以使用挂接action的方式生成子流程,所有生成的子流程都由同一个rootTooken下的childrenTooken来维护

流程定义如下

xml 代码
  1. xml version="1.0" encoding="UTF-8"?>  
  2.   
  3. <process-definition  xmlns=""  name="主流程">  
  4.    <start-state name="开始节点">  
  5.       <transition name="fork" to="fork">transition>  
  6.    start-state>  
  7.    <fork name="fork">  
  8.       <transition name="子流程分派" to="子流程分派节点">transition>  
  9.    fork>  
  10.    <state name="子流程分派节点">  
  11.       <transition name="结束所有子流程" to="结束所有子流程处理节点">transition>  
  12.       <transition name="子流程" to="子流程"> 
  13.       <transition name="增加子流程" to="子流程分派节点">  
  14.          <action name="创建子流程" class="createSubProcess">  
  15.             <leavename>子流程名称leavename>  
  16.          action>  
  17.       transition>  
  18.    state>  
  19.    <process-state name="子流程">  
  20.      <sub-process name="子流程名称" />  
  21.       <transition name="" to="join">  
  22.       transition>  
  23.    process-state>  
  24.    <node name="结束所有子流程处理节点">  
  25.    <event type="node-enter">  
  26.    <action name="结束所有子流程" class="killAllSubProcess" />  
  27.   event>  
  28.   <transition to="join"/>  
  29.    node>  
  30.    <join name="join">  
  31.       <transition  to="end">transition>  
  32.    join>  
  33.    <end-state name="end">end-state>  
  34. process-definition>  

class killAllSubProcess implements ActionHandler {

  public void execute(ExecutionContext executionContext) throws Exception {
   int i = 0;
   Map m = executionContext.getProcessInstance().getRootToken().getActiveChildren();
   Iterator iter = m.values().iterator();
   while( iter.hasNext() ) {
    Token t = (Token)iter.next();
    if( t.getSubProcessInstance()!=null) {
     t.getSubProcessInstance().end();
     i++;
    }
   }
  } }

class createSubProcess implements ActionHandler {

String leavename;
 
 public void execute(ExecutionContext executionContext) throws Exception {
  Token childToken = new Token( executionContext.getToken(), "TK" + ((new Random()).nextInt()) );
  ExecutionContext newctx = new ExecutionContext(childToken);
  executionContext.getTransitionSource().leave(newctx, leavename );
 }

}

 

   
时间:2008-04-12
请问楼住:
<property name="mappingLocations">
<value>classpath*:/org/jbpm/**/*.hbm.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="jdbc.fetch_size">50</prop>
<prop key="jdbc.batch_size">30</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.use_outer_join">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">
true
</prop>
</props>
</property>
以上是意思,能否请解一下。谢谢
   
0 请登录后投票
论坛首页 Java版 JBoss

跳转论坛:
JavaEye推荐
    快速回复 引用上一条消息 (Alt+S)