jfinal集成activiti

有没有jfinal集成activiti的文档呀   

不会创建工作流在jfinal里面 

评论区

JFinal

2017-05-17 17:38

这里有相关资源可参考:
https://www.oschina.net/search?scope=blog&q=jfinal%20activiti

https://www.oschina.net/search?q=jfinal+activiti&scope=bbs&catalog=1&sort_by_time=1

雷仔仔

2017-05-18 13:52

运行报错呀 [ERROR]-[Thread: localhost-startStop-1]-[com.jfinal.core.Config.startPlugins()]: Plugin start error: com.demo.activiti.ActivitiPlugins.
null
java.lang.NullPointerException
at org.activiti.engine.impl.db.DbSqlSession.dbSchemaUpdate(DbSqlSession.java:993)
at org.activiti.engine.impl.db.DbSqlSession.performSchemaOperationsProcessEngineBuild(DbSqlSession.java:1385)
at org.activiti.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:25)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at org.activiti.engine.impl.ProcessEngineImpl.(ProcessEngineImpl.java:77)
at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:413)
at com.demo.activiti.ActivitiPlugins.buildProcessEngine(ActivitiPlugins.java:46)
at com.demo.activiti.ActivitiPlugins.start(ActivitiPlugins.java:26)

JFinal

2017-05-18 14:14

@雷仔仔 ActiveRecordPlugin 没有成功启动,所以后面在操作数据库时的时候会出现 NullPointerException

aarreess

2017-05-19 11:39

import com.jfinal.plugin.IPlugin;
import com.jfinal.plugin.activerecord.DbKit;
import com.zcqm.util.Para;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration;

public class ActivitiPlugins implements IPlugin
{
private static ProcessEngineConfiguration processEngineConfiguration = null;
private boolean isStarted = false;
private String dbSchema = null;
private String dbType = null;
private String labelFontName = "宋体";

@Override
public boolean start()
{
try
{
createProcessEngine();
}
catch (Exception e)
{
e.printStackTrace();
}
return true;
}

@Override
public boolean stop()
{
ProcessEngines.destroy();
isStarted = false;
return true;
}

private Boolean createProcessEngine() throws Exception
{
if (isStarted)
{
return true;
}
Para.log.debug("启动流程管理引擎.......");
StandaloneProcessEngineConfiguration conf = (StandaloneProcessEngineConfiguration) ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration();
conf.setDatabaseType(this.dbType);
conf.setDatabaseSchema(this.dbSchema); // ORACLE必须设置
conf.setDataSource(DbKit.getConfig(Para.defaultDbName).getDataSource());
conf.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE).setDbHistoryUsed(true);
conf.setTransactionFactory(new ActivitiTransactionFactory());
//conf.setTransactionsExternallyManaged(true); // 使用托管事务工厂
conf.setLabelFontName(this.labelFontName);
conf.setActivityFontName(this.labelFontName);
// conf.setTransactionFactory(new ActivitiTransactionFactory());
Para.pe = conf.buildProcessEngine();
Para.log.debug("启动流程管理引擎结束");
isStarted = true;
return isStarted;
}

// 开启流程服务引擎
public static ProcessEngine buildProcessEngine()
{
if (Para.pe == null)
{
if (processEngineConfiguration != null)
{
Para.pe = processEngineConfiguration.buildProcessEngine();
}
}
return Para.pe;
}

public ActivitiPlugins( String dbSchema, String dbType, String labelFontName)
{
this.dbSchema = dbSchema;
this.dbType = dbType;
if (labelFontName != null) this.labelFontName = labelFontName;
}

public String getDbSchema()
{
return dbSchema;
}

public void setDbSchema(String dbSchema)
{
this.dbSchema = dbSchema;
}

public String getDbType()
{
return dbType;
}

public void setDbType(String dbType)
{
this.dbType = dbType;
}
}

aarreess

2017-05-19 11:40

import java.sql.Connection;
import java.util.Properties;

import javax.sql.DataSource;

import org.apache.ibatis.session.TransactionIsolationLevel;
import org.apache.ibatis.transaction.Transaction;
import org.apache.ibatis.transaction.TransactionFactory;

public class ActivitiTransactionFactory implements TransactionFactory
{

@Override
public void setProperties(Properties props)
{
}

@Override
public Transaction newTransaction(Connection conn)
{
return new ActivitiTransaction(conn);
}

@Override
public Transaction newTransaction(DataSource ds, TransactionIsolationLevel level, boolean autoCommit)
{
return new ActivitiTransaction(ds, level, autoCommit);
}
}

aarreess

2017-05-19 11:42

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.apache.ibatis.session.TransactionIsolationLevel;
import org.apache.ibatis.transaction.Transaction;

import com.jfinal.plugin.activerecord.DbKit;
import com.zcqm.util.Para;

public class ActivitiTransaction implements Transaction {

protected Connection connection;
protected DataSource dataSource;
protected TransactionIsolationLevel level;
protected boolean autoCommmit;

public ActivitiTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit) {
dataSource = ds;
level = desiredLevel;
autoCommmit = desiredAutoCommit;
}

public ActivitiTransaction(Connection connection) {
this.connection = connection;
}

@Override
public Connection getConnection() throws SQLException {
if (connection == null) {
openConnection();
}
return connection;
}

@Override
public void commit() throws SQLException {
}

@Override
public void rollback() throws SQLException {
}

@Override
public void close() throws SQLException {
if(connection!=null){
DbKit.getConfig(Para.defaultDbName).close(connection);
}
}

protected void openConnection() throws SQLException {
connection = DbKit.getConfig(Para.defaultDbName).getConnection();
if (level != null) {
connection.setTransactionIsolation(level.getLevel());
}
}


public Integer getTimeout() throws SQLException
{
// TODO Auto-generated method stub
return null;
}


}

热门反馈

扫码入社