- 浏览: 21431 次
- 性别:
- 来自: 杭州
最新评论
JBPM 实践
环境
安装Eclipse3.3
安装MyEclipse6.0
安装Tomcat5.5
安装MySQL5.0
下载JBoss jBPM Starters Kit 3.1.2
下载后解压到 D:\jbpm-starters-kit-3.1.2。目录下含有五个子目录:
jbpm jBPM的软件包,包含源码,例子等文件内容。
jbpm-bpel只含有一个网页
jbpm-db各种数据库hibernate配置文件示例,有些还包含了相应的jdbc驱动程序。
jbpm-designer辅助开发jBPM的Eclipse插件,具体在jbpm-gpd-feature子目录中
jbpm-server一个已经配置好了的基于JBoss的jBPM示例。
安装jBPM的Eclipse开发插件(略)
配置
1.导入工程
启动myEclipse,通过“Import”将jBPM工程导入eclipse中.
2.建库
在MySQL中建立数据库jbpm。字符集采用GBK。建表SQL如下:
CREATE DATABASE `jbpm`
CHARACTER SET 'gbk'
COLLATE 'gbk_chinese_ci';
3.添加MySQL驱动
在工程jbpm的lib目录下建立mysql文件夹,将MySQL需要的JDBC驱动程序拷贝其中。
4.建立数据库表
在工程jbpm的src/resources目录下建立mysql目录,并将jbpm/src/resources/hsqldb目录下的所有文件(create.db.hibernate.properties和identity.db.xml)拷贝入mysql中.
5修改create.db.hibernate.properties
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://192.200.1.104:3306/jbpm
hibernate.connection.username=zhoucw
hibernate.connection.password=0632
hibernate.show_sql=true
6 修改build.deploy.xml
在<target name="create.db" depends="declare.jbpm.tasks, db.clean, db.start"
description="creates a hypersonic database with the jbpm tables and loads the processes in there">前面添加
<target
name="create.db.mysql"
depends="declare.jbpm.tasks"
description="creates a mysql database with the jbpm tables and loads the processes in there.
Run this target after starting mysql">
<jbpmschema
actions="create"
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/mysql/create.db.hibernate.properties" />
<loadidentities
file="${basedir}/src/resources/mysql/identity.db.xml"
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/mysql/create.db.hibernate.properties" />
<ant antfile="build.xml"
target="build.processes"
inheritall="false" />
<deployprocess
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/mysql/create.db.hibernate.properties">
<fileset dir="build" includes="*.process" />
</deployprocess>
</target>
<property
file="${basedir}/src/resources/mysql/create.db.hibernate.properties" />
<target
name="execute.mysql.sql"
description="execute a mysql sql script with -Dmysql.script=path-to-script.">
<sql
driver="${hibernate.connection.driver_class}"
url="${hibernate.connection.url}" userid="${hibernate.connection.username}"
password="${hibernate.connection.password}"
delimiter=";"
autocommit="true"
onerror="continue">
<classpath
refid="classpath.ant" />
<transaction
src="${mysql.script}" />
</sql>
</target>
在myeEclipse中,右键点击工程jbpm下的build.deploy.xml文件,在菜单中选择“Run As\Ant Build…”,在出现的窗口中选择“target”为“create db mysql”,然后点击“Run”按钮,开始运行Ant。
7 修改hibernate.cfg.xml
在myeclipse中打开工程jbpm下的src/config.files目录下的hibernate.cfg.xml文件,修改其中的内容为:
<!-- jdbc connection properties -->
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://192.200.1.104:3306/jbpm
</property>
<property name="hibernate.connection.username">zhoucw</property>
<property name="hibernate.connection.password">0632</property>
<!-- other hibernate properties -->
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">false</property>
<property name="hibernate.use_sql_comments">false</property>
8 修改build.deploy.xml
在eclipse中打开工程jbpm下的build.deploy.xml文件,找到如下“target”,<target name="build.webapp" description="builds jbpm.war">
并将此“target”内容更改为如下内容:
<target name="build.webapp" description="builds jbpm.war">
<ant antfile="build.xml" target="build.webapp" />
<mkdir dir="build/jbpm.war.dir" />
<copy todir="build/jbpm.war.dir">
<fileset dir="src/resources/jbpm.war" />
</copy>
<copy todir="build/jbpm.war.dir/WEB-INF/classes">
<fileset dir="src/config.files" />
</copy>
<copy todir="build/jbpm.war.dir/WEB-INF/lib">
<fileset dir="build"
includes="jbpm*.jar,converter.jar"
excludes="*src*.jar" />
<fileset dir="lib/jsf" includes="*.jar" />
<fileset dir="lib/dom4j" includes="*.jar" />
<fileset dir="lib/hibernate" includes="*.jar" />
<fileset dir="lib/mysql" includes="*.jar" />
<fileset dir="lib/commons"
includes="commons-digester-*.jar,
commons-beanutils-*.jar,
commons-fileupload-*.jar" />
<fileset dir="lib/jboss"
includes="*.jar"
excludes="jboss*.jar,
*servlet*.jar,
*hsql*.jar" />
</copy>
<jar destfile="build/jbpm.war">
<fileset dir="build/jbpm.war.dir" />
</jar>
</target>
打包成war文件
在eclipse中,右键点击工程jbpm.3下的build.deploy.xml文件,在菜单中选择“Run As\Ant Build…”,在出现的窗口中选择“target”为“build webapp”,然后点击“Run”按钮,开始运行Ant。
搭建一个例子
建立流程图如下:
processdefinition.xml 内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<process-definition
xmlns="urn:jbpm.org:jpdl-3.1" name="testNo2">
<start-state name="start">
<task name="apply account">
<controller>
<variable name="baoxiaoId" access="read,write,required" mapped-name="baoxiao_ID"></variable>
<variable name="baoxiaoNum" access="read,write,required" mapped-name="baoxiao_num"></variable>
</controller>
<assignment class="com.test.action.UserAssignment"></assignment>
</task>
<transition name="" to="to direct"></transition>
</start-state>
<decision name="to direct">
<handler class="com.test.action.DecisionProcess"/>
<transition name="to caiwu" to="caiwu check apply"></transition>
<transition name="to boss" to="boss signature apply"></transition>
</decision>
<task-node name="boss signature apply">
<task name="boss signature">
<controller>
<variable name="baoxiaoId" access="read" mapped-name="baoxiao_ID"></variable>
<variable name="baoxiaoNum" access="read" mapped-name="baoxiao_num">
</variable>
</controller>
<assignment class="com.test.action.BossAssignment">
</assignment>
</task>
<transition name="to confirm" to="confirm apply1"></transition>
</task-node>
<task-node name="caiwu check apply">
<task name="caiwu check">
<controller>
<variable name="baoxiaoId" access="read" mapped-name="baoxiao_ID"></variable>
<variable name="baoxiaoNum" access="read" mapped-name="baoxiao_num">
</variable>
</controller>
<assignment class="com.test.action.CaiWuAssignment">
</assignment>
</task>
<transition name="to confirm" to="confirm apply2"></transition>
</task-node>
<task-node name="confirm apply1">
<task name="confirm1">
<assignment class="com.test.action.UserAssignment"></assignment>
</task>
<transition name="" to="end1"></transition>
</task-node>
<task-node name="confirm apply2">
<task name="confirm2">
<assignment class="com.test.action.UserAssignment"></assignment>
</task>
<transition name="" to="end1"></transition>
</task-node>
<end-state name="end1"></end-state>
</process-definition>
其中涉及到的类如下:
BossAssignment
package com.test.action;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.def.AssignmentHandler;
import org.jbpm.taskmgmt.exe.Assignable;
public class BossAssignment implements AssignmentHandler {
public void assign(Assignable assignable, ExecutionContext executionContext)
throws Exception {
assignable.setActorId("boss1");
// TODO Auto-generated method stub
}
}
package com.test.action;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.def.AssignmentHandler;
import org.jbpm.taskmgmt.exe.Assignable;
public class CaiWuAssignment implements AssignmentHandler {
public void assign(Assignable assignable, ExecutionContext executionContext)
throws Exception {
assignable.setActorId("Caiwu1");
// TODO Auto-generated method stub
}
}
CaiWuAssignment
package com.test.action;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.def.AssignmentHandler;
import org.jbpm.taskmgmt.exe.Assignable;
public class CaiWuAssignment implements AssignmentHandler {
public void assign(Assignable assignable, ExecutionContext executionContext)
throws Exception {
assignable.setActorId("Caiwu1");
// TODO Auto-generated method stub
}
}
DecisionProcess
package com.test.action;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.node.DecisionHandler;
public class DecisionProcess implements DecisionHandler {
public String decide(ExecutionContext executionContext) throws Exception {
// TODO Auto-generated method stub
String go="";
Object baoxiaoId=executionContext.getContextInstance().getVariable("baoxiaoId");
Object baoxiaoNum=executionContext.getContextInstance().getVariable("baoxiaoNum");
if(Integer.parseInt((String)baoxiaoNum) >1000){
go="to boss";
}
else{
go="to caiwu";
}
return go;
}
}
UserAssignment
package com.test.action;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.def.AssignmentHandler;
import org.jbpm.taskmgmt.exe.Assignable;
public class UserAssignment implements AssignmentHandler {
public void assign(Assignable assignable, ExecutionContext executionContext)
throws Exception {
assignable.setActorId("actor1");
// TODO Auto-generated method stub
}
}
发布到数据库以后,作为客户端业务层的java类如下:
No1Actor1ConfirmTest
package com.test;
import java.util.List;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.taskmgmt.exe.TaskInstance;
public class No1Actor1ConfirmTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String user_name = "actor1";
JbpmConfiguration config=JbpmConfiguration.getInstance();
JbpmContext jbpmContext=config.createJbpmContext();
List ls=jbpmContext.getTaskList(user_name);
int num = ls.size();
System.out.println(String.valueOf(num));
for(int i= 0;i<num;i++){
TaskInstance ti = (TaskInstance)ls.get(i);
System.out.println(ti.getActorId()+"完成"+ti.getName());
ti.end();
}
jbpmContext.close();
}
}
No1Actor1Test
package com.test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.taskmgmt.exe.TaskInstance;
public class No1Actor1Test {
/**
* @param args
*/
public static void main(String[] args) {
String user_name = "actor1";
String baoxiaoNum = "1300";
JbpmConfiguration config=JbpmConfiguration.getInstance();
JbpmContext jbpmContext=config.createJbpmContext();
Session session=jbpmContext.getSessionFactory().openSession();
Transaction trans=session.beginTransaction();
ProcessDefinition pd=jbpmContext.getGraphSession().findLatestProcessDefinition("testNo2");
ProcessInstance pi=pd.createProcessInstance();
TaskInstance ti=pi.getTaskMgmtInstance().createStartTaskInstance();
long pi_id= pi.getId();
No1Constant.baoxiaoId =pi_id;
ti.setVariable("baoxiaoId",pi_id);
ti.setVariable("baoxiaoNum",baoxiaoNum);
ti.end();
trans.commit();
session.close();
jbpmContext.close();
}
}
No1Boss1Test
package com.test;
import java.util.List;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.taskmgmt.exe.TaskInstance;
public class No1Boss1Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String user_name = "boss1";
JbpmConfiguration config=JbpmConfiguration.getInstance();
JbpmContext jbpmContext=config.createJbpmContext();
List ls=jbpmContext.getTaskList(user_name);
int num = ls.size();
System.out.println(String.valueOf(num));
for(int i= 0;i<num;i++){
TaskInstance ti = (TaskInstance)ls.get(i);
System.out.println(ti.getActorId()+"完成"+ti.getName());
ti.end();
}
jbpmContext.close();
}
}
No1CaiwuTest
package com.test;
import java.util.List;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.taskmgmt.exe.TaskInstance;
public class No1CaiwuTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String user_name = "Caiwu1";
JbpmConfiguration config=JbpmConfiguration.getInstance();
JbpmContext jbpmContext=config.createJbpmContext();
//TaskInstance ti = jbpmContext.getTaskInstance(19);
ProcessInstance pi=jbpmContext.getProcessInstance(12);
Token token = pi.getRootToken();
System.out.println(token.getNode().getName());
//System.out.println(ti.getActorId());
List ls=jbpmContext.getTaskList(user_name);
int num = ls.size();
System.out.println(String.valueOf(num));
for(int i= 0;i<num;i++){
TaskInstance ti = (TaskInstance)ls.get(i);
System.out.println(ti.getActorId()+"完成"+ti.getName());
ti.end();
}
jbpmContext.close();
}
}
No1Constant
package com.test;
public class No1Constant {
public static long baoxiaoId=0;
}
环境
安装Eclipse3.3
安装MyEclipse6.0
安装Tomcat5.5
安装MySQL5.0
下载JBoss jBPM Starters Kit 3.1.2
下载后解压到 D:\jbpm-starters-kit-3.1.2。目录下含有五个子目录:
jbpm jBPM的软件包,包含源码,例子等文件内容。
jbpm-bpel只含有一个网页
jbpm-db各种数据库hibernate配置文件示例,有些还包含了相应的jdbc驱动程序。
jbpm-designer辅助开发jBPM的Eclipse插件,具体在jbpm-gpd-feature子目录中
jbpm-server一个已经配置好了的基于JBoss的jBPM示例。
安装jBPM的Eclipse开发插件(略)
配置
1.导入工程
启动myEclipse,通过“Import”将jBPM工程导入eclipse中.
2.建库
在MySQL中建立数据库jbpm。字符集采用GBK。建表SQL如下:
CREATE DATABASE `jbpm`
CHARACTER SET 'gbk'
COLLATE 'gbk_chinese_ci';
3.添加MySQL驱动
在工程jbpm的lib目录下建立mysql文件夹,将MySQL需要的JDBC驱动程序拷贝其中。
4.建立数据库表
在工程jbpm的src/resources目录下建立mysql目录,并将jbpm/src/resources/hsqldb目录下的所有文件(create.db.hibernate.properties和identity.db.xml)拷贝入mysql中.
5修改create.db.hibernate.properties
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://192.200.1.104:3306/jbpm
hibernate.connection.username=zhoucw
hibernate.connection.password=0632
hibernate.show_sql=true
6 修改build.deploy.xml
在<target name="create.db" depends="declare.jbpm.tasks, db.clean, db.start"
description="creates a hypersonic database with the jbpm tables and loads the processes in there">前面添加
<target
name="create.db.mysql"
depends="declare.jbpm.tasks"
description="creates a mysql database with the jbpm tables and loads the processes in there.
Run this target after starting mysql">
<jbpmschema
actions="create"
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/mysql/create.db.hibernate.properties" />
<loadidentities
file="${basedir}/src/resources/mysql/identity.db.xml"
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/mysql/create.db.hibernate.properties" />
<ant antfile="build.xml"
target="build.processes"
inheritall="false" />
<deployprocess
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/mysql/create.db.hibernate.properties">
<fileset dir="build" includes="*.process" />
</deployprocess>
</target>
<property
file="${basedir}/src/resources/mysql/create.db.hibernate.properties" />
<target
name="execute.mysql.sql"
description="execute a mysql sql script with -Dmysql.script=path-to-script.">
<sql
driver="${hibernate.connection.driver_class}"
url="${hibernate.connection.url}" userid="${hibernate.connection.username}"
password="${hibernate.connection.password}"
delimiter=";"
autocommit="true"
onerror="continue">
<classpath
refid="classpath.ant" />
<transaction
src="${mysql.script}" />
</sql>
</target>
在myeEclipse中,右键点击工程jbpm下的build.deploy.xml文件,在菜单中选择“Run As\Ant Build…”,在出现的窗口中选择“target”为“create db mysql”,然后点击“Run”按钮,开始运行Ant。
7 修改hibernate.cfg.xml
在myeclipse中打开工程jbpm下的src/config.files目录下的hibernate.cfg.xml文件,修改其中的内容为:
<!-- jdbc connection properties -->
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://192.200.1.104:3306/jbpm
</property>
<property name="hibernate.connection.username">zhoucw</property>
<property name="hibernate.connection.password">0632</property>
<!-- other hibernate properties -->
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">false</property>
<property name="hibernate.use_sql_comments">false</property>
8 修改build.deploy.xml
在eclipse中打开工程jbpm下的build.deploy.xml文件,找到如下“target”,<target name="build.webapp" description="builds jbpm.war">
并将此“target”内容更改为如下内容:
<target name="build.webapp" description="builds jbpm.war">
<ant antfile="build.xml" target="build.webapp" />
<mkdir dir="build/jbpm.war.dir" />
<copy todir="build/jbpm.war.dir">
<fileset dir="src/resources/jbpm.war" />
</copy>
<copy todir="build/jbpm.war.dir/WEB-INF/classes">
<fileset dir="src/config.files" />
</copy>
<copy todir="build/jbpm.war.dir/WEB-INF/lib">
<fileset dir="build"
includes="jbpm*.jar,converter.jar"
excludes="*src*.jar" />
<fileset dir="lib/jsf" includes="*.jar" />
<fileset dir="lib/dom4j" includes="*.jar" />
<fileset dir="lib/hibernate" includes="*.jar" />
<fileset dir="lib/mysql" includes="*.jar" />
<fileset dir="lib/commons"
includes="commons-digester-*.jar,
commons-beanutils-*.jar,
commons-fileupload-*.jar" />
<fileset dir="lib/jboss"
includes="*.jar"
excludes="jboss*.jar,
*servlet*.jar,
*hsql*.jar" />
</copy>
<jar destfile="build/jbpm.war">
<fileset dir="build/jbpm.war.dir" />
</jar>
</target>
打包成war文件
在eclipse中,右键点击工程jbpm.3下的build.deploy.xml文件,在菜单中选择“Run As\Ant Build…”,在出现的窗口中选择“target”为“build webapp”,然后点击“Run”按钮,开始运行Ant。
搭建一个例子
建立流程图如下:
processdefinition.xml 内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<process-definition
xmlns="urn:jbpm.org:jpdl-3.1" name="testNo2">
<start-state name="start">
<task name="apply account">
<controller>
<variable name="baoxiaoId" access="read,write,required" mapped-name="baoxiao_ID"></variable>
<variable name="baoxiaoNum" access="read,write,required" mapped-name="baoxiao_num"></variable>
</controller>
<assignment class="com.test.action.UserAssignment"></assignment>
</task>
<transition name="" to="to direct"></transition>
</start-state>
<decision name="to direct">
<handler class="com.test.action.DecisionProcess"/>
<transition name="to caiwu" to="caiwu check apply"></transition>
<transition name="to boss" to="boss signature apply"></transition>
</decision>
<task-node name="boss signature apply">
<task name="boss signature">
<controller>
<variable name="baoxiaoId" access="read" mapped-name="baoxiao_ID"></variable>
<variable name="baoxiaoNum" access="read" mapped-name="baoxiao_num">
</variable>
</controller>
<assignment class="com.test.action.BossAssignment">
</assignment>
</task>
<transition name="to confirm" to="confirm apply1"></transition>
</task-node>
<task-node name="caiwu check apply">
<task name="caiwu check">
<controller>
<variable name="baoxiaoId" access="read" mapped-name="baoxiao_ID"></variable>
<variable name="baoxiaoNum" access="read" mapped-name="baoxiao_num">
</variable>
</controller>
<assignment class="com.test.action.CaiWuAssignment">
</assignment>
</task>
<transition name="to confirm" to="confirm apply2"></transition>
</task-node>
<task-node name="confirm apply1">
<task name="confirm1">
<assignment class="com.test.action.UserAssignment"></assignment>
</task>
<transition name="" to="end1"></transition>
</task-node>
<task-node name="confirm apply2">
<task name="confirm2">
<assignment class="com.test.action.UserAssignment"></assignment>
</task>
<transition name="" to="end1"></transition>
</task-node>
<end-state name="end1"></end-state>
</process-definition>
其中涉及到的类如下:
BossAssignment
package com.test.action;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.def.AssignmentHandler;
import org.jbpm.taskmgmt.exe.Assignable;
public class BossAssignment implements AssignmentHandler {
public void assign(Assignable assignable, ExecutionContext executionContext)
throws Exception {
assignable.setActorId("boss1");
// TODO Auto-generated method stub
}
}
package com.test.action;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.def.AssignmentHandler;
import org.jbpm.taskmgmt.exe.Assignable;
public class CaiWuAssignment implements AssignmentHandler {
public void assign(Assignable assignable, ExecutionContext executionContext)
throws Exception {
assignable.setActorId("Caiwu1");
// TODO Auto-generated method stub
}
}
CaiWuAssignment
package com.test.action;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.def.AssignmentHandler;
import org.jbpm.taskmgmt.exe.Assignable;
public class CaiWuAssignment implements AssignmentHandler {
public void assign(Assignable assignable, ExecutionContext executionContext)
throws Exception {
assignable.setActorId("Caiwu1");
// TODO Auto-generated method stub
}
}
DecisionProcess
package com.test.action;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.node.DecisionHandler;
public class DecisionProcess implements DecisionHandler {
public String decide(ExecutionContext executionContext) throws Exception {
// TODO Auto-generated method stub
String go="";
Object baoxiaoId=executionContext.getContextInstance().getVariable("baoxiaoId");
Object baoxiaoNum=executionContext.getContextInstance().getVariable("baoxiaoNum");
if(Integer.parseInt((String)baoxiaoNum) >1000){
go="to boss";
}
else{
go="to caiwu";
}
return go;
}
}
UserAssignment
package com.test.action;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.def.AssignmentHandler;
import org.jbpm.taskmgmt.exe.Assignable;
public class UserAssignment implements AssignmentHandler {
public void assign(Assignable assignable, ExecutionContext executionContext)
throws Exception {
assignable.setActorId("actor1");
// TODO Auto-generated method stub
}
}
发布到数据库以后,作为客户端业务层的java类如下:
No1Actor1ConfirmTest
package com.test;
import java.util.List;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.taskmgmt.exe.TaskInstance;
public class No1Actor1ConfirmTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String user_name = "actor1";
JbpmConfiguration config=JbpmConfiguration.getInstance();
JbpmContext jbpmContext=config.createJbpmContext();
List ls=jbpmContext.getTaskList(user_name);
int num = ls.size();
System.out.println(String.valueOf(num));
for(int i= 0;i<num;i++){
TaskInstance ti = (TaskInstance)ls.get(i);
System.out.println(ti.getActorId()+"完成"+ti.getName());
ti.end();
}
jbpmContext.close();
}
}
No1Actor1Test
package com.test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.taskmgmt.exe.TaskInstance;
public class No1Actor1Test {
/**
* @param args
*/
public static void main(String[] args) {
String user_name = "actor1";
String baoxiaoNum = "1300";
JbpmConfiguration config=JbpmConfiguration.getInstance();
JbpmContext jbpmContext=config.createJbpmContext();
Session session=jbpmContext.getSessionFactory().openSession();
Transaction trans=session.beginTransaction();
ProcessDefinition pd=jbpmContext.getGraphSession().findLatestProcessDefinition("testNo2");
ProcessInstance pi=pd.createProcessInstance();
TaskInstance ti=pi.getTaskMgmtInstance().createStartTaskInstance();
long pi_id= pi.getId();
No1Constant.baoxiaoId =pi_id;
ti.setVariable("baoxiaoId",pi_id);
ti.setVariable("baoxiaoNum",baoxiaoNum);
ti.end();
trans.commit();
session.close();
jbpmContext.close();
}
}
No1Boss1Test
package com.test;
import java.util.List;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.taskmgmt.exe.TaskInstance;
public class No1Boss1Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String user_name = "boss1";
JbpmConfiguration config=JbpmConfiguration.getInstance();
JbpmContext jbpmContext=config.createJbpmContext();
List ls=jbpmContext.getTaskList(user_name);
int num = ls.size();
System.out.println(String.valueOf(num));
for(int i= 0;i<num;i++){
TaskInstance ti = (TaskInstance)ls.get(i);
System.out.println(ti.getActorId()+"完成"+ti.getName());
ti.end();
}
jbpmContext.close();
}
}
No1CaiwuTest
package com.test;
import java.util.List;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.taskmgmt.exe.TaskInstance;
public class No1CaiwuTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String user_name = "Caiwu1";
JbpmConfiguration config=JbpmConfiguration.getInstance();
JbpmContext jbpmContext=config.createJbpmContext();
//TaskInstance ti = jbpmContext.getTaskInstance(19);
ProcessInstance pi=jbpmContext.getProcessInstance(12);
Token token = pi.getRootToken();
System.out.println(token.getNode().getName());
//System.out.println(ti.getActorId());
List ls=jbpmContext.getTaskList(user_name);
int num = ls.size();
System.out.println(String.valueOf(num));
for(int i= 0;i<num;i++){
TaskInstance ti = (TaskInstance)ls.get(i);
System.out.println(ti.getActorId()+"完成"+ti.getName());
ti.end();
}
jbpmContext.close();
}
}
No1Constant
package com.test;
public class No1Constant {
public static long baoxiaoId=0;
}
相关推荐
**jbpm入门实践** jbpm 是一款开源的工作流管理系统,主要用于设计、执行和管理业务流程。本文主要针对jbpm 5.2版本进行入门实践,适合初级用户学习。首先,我们要进行必要的安装与配置。 **一、jbpm的准备工作** ...
JBPM(Java Business Process Management)是一个开源的工作流和业务流程管理系统,它允许开发者设计、执行、管理和监控业务流程。在JBPM中,处理并发子流程是实现复杂业务逻辑的重要一环。本文将深入探讨如何使用...
自己的apache maven 仓库放了3个jar 文件. 博文链接:https://chenjin.iteye.com/blog/153407
【描述】虽然描述部分是空的,但根据标题和标签,我们可以推测博主可能分享了一篇关于jbpm实践的文章,可能是通过个人博客平台iteye。通常,这样的文章会涵盖jbpm的基础概念、环境搭建、实例演示,以及如何利用源码...
"JBPM最佳实践.txt"则可能包含了一系列在实际项目中运用jbpm时的最佳实践建议,如性能优化、流程设计原则、错误处理策略等,旨在帮助开发者避免常见问题,提升项目的质量和效率。 通过这些文档,学习者可以全面了解...
**四、JBPM实践中的注意事项** 1. **性能优化**:对于大型企业级应用,可能需要考虑缓存策略、数据库优化和分布式部署等性能问题。 2. **错误处理**:合理设计异常处理机制,确保流程在出现问题时能够优雅地恢复或...
jbpm应用开发指面(胡奇).pdf可能是胡奇专家对jbpm应用开发的实践经验分享,可能包含了最佳实践、常见问题解决方案和案例研究。开发者可以从中学到如何在实际项目中有效地运用jbpm,以及如何解决开发过程中遇到的...
总的来说,jbPM 3.2是一个强大的工作流管理系统,通过深入理解和实践,开发者可以构建出高效、灵活的业务流程,提高企业的业务自动化水平。希望这份知识总结能对你在jbPM的学习和使用上提供帮助。
jbpm-3.1.2.zip 文件包含了 jBpm 的一个重要版本——jBpm 3.1.2,这是一个开源的工作流管理系统,专为构建灵活且可扩展的业务...通过深入学习和实践,开发者可以充分利用其特性,构建出符合业务需求的复杂工作流系统。
在描述中提到的博客链接指向了iteye上的一篇关于jbpm的博文,虽然具体内容无法直接展示,但可以推测博主可能分享了如何将jbpm与Struts2框架整合的实践经验和技巧。Struts2是一个流行的Java Web应用程序框架,它提供...
- **社区支持**:活跃的开发者社区提供了丰富的资源和支持,有助于快速解决问题和获取最佳实践。 - **易于集成**:与其他 Java EE 应用和服务的无缝集成能力,使得 jBPM 能够轻松融入现有的企业环境中。 - **扩展性*...
本教程将指导您如何将JBPM的默认数据库从H2切换到MySQL或PostgreSQL,并提供实践案例。 首先,我们需要了解为什么要更换数据库。H2虽然轻量级且易于开发,但在高并发、大数据量和多用户环境下,其性能可能无法满足...
【标题】"JBPM4 web设计器实践--命令模式的使用"揭示了在JBPM4中如何运用命令模式来提升流程设计的效率与可维护性。命令模式是一种设计模式,它将请求封装为一个对象,使得我们可以用不同的请求对客户进行参数化,对...
jbpm-demo是jbpm附带的演示项目,它包含了多个示例流程,如请假审批流程、采购流程等,这些实例为初学者提供了实践和学习的机会。通过jbpm-demo,用户可以直观地了解如何部署和运行工作流,以及如何与工作流系统进行...
本文将详细介绍jBPM5的一个实例实践,旨在提供清晰的操作指南和运行结果解析。jBPM5是一个开源的工作流管理系统,用于设计、执行和管理业务流程。在这个实践中,我们将关注一个具体的报销流程,展示如何启动流程、...
SSH整合JBPM是一个在Java开发领域中的重要主题,它涉及到Spring、Struts和Hibernate这三大框架与业务流程管理(Business Process Management, BPM)系统JBPM的集成。SSH是Java Web应用开发的主流技术栈,而JBPM则是...
SSH+JBPM4.3的整合是企业级应用开发中的一种常见组合,SSH指的是Spring、Struts和Hibernate这三个开源框架的集成,而JBPM4.3则是一个强大的工作流...通过学习和实践,你可以创建出高效、灵活且易于维护的企业级应用。
总的来说,这个"JBPM web(SSH+JBPM)例子"为学习者提供了一个全面了解如何在Java Web环境中集成工作流管理的实践案例。通过深入研究这个项目,开发者不仅可以掌握SSH框架的使用,还能熟悉JBPM的工作流管理机制,为...