jPBM4.3 -- 第四节 动态发布与删除流程实例
来源:互联网 发布:一句话恐怖故事 知乎 编辑:程序博客网 时间:2024/05/18 00:06
package com.darren.action;
import java.util.List;
import org.jbpm.api.Configuration;
import org.jbpm.api.NewDeployment;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessDefinitionQuery;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.RepositoryService;
import org.springframework.stereotype.Controller;
@Controller//控制层
publicclass ProcessAction {
private List<ProcessDefinition>processDefinitionList;
private StringdeploymentId;
public String deployProcess() {
//得到一个查询服务
RepositoryService repositoryService =this.getRepositoryService();
//获取一个部署对象
NewDeployment newDeployment = repositoryService.createDeployment();
//加载流程部署文件并部署发布流程
newDeployment.addResourceFromClasspath("leave.jpdl.xml").deploy();
return"deploy";
}
public String deleteProcess() {
RepositoryService repositoryService =this.getRepositoryService();
repositoryService.deleteDeploymentCascade(deploymentId);
return"delete";
}
public String listDefinitionProcess() {
RepositoryService repositoryService =this.getRepositoryService();
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
processDefinitionList = processDefinitionQuery.list();
return"list";
}
private RepositoryServicegetRepositoryService() {
//得到一个流程控制引擎
ProcessEngine processEngine = Configuration.getProcessEngine();
//得到一个查询服务
RepositoryService repositoryService = processEngine.getRepositoryService();
return repositoryService;
}
public List<ProcessDefinition> getProcessDefinitionList() {
returnprocessDefinitionList;
}
publicvoid setDeploymentId(String deploymentId) {
this.deploymentId = deploymentId;
}
}
struts.xml文件
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEstruts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- 默认的视图主题 -->
<constantname="struts.ui.theme"value="simple"/>
<!-- 使用spring工厂类去替换struts默认的工厂类 Action由spring进行创建和维护,而不再由struts进行管理-->
<constantname="struts.objectFactory"value="spring"/>
<packagename="process" extends="struts-default">
<action name="deployProcess"class="processAction"method="deployProcess">
<result name="deploy"type="redirect">listDefinitionProcess</result>
</action>
<action name="deleteProcess"class="processAction"method="deleteProcess">
<result name="delete"type="redirect">listDefinitionProcess</result>
</action>
<action name="listDefinitionProcess"class="processAction"method="listDefinitionProcess">
<resultname="list">/WEB-INF/pages/index.jsp</result>
</action>
</package>
</struts>
applicationContext.xml文件
<?xmlversion="1.0"encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!--开启注解方式使用IOC -->
<context:annotation-config/>
<context:component-scanbase-package="com.darren"/>
<beanid="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"lazy-init="false">
<propertyname="locations">
<list>
<value>classpath:database.properties</value>
</list>
</property>
</bean>
<beanid="dataSource"class="com.mchange.v2.c3p0.ComboPooledDataSource"destroy-method="close">
<propertyname="driverClass">
<value>${jdbc.driverClass}</value>
</property>
<property name="jdbcUrl">
<value>${jdbc.url}</value>
</property>
<property name="user">
<value>${jdbc.uesrName}</value>
</property>
<property name="password">
<value>${jdbc.passWord}</value>
</property>
<!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
<propertyname="initialPoolSize"value="1"/>
<!--连接池中保留的最小连接数。-->
<propertyname="minPoolSize"value="1"/>
<!--连接池中保留的最大连接数。Default: 15 -->
<propertyname="maxPoolSize"value="300"/>
<!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
<propertyname="maxIdleTime"value="60"/>
<!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
<propertyname="acquireIncrement"value="5"/>
<!--每60秒检查所有连接池中的空闲连接。Default: 0 -->
<propertyname="idleConnectionTestPeriod"value="60"/>
</bean>
<beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<propertyname="dataSource"ref="dataSource"/>
<propertyname="mappingResources">
<list>
</list>
</property>
<propertyname="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=true
hibernate.format_sql=false
</value>
</property>
</bean>
<beanid="txManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<propertyname="sessionFactory"ref="sessionFactory"/>
</bean>
<!--使用基于注解方式配置事务 -->
<tx:annotation-driventransaction-manager="txManager"/>
</beans>
hibernate配置部分暂时没有用到
- jPBM4.3 -- 第四节 动态发布与删除流程实例
- jPBM4.3 -- 第三节 管理流程实例
- jPBM4.3 -- 第二节 管理流程定义
- jpbm4入门实践之web请假流程。
- java流程管理 之 jbpm流程实例 发布、查看、终止、删除
- java流程管理 之 jbpm流程实例 发布、查看、终止、删除
- JBPM发布流程、查询流程、删除流程
- JBPM4删除流程实例
- jPBM4.3 -- 第一节 配置开发环境
- jbpm发布流程定义,启动流程实例
- activiti删除流程实例与activiti删除部署的流程,是初学者最容易犯的错误
- java流程管理 之 jbpm流程定义、发布、查看、删除
- 建立与删除复制发布
- 第四章 流程控制与数组
- Activiti挂起或者删除一个流程实例
- jpbm4.4之一个简单的流程(来自example的custom)
- 动态项目引用与发布
- ReactNative 第四节 实例开发
- 一个简单web服务器的实现
- Silverlight调用Webservice出现的跨域问题
- Android基础--Gallery画廊控件
- arm处理器裸机开发实战——学习笔记2
- java equals() 和toString()方法重写
- jPBM4.3 -- 第四节 动态发布与删除流程实例
- Hibernate 简单的增删改查 示例
- mcrypt.so 下载 环境为 OS X 10.8.2 和 php5.3.15
- 【转载】DirectShow 一些常见编译错误的处理
- 4类业务员(顾问+利益+解决问题+勤奋)=(知识+人际关系+执行+勤奋)
- Nginx
- 国外的街头3D艺术与咱自家的街头3D艺术
- android onTouchEvent 左右手势滑动事件处理
- ubuntu下编译OpenGL