1. package kaiyuansi; 
  2.  
  3. import org.jbpm.JbpmConfiguration; 
  4. import org.jbpm.JbpmContext; 
  5. import org.jbpm.graph.def.ProcessDefinition; 
  6.  
  7. public class InitJbpm { 
  8.     public static void main(String[] args) { 
  9.          //初始化表 
  10.         JbpmConfiguration.getInstance().createSchema(); 
  11.         //得到jbpm上下文 
  12.         JbpmContext context = JbpmConfiguration.getInstance().createJbpmContext(); 
  13.         //解析流程定义文件 
  14.         ProcessDefinition pd = ProcessDefinition.parseXmlResource("processdefinition.xml"); 
  15.         //部署流程 
  16.         context.deployProcessDefinition(pd); 
  17.         context.close(); 
  18.         //JbpmConfiguration.getInstance().dropSchema(); 
  19.  
  20.     } 
  21.  

 

 
  
  1. package kaiyuansi; 
  2.  
  3. import org.jbpm.JbpmConfiguration; 
  4. import org.jbpm.JbpmContext; 
  5. import org.jbpm.db.GraphSession; 
  6. import org.jbpm.graph.def.ProcessDefinition; 
  7. import org.jbpm.graph.exe.ProcessInstance; 
  8.  
  9. public class GoNote { 
  10.     public static void main(String[] args) { 
  11.         // 获得上下文 
  12.         JbpmContext context = JbpmConfiguration.getInstance() 
  13.                 .createJbpmContext(); 
  14.         // 流程控制器 
  15.         GraphSession graphSession = context.getGraphSession(); 
  16.         // 获取请假流程 
  17.         ProcessDefinition processDefinition = graphSession 
  18.                 .findLatestProcessDefinition("请假"); 
  19.         // 得到流程实例 
  20.         ProcessInstance pi = new ProcessInstance(processDefinition); 
  21.         pi.getContextInstance().setVariable("userId""mpconfig"); 
  22.         pi.signal(); 
  23.         pi.signal(); 
  24.         graphSession.saveProcessDefinition(processDefinition); 
  25.         context.save(pi); 
  26.         context.close(); 
  27.  
  28.     } 
  29.  

 

 
  
  1. <?xml version='1.0' encoding='utf-8'?> 
  2.  
  3. <!DOCTYPE hibernate-configuration PUBLIC 
  4.           "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
  5.           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 
  6.  
  7. <hibernate-configuration> 
  8.   <session-factory> 
  9.  
  10.     <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property> 
  11.     <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:ORCL</property> 
  12.     <property name="hibernate.connection.username">SYSTEM</property> 
  13.     <property name="hibernate.connection.password">mpconfig</property> 
  14.     <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property> 
  15.     <property name="hibernate.hbm2ddl.auto">update</property> 
  16.     <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property> 
  17.      
  18.     <property name="hibernate.show_sql">true</property> 
  19.  
  20.      
  21.      
  22.     <!-- DataSource properties (begin) === 
  23.     <property name="hibernate.connection.datasource">java:/JbpmDS</property> 
  24.     ==== DataSource properties (end) --> 
  25.      
  26.     <!-- JTA transaction properties (begin) === 
  27.     <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property> 
  28.     <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property> 
  29.     ==== JTA transaction properties (end) --> 
  30.  
  31.     <!-- CMT transaction properties (begin) === 
  32.     <property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property> 
  33.     <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property> 
  34.     ==== CMT transaction properties (end) --> 
  35.  
  36.     <!-- logging properties (begin) === 
  37.     <property name="hibernate.show_sql">true</property> 
  38.     <property name="hibernate.format_sql">true</property> 
  39.     <property name="hibernate.use_sql_comments">true</property> 
  40.     ==== logging properties (end) --> 
  41.      
  42.     <!-- ############################################ --> 
  43.     <!-- # mapping files with external dependencies # --> 
  44.     <!-- ############################################ --> 
  45.  
  46.     <!-- following mapping file has a dependendy on   --> 
  47.     <!-- 'bsh-{version}.jar'.                         --> 
  48.     <!-- uncomment this if you don't have bsh on your --> 
  49.     <!-- classpath.  you won't be able to use the     --> 
  50.     <!-- script element in process definition files   --> 
  51.     <mapping resource="org/jbpm/graph/action/Script.hbm.xml"/> 
  52.  
  53.     <!-- following mapping files have a dependendy on  --> 
  54.     <!-- 'jbpm-identity.jar', mapping files            --> 
  55.     <!-- of the pluggable jbpm identity component.     --> 
  56.     <!-- Uncomment the following 3 lines if you        --> 
  57.     <!-- want to use the jBPM identity mgmgt           --> 
  58.     <!-- component.                                    --> 
  59.     <!-- identity mappings (begin) --> 
  60.      
  61.     <mapping resource="org/jbpm/identity/User.hbm.xml"/> 
  62.     <mapping resource="org/jbpm/identity/Group.hbm.xml"/> 
  63.     <mapping resource="org/jbpm/identity/Membership.hbm.xml"/> 
  64.     <!-- identity mappings (end) --> 
  65.      
  66.     <!-- following mapping files have a dependendy on  --> 
  67.     <!-- the JCR API                                   --> 
  68.     <!-- jcr mappings (begin) === 
  69.     <mapping resource="org/jbpm/context/exe/variableinstance/JcrNodeInstance.hbm.xml"/> 
  70.     ==== jcr mappings (end) --> 
  71.  
  72.  
  73.     <!-- ###################### --> 
  74.     <!-- # jbpm mapping files # --> 
  75.     <!-- ###################### --> 
  76.  
  77.     <!-- hql queries and type defs --> 
  78.     <mapping resource="org/jbpm/db/hibernate.queries.hbm.xml" /> 
  79.      
  80.     <!-- graph.def mapping files --> 
  81.     <mapping resource="org/jbpm/graph/def/ProcessDefinition.hbm.xml"/> 
  82.     <mapping resource="org/jbpm/graph/def/Node.hbm.xml"/> 
  83.     <mapping resource="org/jbpm/graph/def/Transition.hbm.xml"/> 
  84.     <mapping resource="org/jbpm/graph/def/Event.hbm.xml"/> 
  85.     <mapping resource="org/jbpm/graph/def/Action.hbm.xml"/> 
  86.     <mapping resource="org/jbpm/graph/def/SuperState.hbm.xml"/> 
  87.     <mapping resource="org/jbpm/graph/def/ExceptionHandler.hbm.xml"/> 
  88.     <mapping resource="org/jbpm/instantiation/Delegation.hbm.xml"/> 
  89.  
  90.     <!-- graph.node mapping files --> 
  91.     <mapping resource="org/jbpm/graph/node/StartState.hbm.xml"/> 
  92.     <mapping resource="org/jbpm/graph/node/EndState.hbm.xml"/> 
  93.     <mapping resource="org/jbpm/graph/node/ProcessState.hbm.xml"/> 
  94.     <mapping resource="org/jbpm/graph/node/Decision.hbm.xml"/> 
  95.     <mapping resource="org/jbpm/graph/node/Fork.hbm.xml"/> 
  96.     <mapping resource="org/jbpm/graph/node/Join.hbm.xml"/> 
  97.     <mapping resource="org/jbpm/graph/node/State.hbm.xml"/> 
  98.     <mapping resource="org/jbpm/graph/node/TaskNode.hbm.xml"/> 
  99.  
  100.     <!-- context.def mapping files --> 
  101.     <mapping resource="org/jbpm/context/def/ContextDefinition.hbm.xml"/> 
  102.     <mapping resource="org/jbpm/context/def/VariableAccess.hbm.xml"/> 
  103.  
  104.     <!-- taskmgmt.def mapping files --> 
  105.     <mapping resource="org/jbpm/taskmgmt/def/TaskMgmtDefinition.hbm.xml"/> 
  106.     <mapping resource="org/jbpm/taskmgmt/def/Swimlane.hbm.xml"/> 
  107.     <mapping resource="org/jbpm/taskmgmt/def/Task.hbm.xml"/> 
  108.     <mapping resource="org/jbpm/taskmgmt/def/TaskController.hbm.xml"/> 
  109.  
  110.     <!-- module.def mapping files --> 
  111.     <mapping resource="org/jbpm/module/def/ModuleDefinition.hbm.xml"/> 
  112.  
  113.     <!-- bytes mapping files --> 
  114.     <mapping resource="org/jbpm/bytes/ByteArray.hbm.xml"/> 
  115.  
  116.     <!-- file.def mapping files --> 
  117.     <mapping resource="org/jbpm/file/def/FileDefinition.hbm.xml"/> 
  118.  
  119.     <!-- scheduler.def mapping files --> 
  120.     <mapping resource="org/jbpm/scheduler/def/CreateTimerAction.hbm.xml"/> 
  121.     <mapping resource="org/jbpm/scheduler/def/CancelTimerAction.hbm.xml"/> 
  122.  
  123.     <!-- graph.exe mapping files --> 
  124.     <mapping resource="org/jbpm/graph/exe/Comment.hbm.xml"/> 
  125.     <mapping resource="org/jbpm/graph/exe/ProcessInstance.hbm.xml"/> 
  126.     <mapping resource="org/jbpm/graph/exe/Token.hbm.xml"/> 
  127.     <mapping resource="org/jbpm/graph/exe/RuntimeAction.hbm.xml"/> 
  128.  
  129.     <!-- module.exe mapping files --> 
  130.     <mapping resource="org/jbpm/module/exe/ModuleInstance.hbm.xml"/> 
  131.          
  132.     <!-- context.exe mapping files --> 
  133.     <mapping resource="org/jbpm/context/exe/ContextInstance.hbm.xml"/> 
  134.     <mapping resource="org/jbpm/context/exe/TokenVariableMap.hbm.xml"/> 
  135.     <mapping resource="org/jbpm/context/exe/VariableInstance.hbm.xml"/> 
  136.     <mapping resource="org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml"/> 
  137.     <mapping resource="org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml"/> 
  138.     <mapping resource="org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml"/> 
  139.     <mapping resource="org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml"/> 
  140.     <mapping resource="org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml"/> 
  141.     <mapping resource="org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml"/> 
  142.     <mapping resource="org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml"/> 
  143.     <mapping resource="org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml"/> 
  144.  
  145.     <!-- job mapping files --> 
  146.     <mapping resource="org/jbpm/job/Job.hbm.xml"/> 
  147.     <mapping resource="org/jbpm/job/Timer.hbm.xml"/> 
  148.     <mapping resource="org/jbpm/job/ExecuteNodeJob.hbm.xml"/> 
  149.     <mapping resource="org/jbpm/job/ExecuteActionJob.hbm.xml"/> 
  150.  
  151.     <!-- taskmgmt.exe mapping files --> 
  152.     <mapping resource="org/jbpm/taskmgmt/exe/TaskMgmtInstance.hbm.xml"/> 
  153.     <mapping resource="org/jbpm/taskmgmt/exe/TaskInstance.hbm.xml"/> 
  154.     <mapping resource="org/jbpm/taskmgmt/exe/PooledActor.hbm.xml"/> 
  155.     <mapping resource="org/jbpm/taskmgmt/exe/SwimlaneInstance.hbm.xml"/> 
  156.  
  157.     <!-- logging mapping files --> 
  158.     <mapping resource="org/jbpm/logging/log/ProcessLog.hbm.xml"/> 
  159.     <mapping resource="org/jbpm/logging/log/MessageLog.hbm.xml"/> 
  160.     <mapping resource="org/jbpm/logging/log/CompositeLog.hbm.xml"/> 
  161.     <mapping resource="org/jbpm/graph/log/ActionLog.hbm.xml"/> 
  162.     <mapping resource="org/jbpm/graph/log/NodeLog.hbm.xml"/> 
  163.     <mapping resource="org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml"/> 
  164.     <mapping resource="org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml"/> 
  165.     <mapping resource="org/jbpm/graph/log/ProcessStateLog.hbm.xml"/> 
  166.     <mapping resource="org/jbpm/graph/log/SignalLog.hbm.xml"/> 
  167.     <mapping resource="org/jbpm/graph/log/TokenCreateLog.hbm.xml"/> 
  168.     <mapping resource="org/jbpm/graph/log/TokenEndLog.hbm.xml"/> 
  169.     <mapping resource="org/jbpm/graph/log/TransitionLog.hbm.xml"/> 
  170.     <mapping resource="org/jbpm/context/log/VariableLog.hbm.xml"/> 
  171.     <mapping resource="org/jbpm/context/log/VariableCreateLog.hbm.xml"/> 
  172.     <mapping resource="org/jbpm/context/log/VariableDeleteLog.hbm.xml"/> 
  173.     <mapping resource="org/jbpm/context/log/VariableUpdateLog.hbm.xml"/> 
  174.     <mapping resource="org/jbpm/context/log/variableinstance/ByteArrayUpdateLog.hbm.xml"/> 
  175.     <mapping resource="org/jbpm/context/log/variableinstance/DateUpdateLog.hbm.xml"/> 
  176.     <mapping resource="org/jbpm/context/log/variableinstance/DoubleUpdateLog.hbm.xml"/> 
  177.     <mapping resource="org/jbpm/context/log/variableinstance/HibernateLongUpdateLog.hbm.xml"/> 
  178.     <mapping resource="org/jbpm/context/log/variableinstance/HibernateStringUpdateLog.hbm.xml"/> 
  179.     <mapping resource="org/jbpm/context/log/variableinstance/LongUpdateLog.hbm.xml"/> 
  180.     <mapping resource="org/jbpm/context/log/variableinstance/StringUpdateLog.hbm.xml"/> 
  181.     <mapping resource="org/jbpm/taskmgmt/log/TaskLog.hbm.xml"/> 
  182.     <mapping resource="org/jbpm/taskmgmt/log/TaskCreateLog.hbm.xml"/> 
  183.     <mapping resource="org/jbpm/taskmgmt/log/TaskAssignLog.hbm.xml"/> 
  184.     <mapping resource="org/jbpm/taskmgmt/log/TaskEndLog.hbm.xml"/> 
  185.     <mapping resource="org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml"/> 
  186.     <mapping resource="org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml"/> 
  187.     <mapping resource="org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml"/> 
  188.      
  189.   </session-factory> 
  190. </hibernate-configuration> 

 

 
  
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2.  
  3. <process-definition  
  4.   xmlns="urn:jbpm.org:jpdl-3.2" 
  5.   name="请假"> 
  6.    <start-state name="开始"> 
  7.       <transition name="填写申请单" to="填写申请单"> 
  8.       </transition> 
  9.    </start-state> 
  10.    
  11.   <task-node name="填写申请单"> 
  12.      <task name="填写申请单"> 
  13.        <assignment actor-id="#{userId}"></assignment> 
  14.      </task> 
  15.      <transition name="班长审批" to="班长审批"></transition> 
  16.   </task-node> 
  17.    
  18.   <task-node name="班长审批"> 
  19.      <task name="班长审批"> 
  20.        <assignment actor-id="bz"></assignment> 
  21.      </task> 
  22.      <transition name="填写申请单" to="填写申请单"></transition> 
  23.      <transition name="班主任审批" to="班主任审批"></transition> 
  24.   </task-node> 
  25.    
  26.   <task-node name="班主任审批"> 
  27.     <task name="班主任审批"> 
  28.       <assignment actor-id="bzr"></assignment> 
  29.     </task> 
  30.     <transition to="填写申请单" name="填写申请单"></transition> 
  31.      <transition to="结束流程" name="结束流程"></transition> 
  32.   </task-node> 
  33.    
  34.     
  35.     
  36.    <end-state name="结束流程"></end-state> 
  37. </process-definition> 

 jar包下载地址 http://download.csdn.net/detail/mainstream_code/4256548