java工作流框架jbpm_Jbpm工作流与ssh框架集成
目录
简
述
使
用jbpm-starters-kit-3.1.4生成数据库表及安装eclipse图形化配置插件
部
署jbpm的jar包和moudle的jar包
部
署hbm文件到项目
设
置大字段string-max
配
置configration、template
过
滤器的设置与建立
编
写发布流程定义xml的人机页面及程序
写
在最后
简述
Jbpm工作流框架与现有ssh框架的集成工作其
实很简单,但国内外的资料太小,所以会在集成时走入太多误区,本文是在struts1.2,spring2.5,hibernate3.2上集成成功的详细步骤。其中解决了,jbpm的访问数据库session与原有hibernate的session不同的问
题,string-max大字段问题。完成了流程部署web及后台程序。利用spring-modules-0.8当中的spring31做为集成
的桥梁(其实它已经做好了集成,但文档和实例实在是太简单)。
使用jbpm-starters-kit-3.1.4生成数据库表及安装eclipse图形化配置插件
1下载jbpm-starters-kit-3.1.4到其网站,包含所有需要的工具及jar包。
2数据库的安装以oracle为例,其它
数据库可按此例修改。
2.1创建所需用户及表空间,如果有了用户和表空间就不需要了。
2.2找到jbpm-starters-kit-3.1.4文件夹,在其下的jbpm文件夹的下级文件夹lib中加入oracle的驱动包ojdbc14.jar.
2.3在jbpm"src"resources文件夹下建立oracle文件夹,将"jbpm"src"resources"hsqldb里的create.db.hibernate.properties和identity.db.xml文件copy到刚刚建立的oracle文件夹当中.
2.4修改create.db.hibernate.properties文件,修改目标数据库的连接属性如下:
# these properties are
used by the build script to create
# a hypersonic database
in the build/db directory that contains
# the jbpm tables and a
process deployed in there
hibernate.dialect=org.hibernate.dialect.OracleDialect
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.connection.url=jdbc:oracle:thin:@10.62.1.12:1521:oracle
hibernate.connection.username=dpf
hibernate.connection.password=dpf
hibernate.show_sql=true
hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
2.5修改jbpm"src"config.files"hibernate.cfg.xml文件,同样是配置数据库的连接属性如下:
name="hibernate.dialect">org.hibernate.dialect.OracleDialect
name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver
name="hibernate.connection.url">jdbc:oracle:thin:@10.62.1.12:1521:oracle
name="hibernate.connection.username">dpf
name="hibernate.connection.password">dpf
name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider
2.6修改jbpm"build.deploy.xml文件.找到create.db项并进行如下修改:
name="create.db" depends="declare.jbpm.tasks, db.clean, db.start"
description="creates a hypersonic database with the jbpm tables and
loads the processes in there">
actions="create"
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/oracle/create.db.hibernate.properties"/>
file="${basedir}/src/resources/oracle/identity.db.xml"
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/oracle/create.db.hibernate.properties"/>
antfile="build.xml" target="build.processes" inheritall="false" />
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/oracle/create.db.hibernate.properties">
dir="build" includes="*.process" />
target="db.stop" />
2.7配置ant,在jbpm目录执行ant create.db –buildfile build.deploy.xml命令。
会有一些小错误的提示,没有关系数据库的表已经建立完成。
2.8 eclipse的图形化配置插件安装文件可以到jbpm-starters-kit-3.1.4"jbpm-designer"
jbpm-gpd-feature"eclipse下找到,需注意版本。
部署jbpm的jar包和moudle的jar包
1把如下jar包放入"WEB-INF"lib文件夹下,spring-modules-jbpm31.jar可以在
spring-modules-0.8下找到,其它的都属于jbpm工具包。
bsh-1.3.0.jar
bsf.jar
spring-modules-jbpm31.jar
jbpm-webapp-3.1.4.jar
jbpm-identity-3.1.4.jar
jbpm-3.1.4.jar
部署hbm文件到项目
1在jbpm文件夹中找到所有
的*.hbm.xml数据库映射文件。放到项目的一个文件夹当中。本例放到"com"gresoft"security"model"hbm文件夹中。并且在hibernate的sessionfactory建立时,设置为相关路径配置。
2此文件需在spring管理的hibernate配置文件下修改,本例为
dataAccessContext-hibernate.xml,如下:
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
org.hibernate.dialect.Oracle9Dialect
true
org.hibernate.cache.EhCacheProvider
true
classpath*:/com/gresoft/security/model/hbm/
设置大字段string-max
1此文件需在spring管理的hibernate配置文件下修改,本例为
dataAccessContext-hibernate.xml,如下:
配置configration、template
说明:jbpmConfiguration是根据springmodules所
提供的
LocalJbpmConfigurationFactoryBean进行配置,其集成好对jbpmConfiguration的管理。在系统使用时JbpmConfiguration需调用jbpmTemplate的jbpmTemplate.getJbpmConfiguration()方法得到。
1此文件需在spring管理的hibernate配置文件下修改,本例为
dataAccessContext-hibernate.xml,如下:
2增加类路
径中jbpm.cfg.xml文件,可以根据
jbpm-starters-kit-3.1.4"jbpm"src"java.jbpm"org"jbpm"default.jbpm.cfg.xml
复制后修改。本例放到/datasql/jbpm.cfg.xml下。上面配置文件有相关配置。全部内容如下:
name="persistence">
class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
过滤器的设置与建立
过滤器的建立是为了保证一个session的正常工
作。
1 web.xml中的修改
本例中描述如下:
JbpmContextFilter
com.gresoft.components.jbpm.JbpmContextHolder
2建立对应的类文件
本例中描述如下:
package
com.gresoft.components.jbpm;
import
java.io.IOException;
import
java.io.Serializable;
import
java.security.Principal;
import
javax.servlet.Filter;
import
javax.servlet.FilterChain;
import
javax.servlet.FilterConfig;
import
javax.servlet.ServletException;
import
javax.servlet.ServletRequest;
import
javax.servlet.ServletResponse;
import
javax.servlet.http.HttpServletRequest;
import
org.jbpm.JbpmConfiguration;
import
org.jbpm.JbpmContext;
import
org.springframework.web.context.WebApplicationContext;
public class
JbpmContextHolder implements Filter, Serializable {
private static final long serialVersionUID = 1L;
String jbpmConfigurationResource = null;
String jbpmContextName = null;
boolean isAuthenticationEnabled = true;
public void init(FilterConfig filterConfig) throws
ServletException {
// get the jbpm configuration resource
this.jbpmConfigurationResource = filterConfig
.getInitParameter("jbpm.configuration.resource");
// get the jbpm context to be used from the jbpm configuration
this.jbpmContextName = filterConfig
.getInitParameter("jbpm.context.name");
if (jbpmContextName == null) {
jbpmContextName = JbpmContext.DEFAULT_JBPM_CONTEXT_NAME;
}
// see if authentication is turned off
String isAuthenticationEnabledText = filterConfig
.getInitParameter("authentication");
if ((isAuthenticationEnabledText != null)
&&
("disabled".equalsIgnoreCase(isAuthenticationEnabledText))) {
isAuthenticationEnabled = false;
}
}
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
String actorId = null;
// see if we can get the authenticated swimlaneActorId
if (servletRequest instanceof HttpServletRequest) {
HttpServletRequest httpServletRequest = (HttpServletRequest)
servletRequest;
Principal userPrincipal = httpServletRequest.getUserPrincipal();
if (userPrincipal != null) {
actorId = userPrincipal.getName();
}
}
JbpmContext jbpmContext = getJbpmConfiguration(servletRequest)
.createJbpmContext(jbpmContextName);
try {
if (isAuthenticationEnabled) {
jbpmContext.setActorId(actorId);
}
filterChain.doFilter(servletRequest, servletResponse);
} finally {
jbpmContext.close();
}
}
/*
*从spring获取JbpmConfiguration的bean加载方式
*/
protected JbpmConfiguration getJbpmConfiguration(
ServletRequest servletRequest) {
WebApplicationContext webApplicationContext =
(WebApplicationContext) ((HttpServletRequest) servletRequest)
.getSession()
.getServletContext()
.getAttribute(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
JbpmConfiguration jbpmConfiguration = (JbpmConfiguration)
webApplicationContext
.getBean("jbpmConfiguration");
//得到业务Bean(在这里是你需要
注入的bean)
System.out.println("------------------------------------------------------------------------------------------");
System.out.println("jbpmconfiguration对象化=" + jbpmConfiguration.toString());
System.out.println("------------------------------------------------------------------------------------------");
return jbpmConfiguration;
}
public void destroy() {
}
}
编写发布流程定义xml的人机页面及程序
1 JSP页面使用struts1.2,spring2.0,hibernate3.2框架。此为流程发布页面。
name="formupload" method="post" enctype="multipart/form-data">
请选择要发布的流程文件
type="file" id="workflowfile" >
name="submit">
2后台对应类
/*******************************************************************************
*文件名: JbpmAction.java
*版本:
*描述:
*版权所有:
*
*创建者:沙振中
*创建日期: Dec 27, 2007
*修改者:
*修改日期:
*修改说明:
******************************************************************************/
package
com.gresoft.security.web;
import
java.io.InputStream;
import
javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse;
import
org.apache.commons.beanutils.DynaBean;
import
org.apache.commons.logging.Log;
import
org.apache.commons.logging.LogFactory;
import
org.apache.struts.action.ActionForm;
import
org.apache.struts.action.ActionForward;
import
org.apache.struts.action.ActionMapping;
import
org.apache.struts.upload.FormFile;
import
org.jbpm.JbpmContext;
import
org.jbpm.graph.def.ProcessDefinition;
import
org.springmodules.workflow.jbpm31.JbpmTemplate;
import
com.gresoft.commons.core.web.StrutsAction;
public class JbpmAction
extends StrutsAction {
private static Log log = LogFactory.getLog(JbpmAction.class);
private JbpmTemplate jbpmTemplate;
public void setjbpmTemplate(JbpmTemplate jbpmTemplate) {
this.jbpmTemplate = jbpmTemplate;
}
/**
*进入上传流程主页面
*
@param mapping
*
@param form
*
@param request
*
@param response
*
@return
*/
public
ActionForward index(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
return mapping.findForward("delpoyindex");
}
/**
*上传流程文件
*
@param mapping
*
@param form
*
@param request
*
@param response
*
@return
*/
public
ActionForward deploy(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws
Exception {
DynaBean dy = (DynaBean) form;
FormFile file = (FormFile) dy.get("workflowfile");
InputStream is =
file.getInputStream();
JbpmContext jbpmContext =
jbpmTemplate.getJbpmConfiguration().createJbpmContext();
ProcessDefinition processDefinition =
ProcessDefinition.parseXmlInputStream(is);
//利用容器的方法将流程定义数据部署到
数据库上
jbpmContext.deployProcessDefinition(processDefinition);
//关闭jbpmContext
jbpmContext.close();
//提交到数据库当中,使用统一的session
jbpmTemplate.getHibernateTemplate().flush();
log.info("流程部署成功!");
return mapping.findForward("delpoyindex");
}
}
注:相关ssh配置文件的设置需根
据自己实际项目为准。
写在最后
通过上述集成的工作,可以使你的项目中很好的集成jbpm。Jbpm流程的设置需根据实际业务相绑定。现在我们就可以在项目当中应用工作流了。
java工作流框架jbpm_Jbpm工作流与ssh框架集成相关推荐
- 基于java jsp的健身房会员卡管理系统ssh框架
为了实现基于SSH框架和MySQL数据库的健身房会员卡管理系统,本文主要围绕会员卡管理的模块做了大量工作,同时也完善了会员信息的管理.首先分析了会员管理中的卡片管理,并且具体分析了其增加,修改,删除的 ...
- ssh框架怎么写ajax,SSH框架+Ajax(运用dwr框架)综合小实例[精校版本]
<SSH框架+Ajax(运用dwr框架)综合小实例[精校版本]>由会员分享,可在线阅读,更多相关<SSH框架+Ajax(运用dwr框架)综合小实例[精校版本](36页珍藏版)> ...
- Java 中实现定时服务 在ssh框架中跟普通工程里面创建的方式
http://www.iteye.com/topic/1119730 转载于:https://www.cnblogs.com/caixiaoqiu/archive/2012/02/03/2336818 ...
- java框架之ssh框架之认识
SSH框架 1.SSH框架是什么? SSH框架是struts+spring+hibernate的一个集成框架,分为四层:表示层.业务逻辑层.数据持久层和域模块层,其中使用Struts作为系统的整体基础 ...
- SSH框架配置及Maven使用
1.SSH框架配置 1.1. SSH框架介绍 1.2. SSH框架配置 所需资源下载: l jdk; 从Oracle官方网站:http://www.oracle.com/technetwork/cn/ ...
- SSH框架整合——基于注解
SSH框架整合--基于注解 @(Spring)[Spring, hibernate, struts2, 框架整合] SSH框架整合基于注解 SSH框架整合 第一步导入Jar包 第二步导入配置文件 第三 ...
- Java源码 JavaWeb开发框架 代码 SSH SSM OA ERP CRM Java项目[Java通用框架源码及开发视频教程]
Java源码 JavaWeb开发框架 代码 SSH SSM OA ERP CRM Java项目 功能简介: A.代码生成器(开发利器) 生成Java各层次的类和JSP等文件,提高开发效率 B.阿里巴巴 ...
- java ssh框架 struts spring hibernate 简介
目录 什么是SSH框架 浅谈Struts 什么是Struts Struts的核心构成 为什么使用Struts 浅谈Hibernate 什么是Hibernate Hibernate的核心构成 浅谈Spr ...
- 【Java Web后台实验与开发】关于SSH框架的探索
文章目录 1 什么是SSH? 2 学习SSH方法 ? 3 MVC是什么? 3.1 MVC 编程模式 4 struts五大组件介绍 5 Spring特征 6 Hibernate特征 7 框架和设计模式的 ...
- JAVA的SSH框架登录注册
Struts 的MVC设计模式可以使我们的逻辑变得很清晰,主要负责表示层的显示. Spring 的IOC和AOP可以使我们的项目在最大限度上解藕. hibernate的就是实体对象的持久化了, 数据库 ...
最新文章
- intouch负值显示0_excel 应用中计算结果显示为负数,使负数显示为0应如何操作?...
- java反编器中文版,java反编译软件下载
- 查看 Android SDK Build-tools 版本号
- HDU 1242 Rescue BFS+优先队列
- oracle数据表管理
- MySql 5.6.36 64位绿色版安装
- 下拉默认选择_在Excel中制作二级联动下拉菜单,太有用了
- Android设置无title报错
- 数据迁移期间进程命令
- Pyqt Model/view框架 3.可编辑项
- 推荐系统实践--基于用户的协同过滤算法
- MQTT客户端代码(C语言)
- 计算机基础知识题库pdf,计算机基础知识题库完整.pdf
- ATA和ATAPI类型硬盘区别方法
- lptwrite matlab,matlab读取地震数据sgy
- h5盲盒商城源码 修复版 附带详细教程
- 网络共享计算机权限访问,局域网共享时提示:你没有权限访问,请与网络管理员联系...
- html中字体设置为行书,行书的字体结构,漂亮的行书是如何写出来的(上)
- 百度网盘PC端扫描二维码登录时无法加载二维码问题解决方法
- C#里@字符d是什么意思
热门文章
- 安卓版的水经注地图_水经注万能地图下载器
- Java web 实战项目案例
- java怎么反编译_java如何进行反编译
- kido机器人用流量吗_拉在手心的爱-----乐视 KIDO有问必答的4G智能儿童手表评测...
- C语言Windows程序设计-第三天-属于自己的窗口
- 圈圈教你玩usb第一版硬件实物使用说明
- C语言计算机题库第91套,二级c语言上机题库 2013年9月全国计算机等级考试二级C语言上机题库100套.doc...
- 万稞pw80线切割编程软件_模具设计编程培训哪些内容?
- SQL:集成 SQL Server 2008 R2 SP3
- ubb码转换的java类库 ubb2html_ubb代码转换为html