- 浏览: 35006 次
- 性别:
- 来自: 重庆
文章分类
最新评论
-
walle1027:
感谢,正式需要的
spring3 hibernate4 如何支持EventListener 系统操作日志 -
paomo30000:
你好博主。请问为什么测试类里可以跑通,但到了实际项目里却得到是 ...
JBPM 4.3 Email与Notification例子 -
dml123:
smtp服务器需要认证的该把认证信息加到哪里呢,我加到prop ...
JBPM 4.3 Email与Notification例子
最近很纠结。JBPM4。3的问题。
说明我的应用开发环境是:JPBM4.3,Spring2.0整个项目框架基于SSH搭建。数据库为MySql5.0。
第一步:项目的配置文件
数据库db.properties
#development
dev.connection.driver_class=com.mysql.jdbc.Driver
dev.connection.url=jdbc:mysql://localhost:3306/test_oatianai?useUnicode=true&characterEncoding=UTF-8
dev.connection.username=root
dev.connection.password=123456
#test
test.connection.driver_class=com.mysql.jdbc.Driver
test.connection.url=jdbc:mysql://localhost:3306/test_oatianai?useUnicode=true&characterEncoding=UTF-8
test.connection.username=root
test.connection.password=123456
hibernate的配置文件为jbpm4.3中带的hibernate.cfg.xml
jbpm4.3的jbpm配置文件如下:jbpm.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.tx.spring.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.bpmn.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<import resource="jbpm.console.cfg.xml" />
<import resource="jbpm.jobexecutor.cfg.xml" />
<!--配置 Spring-->
<process-engine-context>
<string name="spring.cfg" value="spring/spring-jbpm.xml" />
</process-engine-context>
<!-- 扩展用户
<transaction-context>
<identity-session />
<object class="your.package.YourIdentitySessionImpl" />
</transaction-context>
<transaction-context>
<identity-session current="true"/>
<object class="" />
</transaction-context>
-->
</jbpm-configuration>
JBPM4.3中配置Spring相对JBPM4.0要简单一些。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/test_oatianai?useUnicode=true&characterEncoding=UTF-8" />
<property name="username" value="root" />
<property name="password" value="123456" />
</bean>
这里本是想这样来配置JBPM的服务
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
<bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
但这样会报错误,说无法这样创建executionService BEAN,希望大家给指点一下。
整个项目的搭建配置与JBPM4相关的到此配置也就完成。
第二步:表数据模块,我的实例是基于请款而写的,业务表单Bean如下:
ublic class ApplyMoneyForm {
private Long id;
private String applyuser;
private String reason;
private float applynum;
private String suggestion1;
private String decision1;
private String manager;
private String suggestion2;
private String decision2;
private String boss;
private String processid;
public String getDecision1() {
return decision1;
}
public void setDecision1(String decision1) {
this.decision1 = decision1;
}
public String getDecision2() {
return decision2;
}
public void setDecision2(String decision2) {
this.decision2 = decision2;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getApplyuser() {
return applyuser;
}
public void setApplyuser(String applyuser) {
this.applyuser = applyuser;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public float getApplynum() {
return applynum;
}
public void setApplynum(float applynum) {
this.applynum = applynum;
}
public String getSuggestion1() {
return suggestion1;
}
public void setSuggestion1(String suggestion1) {
this.suggestion1 = suggestion1;
}
public String getManager() {
return manager;
}
public void setManager(String manager) {
this.manager = manager;
}
public String getSuggestion2() {
return suggestion2;
}
public void setSuggestion2(String suggestion2) {
this.suggestion2 = suggestion2;
}
public String getBoss() {
return boss;
}
public void setBoss(String boss) {
this.boss = boss;
}
这是表彰数据。
第三步:业务数据与流程实例结合
流程定义文件applymoney.xml
<process name="applymoney" xmlns="http://jbpm.org/4.0/jpdl" key="applymoney"
description="请款流程定义">
<start g="207,78,53,48" name="start1">
<transition g="-40,-16" name="to 填写请款单" to="填写请款单" />
</start>
<task assignee="#{user}" g="176,203,110,55" name="填写请款单">
<transition g="-32,-11" name="to 经理审核" to="经理审核" />
</task>
<task assignee="#{manager}" g="182,300,101,50" name="经理审核">
<transition g="-7,-13" name="同意" to="老板审核">
</transition>
<transition g="345,324;345,229:-13,-10" name="驳回" to="填写请款单">
</transition>
<transition g="347,324:-14,60" name="不同意" to="cancel1">
</transition>
</task>
<task assignee="boss" g="186,398,98,48" name="老板审核">
<transition g="-14,-8" name="同意" to="end1">
</transition>
<transition g="137,421;133,230:-11,11" name="驳回" to="填写请款单">
</transition>
<transition g="-27,-11" name="不同意" to="cancel1">
</transition>
</task>
<end g="109,490,66,42" name="end1" />
<end-cancel g="325,489,82,52" name="cancel1" />
</process>
流程管理ApplyMoneyManager.java
package com.cqta.oatianai.jbpm;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jbpm.api.Execution;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.TaskService;
import org.jbpm.api.task.Task;
import org.jbpm.pvm.internal.task.TaskImpl;
import com.cqta.oatianai.model.ApplyMoneyForm;
public class ApplyMoneyManager {
private ProcessEngine processEngine;
public void setProcessEngine(ProcessEngine processEngine) {
this.processEngine = processEngine;
}
/**
*发起请款流
* @param username
*/
public String startApplyMoney(String username){
Map<String, Object> variables=new HashMap<String, Object>();
variables.put("user", username);
ExecutionService executionService=processEngine.getExecutionService();
ProcessInstance processInstance=executionService.startProcessInstanceByKey("applymoney", variables);
String processId=processInstance.getId();
return processId;
}
/**
* 请假表单结合
* @param applyMoneyForm
*/
public void applyMoney(ApplyMoneyForm applyMoneyForm){
Map<String, Object> variables=new HashMap<String, Object>();
variables.put("manager", applyMoneyForm.getManager());
TaskService taskService=processEngine.getTaskService();
List<Task> listTasks=taskService.findPersonalTasks(applyMoneyForm.getApplyuser());
if(listTasks.size()<=0){
return ;
}
Task task=listTasks.get(0);
taskService.setVariables(task.getId(), variables);
taskService.completeTask(task.getId());
}
public void confirm(ApplyMoneyForm applyMoneyForm,String taskId){
TaskService taskService=processEngine.getTaskService();
Task task=taskService.getTask(taskId);
System.out.println("executionId==========>"+task.getExecutionId());
ExecutionService executionService=processEngine.getExecutionService();
Execution execution=executionService.findExecutionById(task.getExecutionId());
if(execution.getProcessInstance().isActive("经理审核")){
taskService.completeTask(task.getId(),applyMoneyForm.getDecision1());
}else if(execution.getProcessInstance().isActive("老板审核")){
taskService.completeTask(task.getId(), applyMoneyForm.getDecision2());
}
}
}
这里红色标识的就是最近纠结的地方了,findExecutionById(task.getExecutionId())本身应去JBPM4_Execution表中的ID_字段,但去取JBPM4_Execution表中的DBID_字段。前一个字段为字符类型,后一个字段为long型。这个问题在Sqlserver2000与oracle中都出现了问题。希望大家帮忙解决一下。原来是hibernate的版本搞错了
表单数据与流程实例相继合我是在Controller中进行的,不知是否合理。ApplyMoneyController
package com.cqta.oatianai.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.jbpm.api.task.Task;
import com.cqta.core.utils.BeanUtils;
import com.cqta.core.web.ApplicationController;
import com.cqta.oatianai.dao.ApplyMoneyFormDaoImpl;
import com.cqta.oatianai.jbpm.ApplyMoneyManager;
import com.cqta.oatianai.jbpm.PersonTasks;
import com.cqta.oatianai.model.ApplyMoneyForm;
public class ApplyMoneyController extends ApplicationController{
private ApplyMoneyManager applyMoneyManager;
private ApplyMoneyFormDaoImpl applyMoneyFormDaoImpl;
private PersonTasks personTasks;
public void setApplyMoneyManager(ApplyMoneyManager applyMoneyManager) {
this.applyMoneyManager = applyMoneyManager;
}
public void setApplyMoneyFormDaoImpl(ApplyMoneyFormDaoImpl applyMoneyFormDaoImpl) {
this.applyMoneyFormDaoImpl = applyMoneyFormDaoImpl;
}
public void setPersonTasks(PersonTasks personTasks) {
this.personTasks = personTasks;
}
public ActionForward applyMoney(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("apply_money");
}
public ActionForward managerApproval(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String taskId=request.getParameter("taskId");
String procesId=personTasks.getProcessInstanceIdByTaskId(taskId);
ApplyMoneyForm applyMoneyForm=applyMoneyFormDaoImpl.findApplyMoneyForm(procesId);
request.setAttribute("applyMoneyForm", applyMoneyForm);
request.setAttribute("taskId", taskId);
return mapping.findForward("apply_money_manager");
}
public ActionForward bossApproval(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String taskId=request.getParameter("taskId");
String processId=personTasks.getProcessInstanceIdByTaskId(taskId);
ApplyMoneyForm applyMoneyForms=applyMoneyFormDaoImpl.findApplyMoneyForm(processId);
request.setAttribute("applyMoneyForm", applyMoneyForms);
request.setAttribute("taskId", taskId);
return mapping.findForward("apply_money_boss");
}
/**
* 发起请假流程
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward startApply(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ApplyMoneyForm applyMoneyForm=new ApplyMoneyForm();
BeanUtils.populate(applyMoneyForm,request.getParameterMap());
String processId=applyMoneyManager.startApplyMoney(applyMoneyForm.getApplyuser());
applyMoneyManager.applyMoney(applyMoneyForm);
applyMoneyForm.setProcessid(processId);
applyMoneyFormDaoImpl.startApplyMoney(applyMoneyForm);
return mapping.findForward("apply_money");
}
/**
* 经理审批
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward managerApprovaled(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ApplyMoneyForm applyMoneyForm=new ApplyMoneyForm();
String taskId=request.getParameter("taskId");
System.out.println("taskId============>"+taskId);
BeanUtils.populate(applyMoneyForm,request.getParameterMap());
applyMoneyManager.confirm(applyMoneyForm, taskId);
applyMoneyFormDaoImpl.updateApplyMoney(applyMoneyForm, applyMoneyForm.getId());
return mapping.findForward("apply_money_manager");
}
/**
* 老板审批
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward bossApprovaled(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ApplyMoneyForm applyMoneyForm=new ApplyMoneyForm();
String taskId=request.getParameter("taskId");
BeanUtils.populate(applyMoneyForm, request.getParameterMap());
applyMoneyManager.confirm(applyMoneyForm, taskId);
applyMoneyFormDaoImpl.updateApplyMoney(applyMoneyForm,applyMoneyForm.getId());
return mapping.findForward("apply_money_boss");
}
/**
* 获取用户列表
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward taskLists(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String userName=request.getParameter("username");
List<Task> taskList=personTasks.findByPerson(userName);
System.out.println("=========>"+taskList.size());
request.setAttribute("taskList", taskList);
return mapping.findForward("index");
}
}
这就是一个 SSH与JBPM4。3与实际业务相结合。正在探索中学习JBPM啦。
本文中的问题已解决,是因为hibernate得版本问题。我的项目中有两个hibernate,一个是JBPM包下的,一个是我自己加上的。唉,细节呀
相关推荐
然后,将 spring.jbpm.cfg.xml 文件复制到 classpath 中,改名为 jbpm.cfg.xml。 流程设计器安装 要安装流程设计器,用户可以使用 Eclipse 3.5 的 Help-Install New Software-Archive 功能,定位到 ${jbpm.home}/...
jbpm jbpm4.3.jar DDDDDDDD
JBPM4.3开发指南.chm中文说明不错的文档,强烈推荐,下载学习的好帮手
3. jbpm.wire.bindings.xml:这可能涉及到jbpm中的信号和事件绑定。在jbpm中,信号和事件可以触发流程的某些行为,例如流程的跳转或结束。理解这些绑定有助于了解流程如何响应外部事件。 4. jbpm.task.hbm.xml:...
jbpm-4.3-src.rar_bdf-jbpm4 src _jboss 4.3_jboss jbpm4.3_jbpm-4.3 这个压缩包文件包含的是JBOSS jBPM4.3的源代码,这是一个用于业务流程管理(BPM)的开源框架。jBPM是一个强大的工具,它提供了流程定义、执行和...
SSH+JBPM4.3的整合是企业级应用开发中的一种常见组合,SSH指的是Spring、Struts和Hibernate这三个开源框架的集成,而JBPM4.3则是一个强大的工作流管理系统,用于实现业务流程自动化。这篇内容将深入探讨这两个技术...
jbPM 4.3 可以无缝集成到其他Java EE应用中,例如EJB、JMS、JPA和Spring框架。此外,它还支持与外部系统(如ERP、CRM)的集成,通过服务代理(Service Task)实现服务调用。 **9. 持久化机制** jbPM 4.3 使用JPA...
**jbpm4.3:开启开源工作流新篇章** jbpm4.3是一个强大的开源工作流管理系统,它允许开发者和业务分析师...无论是在中小型企业还是大型组织中,jbpm4.3都能发挥出其强大的功能,助力企业优化业务流程,提升运营效率。
- `jbpm-4.3/install/src/cfg/jbpm/spring.jbpm.cfg.xml`:JBPM与Spring集成的关键配置文件。 #### 三、配置文件调整 接下来,我们将对这些配置文件进行必要的修改。 1. **调整`hibernate.cfg.xml`**:在`...
在这个"jbpm4.3工作流程管理例子"中,我们将深入探讨jbpm4.3的核心特性和如何利用它来构建实际的工作流程应用。 一、jbpm4.3核心特性 1. 工作流引擎:jbpm4.3提供了强大的工作流引擎,可以执行基于流程定义的业务...
- **jbpm.hibernate.cfg.xml**:这是jBPM与Hibernate集成的核心配置文件。配置了多个映射文件,如`jbpm.repository.hbm.xml`等。 ```xml <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate ...
【JBPM4.3培训学习视频】是一套针对初学者设计的教程,旨在...通过这套全面的教程,学习者不仅能掌握JBPM4.3的基本操作,还能了解工作流管理系统在实际业务场景中的应用,为后续的进阶学习和实际项目开发打下坚实基础。
jbpm4.3 开发手册,chm格式文档,方便查看。
在这个教程中,我们将探讨Jbpm4.3版本中的核心概念、特性以及如何通过实例来理解和应用它们。 首先,视频教程可能涵盖以下几个关键点: 1. **Jbpm介绍**:介绍Jbpm的起源、目标和在业务流程管理(BPM)领域的地位,...
通过阅读《jbpm4.3中文开发指南》,开发者不仅能了解JBPM4.3的基础知识,还能学习到如何在实际项目中部署和使用该框架。无论是新手还是经验丰富的开发者,都能从中受益,提升业务流程管理的能力。在实践中,不断探索...
4. **规则集成**:jbpm4.3集成了Drools规则引擎,允许在流程中嵌入决策逻辑。通过Drools,开发者可以编写复杂的业务规则,并在流程执行时动态应用这些规则。 5. **事件处理**:系统能够监听并响应各种事件,如流程...
在JBPM 4.3版本中,为了实现完整功能,需要一系列的jar包来支持其运行环境。这些jar包包含了核心引擎、持久化、工作流定义、任务服务、事件处理、事务管理等多个组件。 1. **核心引擎**:jbpm-runtime-engine.jar是...
在《jbpm jbpm4 jbpm4.3 工作流》这本书中,作者可能会详细讲解上述知识点,并通过实例演示如何使用jbpm4.3进行流程设计、部署和运行。这本书对于学习和理解jbpm4.3的工作流管理理念和技术是极有帮助的,尤其适合IT...
根据提供的文件信息,可以归纳出以下关于JBPM 4.3中文用户手册的相关知识点: ### JBPM 4.3 概述 - **JBPM**(JBoss Business Process Management)是一个开源的工作流引擎,用于创建、管理和执行业务流程。 - **...