Integration with spring is simple:
1) Submit the transaction to spring for management.
2) use spring to obtain the Process Engine processengine.
Add the jbpm. cfg. xml file to the src directory of the project:
<? XML version = "1.0" encoding = "UTF-8" ?> < Jbpm-Configuration > < Import Resource = "Jbpm. Default. cfg. xml" /> < Import Resource = "Jbpm. businesscalendar. cfg. xml" /> <! -- <Import resource = "jbpm. TX. hibernate. cfg. xml"/> --> <! -- Integrated with spring --> < Import Resource = "Jbpm. TX. Spring. cfg. xml" /> < Import Resource = "Jbpm. jpdl. cfg. xml" /> < Import Resource = "Jbpm. BPMN. cfg. xml" /> < Import Resource = "Jbpm. Identity. cfg. xml" /> <! -- Job executor is excluded for running the example test cases. --> <! -- To enable timers and messages in production use, this shocould be pinned ded. --> <! -- <Import resource = "jbpm. jobexecutor. cfg. xml"/> --> </ Jbpm-Configuration >
Add the following configuration in the spring configuration file applicationcontext. xml:
< Bean ID = "Sessionfactory" Class = "Org. springframework. Orm. hibernate3.localsessionfactorybean" > < Property Name = "Datasource" Ref = "Mydatasource" /> <! -- Ing the object configuration file of jbpm4.4 --> < Property Name = "Mappingjarlocations" > < Value > WEB-INF/lib/jbpm. Jar </ Value > </ Property > < Property Name = "Hibernateproperties" > < Value > Hibernate. dialect = org. hibernate. dialect. mysql5dialect <! -- Automatic table Creation --> Hibernate. hbm2ddl. Auto = Update </ Value > </ Property > </ Bean > <! -- Jbpm4.4 Configuration --> < Bean ID = "Springhelper" Class = "Org. jbpm. PVM. Internal. processengine. springhelper" > < Property Name = "Jbpmcfg" Value = "Jbpm. cfg. xml" > </ Property > </ Bean > < Bean ID = "Processengine" Factory-bean = "Springhelper" Factory-Method = "Createprocessengine" />
Of course, the jar package of jbpm4.4 must also be copied to the project path. Pay attention to some jar package conflicts.