从我的新浪博客转过来的

官方提供的userguide从大的方面阐述了jBPM的基本流程和概念,总结一下其思路:
    一:发布
    1.一切从Configuration开始:Configuration configuration = new Configuration();
    2.然后构建 ProcessEngine:ProcessEngine processEngine = configuration().buildProcessEngine();
    3.有了ProcessEngine,一切就都有了:
        RepositoryService repositoryService = processEngine.getRepositoryService();
        ExecutionService executionService = processEngine.getExecutionService();
        TaskService taskService = processEngine.getTaskService();
        HistoryService historyService = processEngine.getHistoryService();
        ManagementService = processEngine.getManagementService();
    4.发布了:String deploymentId = repositoryService.createDeployment()
                               .addResourceFromClassPath("org/jbpm/Order.jpdl.xml")
                               .deploy();
    5.现在删除它吧:repositoryService.deleteDeployment(deploymentId);
        当然,还有另一个方法:repositoryService.deleteDeploymentCascade(deploymentId);//将删除相关instance和history。

 

Obtain ProcessEngine from a Configuration:
     ProcessEngine processEngine = new Configuration().buildProcessEngine();
    those code will load this default configuration file jbpm.cfg.xml which is expected in the root of the classpath.
Get ProcessEngine from your own configuration file by Configuration:
     ProcessEngine processEngine = new Configuration().setResource("myconfigurationfile.xml").bulidProcessEngine();
Now you can obtain the following services:
    RepositoryService repositoryService = processEngine.getRepositoryService();
    ExecutionService executionService = processEngine.getExecutionService();
    TaskService taskService = processEngine.getTaskService();
    HistoryService historyService = processEngine.getHistoryService();
    ManagementService managementService = processEngine.getManagementService();
Deploying a process:
     String deploymentId = repositoryService.createDeployment().addResourceFromClassPath("org/jbpm/my.jpdl.xml").deploy();
Deleting a deployment:
     repositoryService.deleteDeployment(deploymentId);
    repositoryService.deleteDeploymentCascade(deploymentId);
 
 

Starting a new process instance

Simplest and most common way: 
    ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL");
Specific process version:
    ProcessInstanc processInstance = executionService.startProcessInstanceById("ICL-1");

With a key:
     ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL","CL92837");
With variables:
    Map<String,Object> variables = new HashMap<String,Object>();
    variables.put("customer","John Doe");
    variables.put("type","Accident");
    ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL",variables);

startProcessInstanceByKey和startProcessInstanceById的区别:
前者会根据key寻找最近的deployment版本,后者是直接寻找到特定版本。
 
 
jbpm 顺序执行一个流程
 
  ProcessInstance processInstance = excutionService.startProcessInstanceByKey("StateSequence");

    Execution executionInA = processInstance.findActiveExecutionIn("a");

    processInstance = executionService.signalExecutionById(executionInA.getId());
    Execution executionInB = processInstance.findActiveExecutionIn("b");

    processInstance = executionService.signalExecutionById(executionInB.getId());
    Execution executionInC = processInstance.findActiveExecutionIn("c");
 
 
ProcessInstance processInstance = executionService.startProcessInstanceByKey("StateChoice");

    String executionId = processInstance.findActiveExecutionIn("wait for response").getId();

    processInstance = executionService.signalExecutionById(executionId,"accept");

    assertTrue(processInstance.isActive("submit document"));
 
 
Map<String,Object> variables = new HashMap<String,Object>();
    variables.put("content","good");
    ProcessInstance processInstance = executionService.startProcessInstanceByKey("DecisionConditions",variables);
    assertTrue(processInstance.isActive("submit document"));
 
mysql在hibernate中的配置
<? xml version='1.0' encoding='UTF-8' ?>
<! DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"
>

<!--  Generated by MyEclipse Hibernate Tools.                    -->
< hibernate-configuration >

    
< session-factory >
        
< property  name ="connection.username" > root </ property >
        
< property  name ="connection.url" >jdbc:mysql://localhost:3306/jbpmdb </ property >
        
< property  name ="dialect" > org.hibernate.dialect.MySQLDialect </ property >
        
< property  name ="myeclipse.connection.profile" > bbs </ property >
        
< property  name ="connection.password" >pwd </ property >
        
< property  name ="connection.driver_class" > com.mysql.jdbc.Driver </ property >
        
< property  name ="show_sql" > true </ property >
        
< mapping  resource ="com/bbs/hibernate/User.hbm.xml" ></ mapping >
     </ session-factory >

 

Hibernate之hbm2ddl

 

<property name="hibernate.hbm2ddl.auto">

</property>

它包含4个属性:

    * create : 会根据你的model类来生成表,但是每次运行都会删除上一次的表,重新生成表,哪怕2次没有任何改变

    * create-drop : 根据model类生成表,但是sessionFactory一关闭,表就自动删除

    * update : 最常用的属性,也根据model类生成表,即使表结构改变了,表中的行仍然存在,不会删除以前的行

    * validate : 只会和数据库中的表进行比较,不会创建新表,但是会插入新值



</ hibernate-configuration >
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值