问题: 是否可以参考别人的http://panyongzheng.iteye.com/blog/1871631一些配置,来进行改进applicationContext.xml和JbpmSupport.java的一些信息。待研究......
pom.xml
<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>com</groupId> <artifactId>JBPM5sh</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>JBPM5sh Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <junit.version>4.8.2</junit.version> <slf4j.version>1.6.1</slf4j.version> <log4j.version>1.2.16</log4j.version> <jstl.version>1.1.2</jstl.version> <servlet.version>2.5</servlet.version> <javaee-api.version>6.0</javaee-api.version> <jsp-api.version>2.1</jsp-api.version> <jsp.version>2.0</jsp.version> <spring.version>3.1.4.RELEASE</spring.version> <aspectj.version>1.6.2</aspectj.version> <drools.version>5.3.1.Final</drools.version> <jbpm.version>5.2.0.Final</jbpm.version> <jbpm.stable.version>5.2.0.Final</jbpm.stable.version> <codehaus.btm.version>2.1.1</codehaus.btm.version> <thoughtworks.xstream.version>1.3.1</thoughtworks.xstream.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> </properties> <dependencies> <!-- 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>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>${cglib.version}</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>${servlet.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <version>${jsp.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>${jstl.version}</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>${jstl.version}</version> </dependency> <dependency> <groupId>org.jboss.netty</groupId> <artifactId>netty</artifactId> <version>${jboss.netty.version}</version> </dependency> <!-- JBPM5.2 --> <dependency> <groupId>org.drools</groupId> <artifactId>drools-spring</artifactId> <version>${drools.version}</version> <exclusions> <exclusion> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.drools</groupId> <artifactId>drools-persistence-jpa</artifactId> <version>${drools.version}</version> <exclusions> <exclusion> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-human-task</artifactId> <version>${jbpm.stable.version}</version> <exclusions> <exclusion> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-flow</artifactId> <version>${jbpm.version}</version> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-bpmn2</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-flow-builder</artifactId> <version>${jbpm.version}</version> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-bam</artifactId> <version>${jbpm.version}</version> <exclusions> <exclusion> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.codehaus.btm</groupId> <artifactId>btm</artifactId> <version>${codehaus.btm.version}</version> </dependency> <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> <version>${thoughtworks.xstream.version}</version> <type>jar</type> </dependency> <!-- 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> <!-- 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> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> <!-- <dependency> <groupId>jaxen</groupId> <artifactId>jaxen</artifactId> <version>1.1.3</version> <exclusions> <exclusion> <artifactId>maven-cobertura-plugin</artifactId> <groupId>maven-plugins</groupId> </exclusion> <exclusion> <artifactId>maven-findbugs-plugin</artifactId> <groupId>maven-plugins</groupId> </exclusion> </exclusions> </dependency> --> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>commons-pool</groupId> <artifactId>commons-pool</artifactId> <version>1.6</version> </dependency> </dependencies> <build> <finalName>JBPM5sh</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>/JBPM5sh</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>
<drools.version>5.3.1.Final</drools.version>,这个不能是5.2.1之前的版本,否则出现:Transaction is already completed - do not call commit or rollback more than once per transaction, 让你几乎一天都找不到原因。
src/main/resources/META-INF/persistence.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <persistence version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/persistence"> <persistence-unit name="org.jbpm.persistence.jpa" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <mapping-file>META-INF/JBPMorm.xml</mapping-file> <mapping-file>META-INF/Taskorm.xml</mapping-file> <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class> <class>org.drools.persistence.info.SessionInfo</class> <class>org.drools.persistence.info.WorkItemInfo</class> <class>org.drools.persistence.info.SessionInfo</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> <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> <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>
这里涉及多数据源的二级缓存,所以这里也添加二级缓存的信息,同时applicationContext.xml也会添加二级缓存的信息。
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/webapp/WEB-INF/web.xml
<?xml version="1.0" encoding="gbk"?> <!--<!DOCTYPE web-app PUBLIC --> <!-- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" --> <!-- "http://java.sun.com/dtd/web-app_2_3.dtd" > --> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener </listener-class> </listener> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <listener> <listener-class>org.springframework.web.context.request.RequestContextListener </listener-class> </listener> <servlet> <servlet-name>JBPM5sh</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>JBPM5sh</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter </filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
src/main/webapp/WEB-INF/JBPM5sh-servlet.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" 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-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <context:component-scan base-package="com.pandy.ssh4.controller,com.gds.web" /> <mvc:annotation-driven/> <mvc:resources location="/resources/" mapping="/resources/**"/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/"></property> <property name="suffix" value=".jsp"></property> </bean> </beans>
src/main/resources/META-INF/Taskorm.xml
<?xml version="1.0" encoding="UTF-8"?> <entity-mappings version="2.0" 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 http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"> <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, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity businessAdministrator where 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, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity excludedOwners where 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, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy left join t.taskData.actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where 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="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, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy left join t.taskData.actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where ( 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="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, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy left join t.taskData.actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where 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, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy left join t.taskData.actualOwner left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity potentialOwners where t.taskData.parentId = :parentId 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="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, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.subjects as subject left join t.descriptions as description left join t.names as name where 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, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity recipients where 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, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity taskInitiator where 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, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy left join t.subjects as subject left join t.descriptions as description left join t.names as name, OrganizationalEntity taskStakeholder where 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, t.taskData.actualOwner, t.taskData.createdBy, t.taskData.createdOn, t.taskData.activationTime, t.taskData.expirationTime, t.taskData.processId, t.taskData.processSessionId) from Task t left join t.taskData.createdBy 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 ( 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 (d in elements( t.deadlines.startDeadlines ) or d in elements( t.deadlines.endDeadlines ) ) and d.escalated = false 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.taskData.workItemId = :workItemId </query> <!-- hint name="org.hibernate.timeout" value="200"/ --> </named-query> <sql-result-set-mapping name="ProcessInstancesWaitingForEvent.mapping"> <column-result name="InstanceId" /> </sql-result-set-mapping> <entity class="org.jbpm.persistence.processinstance.ProcessInstanceInfo"> <attributes> <element-collection name="eventTypes"> <collection-table name="EventTypes"> <join-column name="InstanceId" /> </collection-table> </element-collection> </attributes> </entity> </entity-mappings>
注意,这里使用了version=2.0, entity-mappings version="2.0"
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/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/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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:drools="http://drools.org/schema/drools-spring" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.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://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://drools.org/schema/drools-spring http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.2.0.xsd" default-autowire="byName" default-lazy-init="true"> <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> <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" /> <!-- JBPM5.2.x --> <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="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="xDataSource" /> <property name="persistenceUnitName" value="org.jbpm.persistence.jpa" /> </bean> <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <drools:grid-node id="node1" /> <drools:kstore id="kstore1" /> <drools:kbase id="kbase1" node="node1"> <drools:resources> <drools:resource id="resource1" type="BPMN2" source="classpath:Sample.bpmn" /> </drools:resources> </drools:kbase> <drools:ksession id="ksession" type="stateful" kbase="kbase1" node="node1"> <drools:configuration> <drools:jpa-persistence> <drools:transaction-manager ref="txManager" /> <drools:entity-manager-factory ref="entityManagerFactory" /> </drools:jpa-persistence> </drools:configuration> </drools:ksession> </beans>
这里使用了多数据源的缓存,每个数据源都要配置二级缓存的。
src/main/java/com/gds/jbpm/JbpmSupport.java
package com.gds.jbpm; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.persistence.EntityManagerFactory; import org.drools.SystemEventListenerFactory; import org.drools.runtime.StatefulKnowledgeSession; import org.jbpm.process.audit.JPAProcessInstanceDbLog; import org.jbpm.process.audit.JPAWorkingMemoryDbLogger; import org.jbpm.process.workitem.wsht.SyncWSHumanTaskHandler; import org.jbpm.task.TaskService; import org.jbpm.task.service.TaskServiceSession; import org.jbpm.task.service.local.LocalTaskService; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @Service("jbpmSupport") public class JbpmSupport { @Resource @Qualifier("entityManagerFactory") private EntityManagerFactory entityManagerFactory; @Resource @Qualifier("ksession") private StatefulKnowledgeSession ksession; private TaskServiceSession taskServiceSession; /** * <dt>核心就是两个session: * <dd>KnowledgeSession 可以完全通过spring drools配置成功 * <dd>TaskServiceSession 这里通过手动编码产生local service * * <dt>todo 学习点: * <dd>能否完全使用spring xml配置出两个session * <dd>usergroup callback的作用和用法进一步研究 */ @PostConstruct public void init() { System.out.println("初始化Service类[JbpmSupport]------------------------------------------------------------------------."); // 为 ksession 设置log new JPAWorkingMemoryDbLogger(ksession); new JPAProcessInstanceDbLog(ksession.getEnvironment()); // 创建 local human service 及其 handler org.jbpm.task.service.TaskService tService = new org.jbpm.task.service.TaskService(entityManagerFactory, SystemEventListenerFactory.getSystemEventListener()); taskServiceSession = tService.createSession(); // TODO 事务该如何设置? // taskServiceSession.setTransactionType("RESOURCE_LOCAL"); SyncWSHumanTaskHandler humanTaskHandler = new SyncWSHumanTaskHandler(new LocalTaskService(taskServiceSession), ksession); humanTaskHandler.setLocal(true); humanTaskHandler.connect(); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler); // set user group callback System.setProperty("jbpm.usergroup.callback", "org.jbpm.task.service.DefaultUserGroupCallbackImpl"); } public StatefulKnowledgeSession getKsession() { return ksession; } public TaskService getTaskService() { return new LocalTaskService(taskServiceSession); } }
src/main/java/com/pandy/ssh4/domian/Table3.java
package com.pandy.ssh4.domian; // Generated 2013-3-7 17:34:40 by Hibernate Tools 4.0.0 import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; /** * Table3 generated by hbm2java */ @SuppressWarnings("serial") @Entity @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) @Table(name = "TABLE3") public class Table3 extends BasicDomian implements java.io.Serializable { ...... }
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) ,便是这个类会被缓存
在DAO里面使用缓存命令
@SuppressWarnings("rawtypes") public void doEhcache1() { Session session = getCurrentSession(); String hql = " from com.pandy.ssh4.domian.Table3"; Query query = session.createQuery(hql); query.setCacheable(true);//设定使用缓存 List list = query.list(); System.out.println(list.size()); }
启动时出现:
13-05-20 11:30 DEBUG DefaultListableBeanFactory:1498 - Invoking afterPropertiesSet() on bean with name 'kbase1'
(null: 52, 58): cvc-id.2: ID 值 '_3_ContentInput' 出现了多次。
(null: 52, 58): cvc-attribute.3: 在元素 'dataInput' 中, 属性 'id' 的值 '_3_ContentInput' 与其类型 'ID' 不匹配。
(null: 162, 58): cvc-id.2: ID 值 '_9_ContentInput' 出现了多次。
(null: 162, 58): cvc-attribute.3: 在元素 'dataInput' 中, 属性 'id' 的值 '_9_ContentInput' 与其类型 'ID' 不匹配。
相关推荐
标题中的"Spring 3.1.x + Hibernate 4.2.x + JBPM 5.2 + Ecache例子源码"代表了一个集成开发环境,其中包含了四个关键的技术组件: 1. **Spring 3.1.x**:这是一个开源的应用框架,主要用于简化Java企业级应用的...
标题 "Spring 3.1.x + Hibernate 4.2.x + JBPM 5.2 + Ecache 例子" 涉及的是一个集成多种技术的Java应用开发示例。这个项目可能是一个完整的业务流程管理系统,它整合了Spring、Hibernate、JBPM和Ecache等关键组件。...
标题中的"spring+struts1+hibernate+jbpm实例"揭示了这是一个基于Java技术栈的Web应用程序开发实例,其中涉及四大核心技术:Spring、Struts1、Hibernate和JBPM。接下来,我们将深入探讨这些技术及其在实际项目中的...
**jBPM用户手册3.1.X 知识点详解** jBPM(Java Business Process Management)是一款开源的工作流管理系统,用于实现业务流程自动化。它提供了业务规则、事件处理、工作流、协作以及业务监控等功能,是Java开发环境...
- **配置文件**:jbpm4的配置文件如`jbpm.cfg.xml`需要正确配置,并且可能需要导入其他配置资源,如`jbpm.spring.default.cfg.xml`、`jbpm.spring.hibernate.cfg.xml`等。 5. **jbpm4的流程设计** - **JPDL**:...
在本示例中,我们探讨的是一个集成项目,它结合了Spring 3.1、Hibernate 4.2.1、JBPM 5.4和Ehcache,这四个组件都是Java开发中的关键工具,用于构建高效、可扩展的企业级应用程序。 **Spring 3.1**: Spring是一个...
配置文件是整合的关键部分,例如jbpm.cfg.xml是jbpm的主要配置文件,通常需要导入多个子配置,如jbpm.spring.default.cfg.xml、jbpm.spring.hibernate.cfg.xml等,这些配置文件会定义流程引擎、Spring上下文、...
这是一个基于Java技术栈,采用Spring、Struts、Hibernate、jbpm和DWR等多种框架整合开发的OA(Office Automation)办公系统源码项目。这个系统的构建旨在实现企业的日常办公自动化,提高工作效率,简化工作流程,...
jbpm4整合struts2+spring2[1].5+hibernate3.3
整合这些技术时,开发者通常会创建一个综合的配置文件体系,例如Spring的配置文件可以管理所有组件的依赖和配置,通过引入Struts、Hibernate、JPA、Lucene、JBPM和Compass的相关配置。这需要对每个框架的原理有深入...
【标题】"简单的spring2+struts2+hibernate3.2+jbpm3应用框架"揭示了一个经典的Java企业级开发架构,该框架整合了四个核心组件:Spring 2.x、Struts 2.x、Hibernate 3.2以及jBPM 3。这些技术在2000年代末到2010年代...
3. **spring配置文件**:整合Spring、Hibernate以及jBPM的关键配置。 根据提供的部分代码示例,我们可以看到Spring配置文件的关键内容如下: - **数据源配置**:使用`DriverManagerDataSource`来配置数据源的信息...
《构建基于Spring、Struts2、Hibernate的工作流系统——HRSystem》 在现代企业信息化建设中,工作流管理系统(Workflow Management System,WfMS)扮演着至关重要的角色,它能够自动化处理业务流程,提高工作效率。...
在J2EE开发中,处理大数据对象(如大文本或二进制数据)时,Oracle数据库的CLOB...通过以上配置和操作,你可以在Spring和Hibernate的环境中顺利地对Oracle数据库的CLOB字段进行读写,满足J2EE应用中的大数据存储需求。
基于Struts、Spring和Hibernate的集成框架SSH,加上流程管理工具jbpm,构建出的工作流系统是一种高效、灵活的企业级应用解决方案。这种系统主要用于实现业务流程自动化,提升企业的运营效率。 **Struts**:Struts是...
Struts2、Spring、Hibernate和Jbpm是Java开发中常用的技术栈,它们结合在一起可以构建出高效、灵活的企业级应用。在这个“struts2+spring+hibernate+jbpm工作流实例”中,主要展示了如何利用这些技术实现一个公文...
在这个配置中,我们将探讨如何将这些框架集成在一起,创建一个基于Spring 2.5.4、Hibernate 3.2.6、Struts2和jbpm3.2.2的应用。 1. **Spring框架**: - Spring 2.5.4作为应用的核心容器,负责管理应用的bean(对象...
这个项目将Spring、Hibernate 4 和 Jbpm 4.4 整合在一起,构建了一个强大的企业级应用平台。SpringMVC处理HTTP请求,控制业务逻辑;Hibernate负责数据持久化,处理与MySQL的交互;Jbpm则用于流程管理和执行。这样的...
### 整合JBPM到现有的Spring+Hibernate系统 在企业级应用开发中,流程管理和业务逻辑的自动化变得越来越重要。JBPM(JBoss Business Process Management)作为一款灵活且功能强大的工作流引擎,常被用于此类场景。...