jbpm入门
先生成jbpm数据库表,如何生成数据库表呢
在官网下载jbpm-4.4.zip文件,然后在cmd窗口下进入install目录,
执行 ant -Ddatabase=mysql create.jbpm.schema 就可以生成jbpm的表了
然后在项目下创建一个jbpm.cfg.xml的文件
<?xml version="1.0" encoding="UTF-8"?> <jbpm-configuration> <import resource="jbpm.default.cfg.xml" /> <import resource="jbpm.tx.hibernate.cfg.xml" /> <import resource="jbpm.jpdl.cfg.xml" /> <import resource="jbpm.bpmn.cfg.xml" /> <import resource="jbpm.identity.cfg.xml" /> <import resource="jbpm.businesscalendar.cfg.xml" /> <import resource="jbpm.console.cfg.xml" /> <!-- <import resource="jbpm.jobexecutor.cfg.xml" /> --> </jbpm-configuration>
创建一个jbpm.hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jbpmdb</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">root</property> <property name="hibernate.show_sql">false</property> <property name="hibernate.format_sql">false</property> <mapping resource="jbpm.repository.hbm.xml" /> <mapping resource="jbpm.execution.hbm.xml" /> <mapping resource="jbpm.history.hbm.xml" /> <mapping resource="jbpm.task.hbm.xml" /> <mapping resource="jbpm.identity.hbm.xml" /> </session-factory> </hibernate-configuration>
如何通过eclipse创建一个jbpm 4 process definition文件,然后大压缩zip使用html上传到服务器
<s:actionmessage/> <s:form action="upload" method="post" enctype="multipart/form-data"> <s:file name="file" ></s:file> <s:submit value="上传"></s:submit> </s:form>
package com.chen; import java.io.File; import java.io.FileInputStream; import java.util.zip.ZipInputStream; import org.jbpm.api.Configuration; import org.jbpm.api.ProcessEngine; import org.jbpm.api.RepositoryService; import com.opensymphony.xwork2.ActionSupport; public class UploadAction extends ActionSupport{ private File file; public File getFile() { return file; } public void setFile(File file) { this.file = file; } @Override public String execute() throws Exception { ProcessEngine p = Configuration.getProcessEngine(); RepositoryService r = p.getRepositoryService(); String id = r.createDeployment().addResourcesFromZipInputStream( new ZipInputStream(new FileInputStream(file))).deploy(); this.addActionMessage("部署id为" + id); return "success"; } }
这让就完成了jbpm流程的基本部署,下一节我们讲一下jbpm流程的使用.