1、下载jbpm4.3的包.下载地址.谷歌搜索.谢谢
2、在eclipse中安装jpdl插件.如何安装,请看上一篇博客
3、建立web项目,导入ssh框架所需要的包,以及jbpm包.如果你说你不会,那就甭干程序员了,哈哈
4、建立ssh框架的必要环境.如在web.xml中配置struts.xml,struts.xml中配置spring.xml(即applicationContext.xml)文件.如果你不会.那就看下面的代码.
spring.xml文件中建立连接数据库的环境.如下:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:net/*/webjbpm/dataResources.properties</value>
</property>
</bean>
<!--建立数据库环境-->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${JdbcDriverName}</value>
</property>
<property name="url">
<value>${ConnectString}</value>
</property>
<property name="username">
<value>${UserID}</value>
</property>
<property name="password">
<value>${Password}</value>
</property>
</bean>
<!--创建流程引擎-->
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
<!--
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref bean="dataSource" /></property>
<property name="hibernateProperties">
<props>
<!--<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>-->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>net/bolue/webjbpm/Apply.hbm.xml</value>
<!--导入jbpm所需要的hbm.xml文件-->
<value>jbpm.repository.hbm.xml</value>
<value>jbpm.execution.hbm.xml</value>
<value>jbpm.history.hbm.xml</value>
<value>jbpm.task.hbm.xml</value>
<value>jbpm.identity.hbm.xml</value>
</list>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="txProxyTemplate" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
</beans>
在struts.xml最后action-mapping下面加上如下代码:
<controller inputForward="true"
processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />
<message-resources
parameter="cn.com.bolue.basic.resource.ApplicationResources" />
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="classpath:spring.xml;classpath:spring-process.xml" />
</plug-in>
注意,为什么一定要在这个里面加上classpath呢,那是因为spring.xml(就是applicationContext.xml)文件需要放在src的文件夹下面,主要是jbpm中的jbpm.cft.xml文件需要放在src下面,要不然路径会很让人头疼。我整了很多天,也没有整清楚,建议你不要费那脑劲想了。能用就行。
web.xml中配上struts.xml文件,这不用教吧,作为一个用框架熟练的程序员,这都不会.那还敢干程序吗。
下面再是action中的文件,在action中代码如下:
private ProcessEngine processEngine = null ;
private RepositoryService repositoryService = null;
private ExecutionService executionService = null;
private ProcessInstance processInstance = null;
private TaskService taskService = null;
private Task task = null;
private Execution execution = null;
private List list = null;
private List<Task> taskList = null;
private String url = "";
/* 初始化ProcessEngine. */
public void setServlet(ActionServlet actionServlet) {
super.setServlet(actionServlet);
if (actionServlet != null) {
processEngine = new Configuration().buildProcessEngine();
repositoryService = processEngine.getRepositoryService();
executionService = processEngine.getExecutionService();
taskService = processEngine.getTaskService();
}
}
下一下:
jbpm.cfg.xml文件写入:
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<!--一般是jbpm.tx.hibernate.cfg.xml改为以下文件-->
<import resource="jbpm.tx.spring.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.bpmn.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<!-- Job executor is excluded for running the example test cases. -->
<!-- To enable timers and messages in production use, this should be included. -->
<!--
<import resource="jbpm.jobexecutor.cfg.xml" />
-->
<import resource="jbpm.mail.templates.examples.xml" />
<!--注意,加此处是因为如果不是默认的applicationContext.xml文件就需要加以下代码以及路径了-->
<process-engine-context>
<string name="spring.cfg" value="classpath:spring.xml" />
</process-engine-context>
后面,就可以随心所欲的使用jbpm了.框架与JBPM4.3整合完毕。谢谢..其他的问题自行解决.
最后一点注意,spring的业务类注入时要与spring.xml(applicationContext.xml)分开注入,不要放在一个配置文件里面,要不然,会一直循环启动的.