/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.flowable.engine.common.impl;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import org.apache.ibatis.builder.xml.XMLConfigBuilder;
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.defaults.DefaultSqlSessionFactory;
import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
import org.flowable.engine.common.api.FlowableException;
import org.flowable.engine.common.api.delegate.event.FlowableEventDispatcher;
import org.flowable.engine.common.api.delegate.event.FlowableEventListener;
import org.flowable.engine.common.impl.cfg.CommandExecutorImpl;
import org.flowable.engine.common.impl.cfg.IdGenerator;
import org.flowable.engine.common.impl.cfg.TransactionContextFactory;
import org.flowable.engine.common.impl.cfg.standalone.StandaloneMybatisTransactionContextFactory;
import org.flowable.engine.common.impl.db.CommonDbSchemaManager;
import org.flowable.engine.common.impl.db.DbSchemaManager;
import org.flowable.engine.common.impl.db.DbSqlSessionFactory;
import org.flowable.engine.common.impl.db.LogSqlExecutionTimePlugin;
import org.flowable.engine.common.impl.db.MybatisTypeAliasConfigurator;
import org.flowable.engine.common.impl.db.MybatisTypeHandlerConfigurator;
import org.flowable.engine.common.impl.event.EventDispatchAction;
import org.flowable.engine.common.impl.interceptor.CommandConfig;
import org.flowable.engine.common.impl.interceptor.CommandContextFactory;
import org.flowable.engine.common.impl.interceptor.CommandContextInterceptor;
import org.flowable.engine.common.impl.interceptor.CommandExecutor;
import org.flowable.engine.common.impl.interceptor.CommandInterceptor;
import org.flowable.engine.common.impl.interceptor.DefaultCommandInvoker;
import org.flowable.engine.common.impl.interceptor.LogInterceptor;
import org.flowable.engine.common.impl.interceptor.SessionFactory;
import org.flowable.engine.common.impl.interceptor.TransactionContextInterceptor;
import org.flowable.engine.common.impl.persistence.StrongUuidGenerator;
import org.flowable.engine.common.impl.persistence.entity.Entity;
import org.flowable.engine.common.impl.runtime.Clock;
import org.flowable.engine.common.impl.util.DefaultClockImpl;
import org.flowable.engine.common.impl.util.IoUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class AbstractEngineConfiguration {
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractEngineConfiguration.class);
/** The tenant id indicating 'no tenant' */
public static final String NO_TENANT_ID = "";
/**
* Checks the version of the DB schema against the library when the form engine is being created and throws an exception if the versions don't match.
*/
public static final String DB_SCHEMA_UPDATE_FALSE = "false";
public static final String DB_SCHEMA_UPDATE_CREATE = "create";
public static final String DB_SCHEMA_UPDATE_CREATE_DROP = "create-drop";
/**
* Creates the schema when the form engine is being created and drops the schema when the form engine is being closed.
*/
public static final String DB_SCHEMA_UPDATE_DROP_CREATE = "drop-create";
/**
* Upon building of the process engine, a check is performed and an update of the schema is performed if it is necessary.
*/
public static final String DB_SCHEMA_UPDATE_TRUE = "true";
protected String databaseType;
protected String jdbcDriver = "org.h2.Driver";
protected String jdbcUrl = "jdbc:h2:tcp://localhost/~/flowable";
protected String jdbcUsername = "sa";
protected String jdbcPassword = "";
protected String dataSourceJndiName;
protected int jdbcMaxActiveConnections;
protected int jdbcMaxIdleConnections;
protected int jdbcMaxCheckoutTime;
protected int jdbcMaxWaitTime;
protected boolean jdbcPingEnabled;
protected String jdbcPingQuery;
protected int jdbcPingConnectionNotUsedFor;
protected int jdbcDefaultTransactionIsolationLevel;
protected DataSource dataSource;
protected DbSchemaManager commonDbSchemaManager;
protected DbSchemaManager dbSchemaManager;
protected String databaseSchemaUpdate = DB_SCHEMA_UPDATE_FALSE;
protected String xmlEncoding = "UTF-8";
// COMMAND EXECUTORS ///////////////////////////////////////////////
protected CommandExecutor commandExecutor;
protected Collection<? extends CommandInterceptor> defaultCommandInterceptors;
protected CommandConfig defaultCommandConfig;
protected CommandConfig schemaCommandConfig;
protected CommandContextFactory commandContextFactory;
protected CommandInterceptor commandInvoker;
protected List<CommandInterceptor> customPreCommandInterceptors;
protected List<CommandInterceptor> customPostCommandInterceptors;
protected List<CommandInterceptor> commandInterceptors;
protected Map<String, AbstractEngineConfiguration> engineConfigurations = new HashMap<>();
protected Map<String, AbstractServiceConfiguration> serviceConfigurations = new HashMap<>();
protected ClassLoader classLoader;
/**
* Either use Class.forName or ClassLoader.loadClass for class loading. See http://forums.activiti.org/content/reflectutilloadclass-and-custom- classloader
*/
protected boolean useClassForNameClassLoading = true;
// MYBATIS SQL SESSION FACTORY /////////////////////////////////////
protected boolean isDbHistoryUsed = true;
protected DbSqlSessionFactory dbSqlSessionFactory;
protected SqlSessionFactory sqlSessionFactory;
protected TransactionFactory transactionFactory;
protected TransactionContextFactory transactionContextFactory;
/**
* If set to true, enables bulk insert (grouping sql inserts together). Default true.
* For some databases (eg DB2+z/OS) needs to be set to false.
*/
protected boolean isBulkInsertEnabled = true;
/**
* Some databases have a limit of how many parameters one sql insert can have (eg SQL Server, 2000 params (!= insert statements) ). Tweak this parameter in case of exceptions indicating too much
* is being put into one bulk insert, or make it higher if your database can cope with it and there are inserts with a huge amount of data.
* <p>
* By default: 100 (75 for mssql server as it has a hard limit of 2000 parameters in a statement)
*/
protected int maxNrOfStatementsInBulkInsert = 100;
public int DEFAULT_MAX_NR_OF_STATEMENTS_BULK_INSERT_SQL_SERVER = 60; // currently Execution has most params (31). 2000 / 31 = 64.
protected
评论0