pom.xml
-----------------------------------
<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.jbpm</groupId> <artifactId>jbpm-maven-example</artifactId> <name>jBPM Maven Project</name> <version>1.0-SNAPSHOT</version> <properties> <spring.version>3.1.4.RELEASE</spring.version> <aspectj.version>1.6.2</aspectj.version> <jboss.netty.version>3.2.0.Final</jboss.netty.version> <mysql.version>5.1.10</mysql.version> <hibernate.version>4.2.1.Final</hibernate.version> <hibernateCommAnn.version>3.2.0.Final</hibernateCommAnn.version> <hibernateAnn.version>3.5.6-Final</hibernateAnn.version> <cglib.version>2.2.2</cglib.version> <slf4j.version>1.6.1</slf4j.version> <log4j.version>1.2.16</log4j.version> <jbpm.version>5.4.0.Final</jbpm.version> <drools.version>5.5.0.Final</drools.version> </properties> <repositories> <!-- use this repository for stable releases --> <repository> <id>jboss-public-repository-group</id> <name>JBoss Public Maven Repository Group</name> <url>https://repository.jboss.org/nexus/content/groups/public/</url> <layout>default</layout> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <!-- use this repository for snapshot releases --> <repository> <id>jboss-snapshot-repository-group</id> <name>JBoss SNAPSHOT Maven Repository Group</name> <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url> <layout>default</layout> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </snapshots> </repository> </repositories> <dependencies> <!-- Spring 3 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-asm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> <optional>true</optional> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> <dependency> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa-persistence</artifactId> <version>2.2.2</version> </dependency> <!-- Hibernate --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-commons-annotations</artifactId> <version>${hibernateCommAnn.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>${hibernateAnn.version}</version> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>${cglib.version}</version> </dependency> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1.0.1.Final</version> </dependency> <!-- JBOSS Cache & Hibernate --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-ehcache</artifactId> <version>4.2.1.Final</version> </dependency> <dependency> <groupId>hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>1.8.0.4</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-testing</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache-core</artifactId> <version>2.4.3</version> </dependency> <!-- JBPM5.4 --> <dependency> <groupId>org.drools</groupId> <artifactId>drools-spring</artifactId> <version>${drools.version}</version> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-bpmn2</artifactId> <version>${jbpm.version}</version> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-human-task-core</artifactId> <version>${jbpm.version}</version> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-persistence-jpa</artifactId> <version>${jbpm.version}</version> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-bam</artifactId> <version>${jbpm.version}</version> </dependency> <!-- Log4j --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.lazyluke</groupId> <artifactId>log4jdbc-remix</artifactId> <version>0.2.7</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> </dependencies> <build> <finalName>JBPM54sh</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.5</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <archive> <manifest> <!--<addClasspath>true</addClasspath> --> </manifest> <manifestEntries> <Built-By>org-builder</Built-By> <Build-Jdk>${java.version}</Build-Jdk> </manifestEntries> </archive> </configuration> </plugin> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.20</version> <configuration> <contextPath>/JBPM54sh</contextPath> <!--<webDefaultXml>webdefault.xml</webDefaultXml> --> <scanIntervalSeconds>0</scanIntervalSeconds> <scanTargetPatterns> <scanTargetPattern> <directory>src/main/webapp/WEB-INF</directory> <excludes> <exclude>**/*.jsp</exclude> </excludes> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> </scanTargetPattern> </scanTargetPatterns> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.0.2</version> <configuration> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> <manifestEntries> <Implementation-Build>${buildNumber}</Implementation-Build> </manifestEntries> </archive> <dependentWarExcludes> **/jdbc.properties,**/web.xml,WEB-INF/classes/META-INF/** </dependentWarExcludes> </configuration> </plugin> </plugins> </build> </project>
src/main/resources/ehcache.xml
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?> <ehcache> <!--如果缓存中的对象存储超过指定的缓存数量的对象存储的磁盘地址 --> <diskStore path="D:/ehcache" /> <!-- 默认cache:如果没有对应的特定区域的缓存,就使用默认缓存 --> <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="false" /> <!-- 指定区域cache:通过name指定,name对应到Hibernate中的区域名即可 --> <cache name="cn.javass.h3test.model.UserModel" eternal="false" maxElementsInMemory="100" timeToIdleSeconds="1200" timeToLiveSeconds="1200" overflowToDisk="false"> </cache> </ehcache>
src/main/resources/jdbc.properties
-----------------------------------
jdbc.driver=net.sf.log4jdbc.DriverSpy
jdbc.url=jdbc:log4jdbc:mysql://localhost:3306/jbpmtest?createDatabaseIfNotExist=true
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://localhost:3306/jbpmtest?createDatabaseIfNotExist=true
jdbc.username=root
jdbc.password=root
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
src/main/resources/log4j.properties
-----------------------------------
#log4j.rootLogger=info, stdout, logfile
log4j.rootLogger=info, stdout, HUB
# log4jdbc
log4j.logger.jdbc.sqlonly=INFO
log4j.logger.jdbc.sqltiming=INFO
log4j.logger.jdbc.audit=OFF
log4j.logger.jdbc.resultset=OFF
log4j.logger.jdbc.connection=OFF
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yy-MM-dd HH:mm} %5p %c{1}:%L - %m%n
#log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.logfile.File=c:/deimos.log
#log4j.appender.logfile.DatePattern='.'yyyy-MM-dd
#log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
#log4j.appender.logfile.layout.ConversionPattern=%d{yy-MM-dd HH:mm} %5p %c{1}:%L - %m%n
log4j.logger.com.mosso=debug
log4j.logger.org.springframework.batch=DEBUG
log4j.logger.org.springframework.transaction=INFO
log4j.logger.org.springframework=error
log4j.category.org.springframework.beans.factory=DEBUG
log4j.appender.HUB=org.apache.log4j.net.SocketHubAppender
log4j.appender.HUB.layout=org.apache.log4j.PatternLayout
log4j.appender.HUB.layout.ConversionPattern=[cc]%d{MMM-dd HH:mm:ss} %-14.14c{1}- %m%n
log4j.appender.HUB.port=4445
src/main/resources/META-INF/JBPMorm.xml(没使用到)
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd" version="1.0"> <named-query name="ProcessInstancesWaitingForEvent"> <query> select processInstanceInfo.processInstanceId from ProcessInstanceInfo processInstanceInfo join processInstanceInfo.eventTypes eventTypes where eventTypes = :type </query> </named-query> </entity-mappings>
src/main/resources/META-INF/Taskorm.xml
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd" version="1.0"> <named-query name="TasksAssignedAsBusinessAdministrator"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity businessAdministrator where t.archived = 0 and businessAdministrator.id = :userId and businessAdministrator in elements ( t.peopleAssignments.businessAdministrators ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsExcludedOwner"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity excludedOwners where t.archived = 0 and excludedOwners.id = :userId and excludedOwners in elements ( t.peopleAssignments.excludedOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsPotentialOwner"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and potentialOwners.id = :userId and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsPotentialOwnerByStatus"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and potentialOwners.id = :userId and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in (:status) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsPotentialOwnerWithGroups"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and ( potentialOwners.id = :userId or potentialOwners.id in (:groupIds) ) and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsPotentialOwnerByStatusWithGroups"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and ( potentialOwners.id = :userId or potentialOwners.id in (:groupIds) ) and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in (:status) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsPotentialOwnerByGroup"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and potentialOwners.id = :groupId and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="SubTasksAssignedAsPotentialOwner"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.archived = 0 and t.taskData.parentId = :parentId and (potentialOwners.id = :userId or potentialOwners.id in (:groupIds)) and potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="GetSubTasksByParentTaskId"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.parentId = :parentId and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsRecipient"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity recipients where t.archived = 0 and recipients.id = :userId and recipients in elements ( t.peopleAssignments.recipients ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsTaskInitiator"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity taskInitiator where t.archived = 0 and taskInitiator.id = :userId and taskInitiator = t.peopleAssignments.taskInitiator and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksAssignedAsTaskStakeholder"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity taskStakeholder where t.archived = 0 and taskStakeholder.id = :userId and taskStakeholder in elements ( t.peopleAssignments.taskStakeholders ) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksOwned"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.actualOwner.id = :userId and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksByStatus"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.status = :status and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksByStatusByProcessId"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.actualOwner as actualOwner left join t.taskData.createdBy as createdBy left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.processInstanceId = :processInstanceId and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in (:status) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksByStatusByProcessIdByTaskName"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.actualOwner as actualOwner left join t.taskData.createdBy as createdBy left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.processInstanceId = :processInstanceId and name.shortText = :taskName and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.status in (:status) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksByStatusSince"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 0 and t.taskData.status = :status and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null and t.taskData.activationTime < :since </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="ArchivedTasks"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.archived = 1 and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TasksOwnedWithParticularStatus"> <query> select new org.jbpm.task.query.TaskSummary( t.id, t.taskData.processInstanceId, name.text, subject.text, description.text, t.taskData.status, t.priority, t.taskData.skipable, actualOwner, createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy as createdBy left join t.taskData.actualOwner as actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name where t.taskData.actualOwner.id = :userId and t.taskData.status in (:status) and ( name.language = :language or t.names.size = 0 ) and ( subject.language = :language or t.subjects.size = 0 ) and ( description.language = :language or t.descriptions.size = 0 ) and t.taskData.expirationTime is null </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="UnescalatedDeadlines"> <query> select new org.jbpm.task.query.DeadlineSummary( t.id, d.id, d.date) from Task t, Deadline d where t.archived = 0 and (d in elements( t.deadlines.startDeadlines ) or d in elements( t.deadlines.endDeadlines ) ) and d.escalated = 0 order by d.date </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <named-query name="TaskByWorkItemId"> <query> select t from Task t where t.archived = 0 and t.taskData.workItemId = :workItemId </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> </entity-mappings>
src/main/resources/META-INF/persistence.xml
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="org.jbpm.persistence.local" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <!-- <non-jta-data-source>jdbc/jbpm-ds</non-jta-data-source> --> <!-- Use this if you are using JPA1 / Hibernate3 --> <!-- <mapping-file>META-INF/JBPMorm.xml</mapping-file> --> <!-- <mapping-file>META-INF/Taskorm.xml</mapping-file> --> <!-- Use this if you are using JPA2 / Hibernate4 --> <mapping-file>META-INF/JBPMorm-JPA2.xml</mapping-file> <mapping-file>META-INF/ProcessInstanceInfo.hbm.xml</mapping-file> <mapping-file>META-INF/Taskorm.xml</mapping-file> <class>org.jbpm.task.Attachment</class> <class>org.jbpm.task.Content</class> <class>org.jbpm.task.BooleanExpression</class> <class>org.jbpm.task.Comment</class> <class>org.jbpm.task.Deadline</class> <class>org.jbpm.task.Comment</class> <class>org.jbpm.task.Deadline</class> <class>org.jbpm.task.Delegation</class> <class>org.jbpm.task.Escalation</class> <class>org.jbpm.task.Group</class> <class>org.jbpm.task.I18NText</class> <class>org.jbpm.task.Notification</class> <class>org.jbpm.task.EmailNotification</class> <class>org.jbpm.task.EmailNotificationHeader</class> <class>org.jbpm.task.PeopleAssignments</class> <class>org.jbpm.task.Reassignment</class> <class>org.jbpm.task.Status</class> <class>org.jbpm.task.Task</class> <class>org.jbpm.task.TaskData</class> <class>org.jbpm.task.SubTasksStrategy</class> <class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class> <class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class> <class>org.jbpm.task.User</class> <class>org.drools.persistence.info.SessionInfo</class> <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class> <class>org.drools.persistence.info.WorkItemInfo</class> <class>org.jbpm.process.audit.ProcessInstanceLog</class> <class>org.jbpm.process.audit.NodeInstanceLog</class> <class>org.jbpm.process.audit.VariableInstanceLog</class> <properties> <property name="hibernate.max_fetch_depth" value="3" /> <property name="hibernate.hbm2ddl.auto" value="update" /> <property name="hibernate.show_sql" value="false" /> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory"/> <property name="hibernate.cache.use_query_cache" value="true"/> <property name="hibernate.cache.use_second_level_cache" value="true"/> <property name="hibernate.generate_statistics" value="true"/> <property name="hibernate.use_sql_comments" value="true"/> <property name="hibernate.generate_statistics" value="true"/> </properties> </persistence-unit> </persistence>
src/main/java/com/gds/jbpm/JBPMUserGroupCallback.java
-----------------------------------
package com.gds.jbpm; import java.util.ArrayList; import java.util.List; import org.jbpm.task.identity.UserGroupCallback; public class JBPMUserGroupCallback implements UserGroupCallback { @Override public boolean existsGroup(String groupId) { return true; } @Override public boolean existsUser(String userId) { return true; } @Override public List<String> getGroupsForUser(String userId, List<String> groupIds, List<String> allExistingGroupIds) { if (groupIds != null) { List<String> retList = new ArrayList<String>(groupIds); // merge all groups if (allExistingGroupIds != null) { for (String grp : allExistingGroupIds) { if (!retList.contains(grp)) { retList.add(grp); } } } return retList; } else { // // return empty list by default // please note: there are different return value for different // version of jPBM // List<String> retList = new ArrayList<String>(); // retList.add("user"); // return retList; // return new ArrayList<String>(); //for jBPM5.3.0.Final return null; // for jBPM5.4.0.CR1 } } }
src/main/java/com/gds/jbpm/MyLocalTaskService.java
-----------------------------------
package com.gds.jbpm; import javax.annotation.PostConstruct; import org.drools.runtime.StatefulKnowledgeSession; import org.jbpm.task.service.local.LocalTaskService; /** * 提供这个类,是为了设定jbpm.usergroup.callback, * 但是如何注解呢? * @author pandy * */ public class MyLocalTaskService { private StatefulKnowledgeSession ksession; private LocalTaskService localTaskService; @PostConstruct public void init() { // set user group callback System.setProperty("jbpm.usergroup.callback", "com.gds.jbpm.JBPMUserGroupCallback"); } public StatefulKnowledgeSession getKsession() { return ksession; } public void setKsession(StatefulKnowledgeSession ksession) { this.ksession = ksession; } public org.jbpm.task.service.local.LocalTaskService getLocalTaskService() { return localTaskService; } public void setLocalTaskService( org.jbpm.task.service.local.LocalTaskService localTaskService) { this.localTaskService = localTaskService; } }
src/main/java/com/gds/web/OrderController.java
-----------------------------------
package com.gds.web; import static org.springframework.web.bind.annotation.RequestMethod.GET; import static org.springframework.web.bind.annotation.RequestMethod.POST; import static org.springframework.web.bind.annotation.RequestMethod.PUT; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.annotation.Resource; import org.apache.log4j.Logger; import org.drools.command.Context; import org.drools.command.impl.GenericCommand; import org.drools.command.impl.KnowledgeCommandContext; import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.process.WorkflowProcessInstance; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.instance.context.variable.VariableScopeInstance; import org.jbpm.process.workitem.wsht.LocalHTWorkItemHandler; import org.jbpm.task.Task; import org.jbpm.task.TaskData; import org.jbpm.task.TaskService; import org.jbpm.task.query.TaskSummary; import org.jbpm.task.service.ContentData; import org.jbpm.task.utils.ContentMarshallerHelper; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import com.gds.jbpm.MyLocalTaskService; import com.gds.jbpm.Order; @Controller public class OrderController { private Logger log = Logger.getLogger(this.getClass()); @Resource @Qualifier("myLocalTaskService") private MyLocalTaskService myLocalTaskService; @Resource @Qualifier("ksession") private StatefulKnowledgeSession ksession; @RequestMapping("/") public String test() { log.info("this is the index"); return "index"; } @RequestMapping(value = "{user}/create", method = GET) public String create(@PathVariable("user") String user) { // log.info(user + " prepare to create"); System.out.println("用户[" + user + "]进入创建界面,准备创建流程。"); return "create"; } @RequestMapping(value = "{user}/create", method = { POST, PUT }) public String doCreate(@PathVariable("user") String user, Model model) { // log.info(user + " create an order"); System.out.println("用户[" + user + "]提交了流程单据"); ksession = myLocalTaskService.getKsession(); LocalHTWorkItemHandler humanTaskHandler = new LocalHTWorkItemHandler( myLocalTaskService.getLocalTaskService(), ksession); humanTaskHandler.setLocal(true); humanTaskHandler.connect(); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler); Map<String, Object> params = new HashMap<String, Object>(); params.put("priority", "High"); params.put("modelNumber", "179"); params.put("quantity", "100"); System.out.println("用户[" + user + "]赋初始值,并准备启动流程......."); ksession.startProcess("com.gds.jbpm.sample", params); ksession.fireAllRules(); System.out.println("用户[" + user + "]创建流程,等待处理......"); model.addAttribute("message", "process created!"); System.out .println("---------------------------------------------------单据提交完成:" + user); return "create"; } @RequestMapping("{user}/list") public String list(@PathVariable("user") String user, Model model) { // log.info(user + " list his tasks"); System.out.println("用户[" + user + "]读取任务列表."); TaskService taskService = myLocalTaskService.getLocalTaskService(); List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner( user, "en-UK"); log.info("\n***Task size::" + tasks.size() + "***\n"); for (TaskSummary taskSummary : tasks) { log.info(taskSummary.getId() + " :: " + taskSummary.getActualOwner()); } model.addAttribute("tasks", tasks); model.addAttribute("tasksCount", tasks.size()); model.addAttribute("user", user); System.out .println("---------------------------------------------------列表读取完成:" + user); return "list"; } @RequestMapping(value = "{user}/work/{task}", method = GET) public String work(@PathVariable("user") String user, @PathVariable("task") long taskId, Model model) { // log.info(user + " prepare to work on task " + taskId); System.out.println("用户[" + user + "]读取任务以便处理,任务ID=" + taskId); StatefulKnowledgeSession ksession = myLocalTaskService.getKsession(); TaskService taskService = myLocalTaskService.getLocalTaskService(); Task task = taskService.getTask(taskId); TaskData taskData = task.getTaskData(); WorkflowProcessInstance process = (WorkflowProcessInstance) ksession .getProcessInstance(taskData.getProcessInstanceId()); model.addAttribute("taskData", taskData); model.addAttribute("order", new Order(user, taskId, process)); System.out .println("---------------------------------------------------任务读取完成:" + user); return "work"; } @RequestMapping(value = "{user}/work/{task}", method = { POST, PUT }) public String doWork(@ModelAttribute Order order) { System.out.println("处理任务信息:" + order.toString()); String user = order.getUser(); long taskId = order.getTaskId(); log.info(user + " complete work on task " + taskId); TaskService taskService = myLocalTaskService.getLocalTaskService(); System.out.println("用户[" + user + "]启动人工任务, taskId=" + taskId); taskService.start(taskId, user); Map<String, Object> data = new HashMap<String, Object>(); data.put("priority", order.getPriority()); data.put("modelNumber", order.getModelNumber()); data.put("quantity", order.getQuantity()); // setProcessVariables(taskId, data); ContentData contentData = null; if (data != null) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream outs; try { outs = new ObjectOutputStream(bos); outs.writeObject(data); outs.close(); contentData = new ContentData(); //contentData.setContent(bos.toByteArray()); //contentData.setAccessType(AccessType.Inline); contentData = ContentMarshallerHelper.marshal(data, null); //contentData.setAccessType(AccessType.Inline); } catch (IOException e) { e.printStackTrace(); } } System.out.println("参数:"+data.toString()); //taskService.complete(taskId, user, contentData); taskService.completeWithResults(taskId, user, data); // ksession.fireAllRules(); // ksession.getWorkItemManager().completeWorkItem(taskService.getTask(taskId).getTaskData().getWorkItemId(), // data); System.out.println("用户[" + user + "]完成人工任务"); System.out .println("---------------------------------------------------处理任务完成:" + user); return "redirect:/" + user + "/list"; } public void setProcessVariables(final long intProcessInstId, final Map<String, Object> hshVariableMap) { try { ksession.execute(new GenericCommand<Map<String, Object>>() { public Map<String, Object> execute(Context objContext) { StatefulKnowledgeSession objKSession = ((KnowledgeCommandContext) objContext) .getStatefulKnowledgesession(); org.jbpm.process.instance.ProcessInstance objProcessInstance = (org.jbpm.process.instance.ProcessInstance) objKSession .getProcessInstance(intProcessInstId); VariableScopeInstance objVariableScope = (VariableScopeInstance) objProcessInstance .getContextInstance(VariableScope.VARIABLE_SCOPE); Iterator<Map.Entry<String, Object>> objIterator = hshVariableMap .entrySet().iterator(); while (objIterator.hasNext()) { Map.Entry<String, Object> objPairs = (Map.Entry<String, Object>) objIterator .next(); objVariableScope.setVariable(objPairs.getKey(), objPairs.getValue()); } return null; } }); } catch (Exception e) { e.printStackTrace(); } } }
src/main/resources/applicationContext.xml
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:drools="http://drools.org/schema/drools-spring" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring-1.3.0.xsd"> <context:component-scan base-package="com"> <context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation" /> </context:component-scan> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <value>classpath:jdbc.properties</value> </property> </bean> <!-- Spring + Hibernate --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" p:packagesToScan="com.pandy.ssh4.domian"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> ${hibernate.dialect} </prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.format_sql">false</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory </prop> <prop key="hibernate.cache.use_structured_entries">true</prop> <prop key="hibernate.generate_statistics">true</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" /> <!-- JBPM 5.4 --> <bean id="xDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://127.0.0.1:3306/jbpmtest?characterEncoding=UTF-8" /> <property name="username" value="root" /> <property name="password" value="root" /> </bean> <bean id="jbpmEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="xDataSource" /> <property name="persistenceUnitName" value="org.jbpm.persistence.local" /> </bean> <bean id="jbpmTxManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="jbpmEntityManagerFactory" /> <!-- 这里要是为false的话,提交事物的时候,容易报错 --> <property name="nestedTransactionAllowed" value="true" /> </bean> <drools:grid-node id="node1" /> <drools:kstore id="kstore1" /> <drools:kbase id="kbase" node="node1"> <drools:resources> <drools:resource type="BPMN2" source="classpath:Sample.bpmn" /> </drools:resources> </drools:kbase> <drools:ksession id="ksession" type="stateful" kbase="kbase" node="node1"> <drools:configuration> <drools:jpa-persistence> <drools:transaction-manager ref="jbpmTxManager" /> <drools:entity-manager-factory ref="jbpmEntityManagerFactory" /> </drools:jpa-persistence> </drools:configuration> </drools:ksession> <bean id="systemEventListener" class="org.drools.SystemEventListenerFactory" factory-method="getSystemEventListener" /> <bean id="internalTaskService" class="org.jbpm.task.service.TaskService"> <property name="systemEventListener" ref="systemEventListener" /> </bean> <bean id="htTxManager" class="org.drools.container.spring.beans.persistence.HumanTaskSpringTransactionManager"> <constructor-arg ref="jbpmTxManager" /> </bean> <bean id="springTaskSessionFactory" class="org.jbpm.task.service.persistence.TaskSessionSpringFactoryImpl" init-method="initialize" depends-on="internalTaskService"> <property name="entityManagerFactory" ref="jbpmEntityManagerFactory" /> <property name="transactionManager" ref="htTxManager" /> <property name="useJTA" value="true" /> <property name="taskService" ref="internalTaskService" /> </bean> <bean id="taskService" class="org.jbpm.task.service.local.LocalTaskService" depends-on="internalTaskService"> <constructor-arg ref="internalTaskService" /> </bean> <bean id="myLocalTaskService" class="com.gds.jbpm.MyLocalTaskService"> <property name="ksession" ref="ksession" /> <property name="localTaskService" ref="taskService" /> </bean> </beans