uflo2
是一套由BSTEK
自主研发的基于Java
的工作流引擎,它以Spring
为基础框架,采用Hibernate
作为持久层,可运行于所有主流程应用服务器及流数据库之上的轻量级流程引擎。
本文主要介绍若依集成
uflo2
的流程
ruoyi-uflo
可参考【若依创建子模块详细教程(四)】
uflo2
依赖<description>
uflo2流程管理模块
</description>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
<!-- uflo2依赖包-->
<dependency>
<groupId>com.bstek.uflo</groupId>
<artifactId>uflo-console</artifactId>
<version>2.1.4</version>
</dependency>
</dependencies>
位置:
ruoyi-uflo/src/main/java/com/ruoyi/ruoyiuflo/config/ServletConfig.java
package com.ruoyi.ruoyiuflo.config;
import com.bstek.uflo.console.UfloServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ServletConfig {
@Bean
public ServletRegistrationBean buildUfloServlet(){
return new ServletRegistrationBean(new UfloServlet(),"/uflo/*");
}
}
位置:
ruoyi-uflo/com/ruoyi/ruoyiuflo/config/UfloConfig.java
package com.ruoyi.ruoyiuflo.config;
import org.hibernate.SessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.hibernate5.HibernateTransactionManager;
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
import javax.sql.DataSource;
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.util.Properties;
@Configuration
public class UfloConfig {
@Bean("localSessionFactoryBean")
public LocalSessionFactoryBean localSessionFactoryBean(DataSource dataSource) throws
PropertyVetoException, IOException {
LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource);
sessionFactoryBean.setPackagesToScan("com.bstek.uflo.model*");
Properties prop = new Properties();
prop.put("hibernate.dialect","org.hibernate.dialect.MySQL5Dialect");
prop.put("hibernate.show_sql",false);
prop.put("hibernate.hbm2ddl.auto","update");
prop.put("hibernate.jdbc.batch_size",100);
sessionFactoryBean.setHibernateProperties(prop);
return sessionFactoryBean;
}
@Bean("ufloTransactionManager")
public HibernateTransactionManager ufloTransactionManager(SessionFactory sessionFactory){
HibernateTransactionManager hi = new HibernateTransactionManager();
hi.setSessionFactory(sessionFactory);
return hi;
}
}
位置:
ruoyi-uflo/com/ruoyi/ruoyiuflo/env/TestEnviromentProvider.java
package com.ruoyi.ruoyiuflo.env;
import com.bstek.uflo.env.EnvironmentProvider;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import javax.annotation.Resource;
@Component
public class TestEnviromentProvider implements EnvironmentProvider {
@Autowired
private SessionFactory sessionFactory;
@Resource(name = "ufloTransactionManager")
private PlatformTransactionManager platformTransactionManager;
@Override
public SessionFactory getSessionFactory() {
return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@Override
public PlatformTransactionManager getPlatformTransactionManager() {
return platformTransactionManager;
}
public void setPlatformTransactionManager(PlatformTransactionManager platformTransactionManager) {
this.platformTransactionManager = platformTransactionManager;
}
@Override
public String getLoginUser() {
return null;
}
@Override
public String getCategoryId() {
return "anonymous";
}
}
位置:
ruoyi-admin
模块的配置启动类RuoYiApplication.java
@ImportResource("classpath:uflo-console-context.xml")
项目启动成功后,会自动在数据库生成uflo
相应的数据表
【待办任务】
http://localhost:8088/uflo/todo
【流程设计】
http://localhost:8088/uflo/designer
至此,访问代办任务和流程设计,若依集成uflo2
已经完成。
powered by kaifamiao