lyh
2026-01-29 e530a7943898221ba3a32731bf1cab154c3a1ab9
dm数据库
已添加5个文件
已修改4个文件
5693 ■■■■■ 文件已修改
db/imp_exp_20260129155243.dmp 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lxzn/framework/domain/activiti/response/ActivitiCode.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/activiti/engine/impl/AbstractQuery.java 212 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/activiti/engine/impl/cfg/ProcessEngineConfigurationImpl.java 3842 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/activiti/engine/impl/db/DbSqlSession.java 1274 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/activiti/engine/impl/db/DbSqlSessionFactory.java 301 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/logback-spring.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
db/imp_exp_20260129155243.dmp
Binary files differ
pom.xml
@@ -71,16 +71,22 @@
        <!--spring boot ç»“束-->
        <!--持久层 æ•°æ®åº“ è¿žæŽ¥æ±  å¼€å§‹-->
        <!--数据库连接在springboot中定义了,所以可以管理包的版本-->
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <scope>runtime</scope>
        </dependency>
<!--        <dependency>-->
<!--            <groupId>com.microsoft.sqlserver</groupId>-->
<!--            <artifactId>mssql-jdbc</artifactId>-->
<!--            <scope>runtime</scope>-->
<!--        </dependency>-->
        <!-- <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
             <version>${mysql-connector-java.version}</version>
         </dependency>-->
        <!--   è¾¾æ¢¦æ•°æ®åº“     -->
        <dependency>
            <groupId>com.dameng</groupId>
            <artifactId>DmJdbcDriver18</artifactId>
            <version>8.1.1.193</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
@@ -121,6 +127,23 @@
        </dependency>
        <!--swagger2 å¼€å§‹-->
        <!--   å›½äº§åŒ–使用开始   2.2版本的persistence-->
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>javax.persistence-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.6.7.Final</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-collections</groupId>
                    <artifactId>commons-collections</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--   å›½äº§åŒ–使用结束   2.2版本的persistence-->
        <!--activiti æµç¨‹å¼•擎-->
        <dependency>
            <groupId>org.activiti</groupId>
src/main/java/com/lxzn/framework/domain/activiti/response/ActivitiCode.java
@@ -23,7 +23,7 @@
    ACT_DOC_ID_NONE(false, 21014, "文档编号不存在!"),
    ACT_DOC_ERROR(false,21015,"启动流程失败,文档信息错误!"),
    ACT_DEVICE_DOC_ERROR(false,21016,"启动流程失败,设备已存在该文档!"),
    ACT_DEVICE_DOC_FILELABLE(false,21016,"密标系统异常,!");
    ACT_DEVICE_DOC_FILELABLE(false,21016,"密标系统异常!");
    //操作代码
    @ApiModelProperty(value = "操作是否成功", example = "true", required = true)
src/main/java/org/activiti/engine/impl/AbstractQuery.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,212 @@
package org.activiti.engine.impl;
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.ManagementService;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.db.ListQueryParameterObject;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.query.Query;
import org.activiti.engine.query.QueryProperty;
import java.io.Serializable;
import java.util.List;
public abstract class AbstractQuery<T extends Query<?, ?>, U> extends ListQueryParameterObject implements Command<Object>, Query<T, U>, Serializable {
    private static final long serialVersionUID = 1L;
    public static final String SORTORDER_ASC = "asc";
    public static final String SORTORDER_DESC = "desc";
    protected transient CommandExecutor commandExecutor;
    protected transient CommandContext commandContext;
    protected String databaseType;
    protected String orderBy;
    protected ResultType resultType;
    protected QueryProperty orderProperty;
    protected NullHandlingOnOrder nullHandlingOnOrder;
    protected AbstractQuery() {
        this.parameter = this;
    }
    protected AbstractQuery(CommandExecutor commandExecutor) {
        this.commandExecutor = commandExecutor;
    }
    public AbstractQuery(CommandContext commandContext) {
        this.commandContext = commandContext;
    }
    public AbstractQuery(ManagementService managementService) {
        this(((ManagementServiceImpl)managementService).getCommandExecutor());
    }
    public AbstractQuery<T, U> setCommandExecutor(CommandExecutor commandExecutor) {
        this.commandExecutor = commandExecutor;
        return this;
    }
    public T orderBy(QueryProperty property) {
        this.orderProperty = property;
        return (T) this;
    }
    public T orderBy(QueryProperty property, NullHandlingOnOrder nullHandlingOnOrder) {
        this.orderBy(property);
        this.nullHandlingOnOrder = nullHandlingOnOrder;
        return (T) this;
    }
    public T asc() {
        return this.direction(Direction.ASCENDING);
    }
    public T desc() {
        return this.direction(Direction.DESCENDING);
    }
    public T direction(Direction direction) {
        if (this.orderProperty == null) {
            throw new ActivitiIllegalArgumentException("You should call any of the orderBy methods first before specifying a direction");
        } else {
            this.addOrder(this.orderProperty.getName(), direction.getName(), this.nullHandlingOnOrder);
            this.orderProperty = null;
            this.nullHandlingOnOrder = null;
            return (T) this;
        }
    }
    protected void checkQueryOk() {
        if (this.orderProperty != null) {
            throw new ActivitiIllegalArgumentException("Invalid query: call asc() or desc() after using orderByXX()");
        }
    }
    public U singleResult() {
        this.resultType = ResultType.SINGLE_RESULT;
        return this.commandExecutor != null ? (U) this.commandExecutor.execute(this) : this.executeSingleResult(Context.getCommandContext());
    }
    public List<U> list() {
        this.resultType = ResultType.LIST;
        return this.commandExecutor != null ? (List)this.commandExecutor.execute(this) : this.executeList(Context.getCommandContext(), (Page)null);
    }
    public List<U> listPage(int firstResult, int maxResults) {
        this.firstResult = firstResult;
        this.maxResults = maxResults;
        this.resultType = ResultType.LIST_PAGE;
        return this.commandExecutor != null ? (List)this.commandExecutor.execute(this) : this.executeList(Context.getCommandContext(), new Page(firstResult, maxResults));
    }
    public long count() {
        this.resultType = ResultType.COUNT;
        return this.commandExecutor != null ? (Long)this.commandExecutor.execute(this) : this.executeCount(Context.getCommandContext());
    }
    public Object execute(CommandContext commandContext) {
        if (this.resultType == ResultType.LIST) {
            return this.executeList(commandContext, (Page)null);
        } else if (this.resultType == ResultType.SINGLE_RESULT) {
            return this.executeSingleResult(commandContext);
        } else {
            return this.resultType == ResultType.LIST_PAGE ? this.executeList(commandContext, (Page)null) : this.executeCount(commandContext);
        }
    }
    public abstract long executeCount(CommandContext var1);
    public abstract List<U> executeList(CommandContext var1, Page var2);
    public U executeSingleResult(CommandContext commandContext) {
        List<U> results = this.executeList(commandContext, (Page)null);
        if (results.size() == 1) {
            return results.get(0);
        } else if (results.size() > 1) {
            throw new ActivitiException("Query return " + results.size() + " results instead of max 1");
        } else {
            return null;
        }
    }
    protected void addOrder(String column, String sortOrder, NullHandlingOnOrder nullHandlingOnOrder) {
        if (this.orderBy == null) {
            this.orderBy = "";
        } else {
            this.orderBy = this.orderBy + ", ";
        }
        String defaultOrderByClause = column + " " + sortOrder;
        if (nullHandlingOnOrder != null) {
            if (nullHandlingOnOrder.equals(NullHandlingOnOrder.NULLS_FIRST)) {
                if (!"h2".equals(this.databaseType) && !"hsql".equals(this.databaseType) && !"postgres".equals(this.databaseType) && !"oracle".equals(this.databaseType)) {
                    if ("mysql".equals(this.databaseType)) {
                        this.orderBy = this.orderBy + "isnull(" + column + ") desc," + defaultOrderByClause;
                    } else if (!"db2".equals(this.databaseType) && !"mssql".equals(this.databaseType)) {
                        this.orderBy = this.orderBy + defaultOrderByClause;
                    } else {
                        this.orderBy = this.orderBy + "case when " + column + " is null then 0 else 1 end," + defaultOrderByClause;
                    }
                } else {
                    this.orderBy = this.orderBy + defaultOrderByClause + " NULLS FIRST";
                }
            } else if (nullHandlingOnOrder.equals(NullHandlingOnOrder.NULLS_LAST)) {
                if (!"h2".equals(this.databaseType) && !"hsql".equals(this.databaseType) && !"postgres".equals(this.databaseType) && !"oracle".equals(this.databaseType)) {
                    if ("mysql".equals(this.databaseType)) {
                        this.orderBy = this.orderBy + "isnull(" + column + ") asc," + defaultOrderByClause;
                    } else if (!"db2".equals(this.databaseType) && !"mssql".equals(this.databaseType)) {
                        this.orderBy = this.orderBy + defaultOrderByClause;
                    } else {
                        this.orderBy = this.orderBy + "case when " + column + " is null then 1 else 0 end," + defaultOrderByClause;
                    }
                } else {
                    this.orderBy = this.orderBy + column + " " + sortOrder + " NULLS LAST";
                }
            }
        } else {
            this.orderBy = this.orderBy + defaultOrderByClause;
        }
    }
    public String getOrderBy() {
        return this.orderBy == null ? super.getOrderBy() : this.orderBy;
    }
    public String getOrderByColumns() {
        return this.getOrderBy();
    }
    public String getDatabaseType() {
        return this.databaseType;
    }
    public void setDatabaseType(String databaseType) {
        this.databaseType = databaseType;
    }
    public static enum NullHandlingOnOrder {
        NULLS_FIRST,
        NULLS_LAST;
        private NullHandlingOnOrder() {
        }
    }
    private static enum ResultType {
        LIST,
        LIST_PAGE,
        SINGLE_RESULT,
        COUNT;
        private ResultType() {
        }
    }
}
src/main/java/org/activiti/engine/impl/cfg/ProcessEngineConfigurationImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,3842 @@
/* 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.activiti.engine.impl.cfg;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.activiti.dmn.api.DmnRepositoryService;
import org.activiti.dmn.api.DmnRuleService;
import org.activiti.engine.*;
import org.activiti.engine.cfg.ProcessEngineConfigurator;
import org.activiti.engine.compatibility.Activiti5CompatibilityHandler;
import org.activiti.engine.compatibility.Activiti5CompatibilityHandlerFactory;
import org.activiti.engine.compatibility.DefaultActiviti5CompatibilityHandlerFactory;
import org.activiti.engine.delegate.event.ActivitiEventDispatcher;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.activiti.engine.delegate.event.ActivitiEventType;
import org.activiti.engine.delegate.event.impl.ActivitiEventDispatcherImpl;
import org.activiti.engine.form.AbstractFormType;
import org.activiti.engine.impl.*;
import org.activiti.engine.impl.agenda.DefaultActivitiEngineAgendaFactory;
import org.activiti.engine.impl.asyncexecutor.*;
import org.activiti.engine.impl.bpmn.data.ItemInstance;
import org.activiti.engine.impl.bpmn.deployer.*;
import org.activiti.engine.impl.bpmn.listener.ListenerNotificationHelper;
import org.activiti.engine.impl.bpmn.parser.BpmnParseHandlers;
import org.activiti.engine.impl.bpmn.parser.BpmnParser;
import org.activiti.engine.impl.bpmn.parser.factory.*;
import org.activiti.engine.impl.bpmn.parser.handler.*;
import org.activiti.engine.impl.bpmn.webservice.MessageInstance;
import org.activiti.engine.impl.calendar.*;
import org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContextFactory;
import org.activiti.engine.impl.cmd.ValidateExecutionRelatedEntityCountCfgCmd;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.db.DbIdGenerator;
import org.activiti.engine.impl.db.DbSqlSessionFactory;
import org.activiti.engine.impl.db.IbatisVariableTypeHandler;
import org.activiti.engine.impl.delegate.invocation.DefaultDelegateInterceptor;
import org.activiti.engine.impl.el.ExpressionManager;
import org.activiti.engine.impl.event.CompensationEventHandler;
import org.activiti.engine.impl.event.EventHandler;
import org.activiti.engine.impl.event.MessageEventHandler;
import org.activiti.engine.impl.event.SignalEventHandler;
import org.activiti.engine.impl.event.logger.EventLogger;
import org.activiti.engine.impl.form.*;
import org.activiti.engine.impl.history.DefaultHistoryManager;
import org.activiti.engine.impl.history.HistoryLevel;
import org.activiti.engine.impl.history.HistoryManager;
import org.activiti.engine.impl.interceptor.*;
import org.activiti.engine.impl.jobexecutor.*;
import org.activiti.engine.impl.persistence.GenericManagerFactory;
import org.activiti.engine.impl.persistence.cache.EntityCache;
import org.activiti.engine.impl.persistence.cache.EntityCacheImpl;
import org.activiti.engine.impl.persistence.deploy.*;
import org.activiti.engine.impl.persistence.entity.*;
import org.activiti.engine.impl.persistence.entity.data.*;
import org.activiti.engine.impl.persistence.entity.data.impl.*;
import org.activiti.engine.impl.scripting.*;
import org.activiti.engine.impl.util.DefaultClockImpl;
import org.activiti.engine.impl.util.IoUtil;
import org.activiti.engine.impl.util.ProcessInstanceHelper;
import org.activiti.engine.impl.util.ReflectUtil;
import org.activiti.engine.impl.variable.*;
import org.activiti.engine.parse.BpmnParseHandler;
import org.activiti.engine.runtime.Clock;
import org.activiti.form.api.FormRepositoryService;
import org.activiti.image.impl.DefaultProcessDiagramGenerator;
import org.activiti.validation.ProcessValidator;
import org.activiti.validation.ProcessValidatorFactory;
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.apache.ibatis.type.JdbcType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import javax.xml.namespace.QName;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
 * @author Tom Baeyens
 * @author Joram Barrez
 */
public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfiguration {
    private static Logger log = LoggerFactory.getLogger(ProcessEngineConfigurationImpl.class);
    public static final String DB_SCHEMA_UPDATE_CREATE = "create";
    public static final String DB_SCHEMA_UPDATE_DROP_CREATE = "drop-create";
    public static final String DEFAULT_WS_SYNC_FACTORY = "org.activiti.engine.impl.webservice.CxfWebServiceClientFactory";
    public static final String DEFAULT_MYBATIS_MAPPING_FILE = "org/activiti/db/mapping/mappings.xml";
    public static final int DEFAULT_GENERIC_MAX_LENGTH_STRING= 4000;
    public static final int DEFAULT_ORACLE_MAX_LENGTH_STRING= 2000;
    // SERVICES /////////////////////////////////////////////////////////////////
    protected RepositoryService repositoryService = new RepositoryServiceImpl();
    protected RuntimeService runtimeService = new RuntimeServiceImpl();
    protected HistoryService historyService = new HistoryServiceImpl(this);
    protected IdentityService identityService = new IdentityServiceImpl();
    protected TaskService taskService = new TaskServiceImpl(this);
    protected FormService formService = new FormServiceImpl();
    protected ManagementService managementService = new ManagementServiceImpl();
    protected DynamicBpmnService dynamicBpmnService = new DynamicBpmnServiceImpl(this);
    // FORM ENGINE SERVICES /////////////////////////////////////////////////////
    protected boolean formEngineInitialized;
    protected FormRepositoryService formEngineRepositoryService;
    protected org.activiti.form.api.FormService formEngineFormService;
    // FORM ENGINE SERVICES /////////////////////////////////////////////////////
    protected boolean dmnEngineInitialized;
    protected DmnRepositoryService dmnEngineRepositoryService;
    protected DmnRuleService dmnEngineRuleService;
    // COMMAND EXECUTORS ////////////////////////////////////////////////////////
    protected CommandConfig defaultCommandConfig;
    protected CommandConfig schemaCommandConfig;
    protected CommandInterceptor commandInvoker;
    /**
     * the configurable list which will be {@link #initInterceptorChain(java.util.List) processed} to build the {@link #commandExecutor}
     */
    protected List<CommandInterceptor> customPreCommandInterceptors;
    protected List<CommandInterceptor> customPostCommandInterceptors;
    protected List<CommandInterceptor> commandInterceptors;
    /** this will be initialized during the configurationComplete() */
    protected CommandExecutor commandExecutor;
    // DATA MANAGERS /////////////////////////////////////////////////////////////
    protected AttachmentDataManager attachmentDataManager;
    protected ByteArrayDataManager byteArrayDataManager;
    protected CommentDataManager commentDataManager;
    protected DeploymentDataManager deploymentDataManager;
    protected EventLogEntryDataManager eventLogEntryDataManager;
    protected EventSubscriptionDataManager eventSubscriptionDataManager;
    protected ExecutionDataManager executionDataManager;
    protected GroupDataManager groupDataManager;
    protected HistoricActivityInstanceDataManager historicActivityInstanceDataManager;
    protected HistoricDetailDataManager historicDetailDataManager;
    protected HistoricIdentityLinkDataManager historicIdentityLinkDataManager;
    protected HistoricProcessInstanceDataManager historicProcessInstanceDataManager;
    protected HistoricTaskInstanceDataManager historicTaskInstanceDataManager;
    protected HistoricVariableInstanceDataManager historicVariableInstanceDataManager;
    protected IdentityInfoDataManager identityInfoDataManager;
    protected IdentityLinkDataManager identityLinkDataManager;
    protected JobDataManager jobDataManager;
    protected TimerJobDataManager timerJobDataManager;
    protected SuspendedJobDataManager suspendedJobDataManager;
    protected DeadLetterJobDataManager deadLetterJobDataManager;
    protected MembershipDataManager membershipDataManager;
    protected ModelDataManager modelDataManager;
    protected ProcessDefinitionDataManager processDefinitionDataManager;
    protected ProcessDefinitionInfoDataManager processDefinitionInfoDataManager;
    protected PropertyDataManager propertyDataManager;
    protected ResourceDataManager resourceDataManager;
    protected TaskDataManager taskDataManager;
    protected UserDataManager userDataManager;
    protected VariableInstanceDataManager variableInstanceDataManager;
    // ENTITY MANAGERS ///////////////////////////////////////////////////////////
    protected AttachmentEntityManager attachmentEntityManager;
    protected ByteArrayEntityManager byteArrayEntityManager;
    protected CommentEntityManager commentEntityManager;
    protected DeploymentEntityManager deploymentEntityManager;
    protected EventLogEntryEntityManager eventLogEntryEntityManager;
    protected EventSubscriptionEntityManager eventSubscriptionEntityManager;
    protected ExecutionEntityManager executionEntityManager;
    protected GroupEntityManager groupEntityManager;
    protected HistoricActivityInstanceEntityManager historicActivityInstanceEntityManager;
    protected HistoricDetailEntityManager historicDetailEntityManager;
    protected HistoricIdentityLinkEntityManager historicIdentityLinkEntityManager;
    protected HistoricProcessInstanceEntityManager historicProcessInstanceEntityManager;
    protected HistoricTaskInstanceEntityManager historicTaskInstanceEntityManager;
    protected HistoricVariableInstanceEntityManager historicVariableInstanceEntityManager;
    protected IdentityInfoEntityManager identityInfoEntityManager;
    protected IdentityLinkEntityManager identityLinkEntityManager;
    protected JobEntityManager jobEntityManager;
    protected TimerJobEntityManager timerJobEntityManager;
    protected SuspendedJobEntityManager suspendedJobEntityManager;
    protected DeadLetterJobEntityManager deadLetterJobEntityManager;
    protected MembershipEntityManager membershipEntityManager;
    protected ModelEntityManager modelEntityManager;
    protected ProcessDefinitionEntityManager processDefinitionEntityManager;
    protected ProcessDefinitionInfoEntityManager processDefinitionInfoEntityManager;
    protected PropertyEntityManager propertyEntityManager;
    protected ResourceEntityManager resourceEntityManager;
    protected TableDataManager tableDataManager;
    protected TaskEntityManager taskEntityManager;
    protected UserEntityManager userEntityManager;
    protected VariableInstanceEntityManager variableInstanceEntityManager;
    // History Manager
    protected HistoryManager historyManager;
    // Job Manager
    protected JobManager jobManager;
    // SESSION FACTORIES /////////////////////////////////////////////////////////
    protected List<SessionFactory> customSessionFactories;
    protected DbSqlSessionFactory dbSqlSessionFactory;
    protected Map<Class<?>, SessionFactory> sessionFactories;
    // CONFIGURATORS ////////////////////////////////////////////////////////////
    protected boolean enableConfiguratorServiceLoader = true; // Enabled by default. In certain environments this should be set to false (eg osgi)
    protected List<ProcessEngineConfigurator> configurators; // The injected configurators
    protected List<ProcessEngineConfigurator> allConfigurators; // Including auto-discovered configurators
    // DEPLOYERS //////////////////////////////////////////////////////////////////
    protected BpmnDeployer bpmnDeployer;
    protected BpmnParser bpmnParser;
    protected ParsedDeploymentBuilderFactory parsedDeploymentBuilderFactory;
    protected TimerManager timerManager;
    protected EventSubscriptionManager eventSubscriptionManager;
    protected BpmnDeploymentHelper bpmnDeploymentHelper;
    protected CachingAndArtifactsManager cachingAndArtifactsManager;
    protected ProcessDefinitionDiagramHelper processDefinitionDiagramHelper;
    protected List<Deployer> customPreDeployers;
    protected List<Deployer> customPostDeployers;
    protected List<Deployer> deployers;
    protected DeploymentManager deploymentManager;
    protected int processDefinitionCacheLimit = -1; // By default, no limit
    protected DeploymentCache<ProcessDefinitionCacheEntry> processDefinitionCache;
    protected int processDefinitionInfoCacheLimit = -1; // By default, no limit
    protected ProcessDefinitionInfoCache processDefinitionInfoCache;
    protected int knowledgeBaseCacheLimit = -1;
    protected DeploymentCache<Object> knowledgeBaseCache;
    // JOB EXECUTOR /////////////////////////////////////////////////////////////
    protected List<JobHandler> customJobHandlers;
    protected Map<String, JobHandler> jobHandlers;
    // HELPERS //////////////////////////////////////////////////////////////////
    protected ProcessInstanceHelper processInstanceHelper;
    protected ListenerNotificationHelper listenerNotificationHelper;
    // ASYNC EXECUTOR ///////////////////////////////////////////////////////////
    /**
     * The number of retries for a job.
     */
    protected int asyncExecutorNumberOfRetries = 3;
    /**
     * The minimal number of threads that are kept alive in the threadpool for job
     * execution. Default value = 2. (This property is only applicable when using
     * the {@link DefaultAsyncJobExecutor}).
     */
    protected int asyncExecutorCorePoolSize = 2;
    /**
     * The maximum number of threads that are created in the threadpool for job
     * execution. Default value = 10. (This property is only applicable when using
     * the {@link DefaultAsyncJobExecutor}).
     */
    protected int asyncExecutorMaxPoolSize = 10;
    /**
     * The time (in milliseconds) a thread used for job execution must be kept
     * alive before it is destroyed. Default setting is 5 seconds. Having a
     * setting > 0 takes resources, but in the case of many job executions it
     * avoids creating new threads all the time. If 0, threads will be destroyed
     * after they've been used for job execution.
     *
     * (This property is only applicable when using the
     * {@link DefaultAsyncJobExecutor}).
     */
    protected long asyncExecutorThreadKeepAliveTime = 5000L;
    /**
     * The size of the queue on which jobs to be executed are placed, before they
     * are actually executed. Default value = 100. (This property is only
     * applicable when using the {@link DefaultAsyncJobExecutor}).
     */
    protected int asyncExecutorThreadPoolQueueSize = 100;
    /**
     * The queue onto which jobs will be placed before they are actually executed.
     * Threads form the async executor threadpool will take work from this queue.
     *
     * By default null. If null, an {@link ArrayBlockingQueue} will be created of
     * size {@link #asyncExecutorThreadPoolQueueSize}.
     *
     * When the queue is full, the job will be executed by the calling thread
     * (ThreadPoolExecutor.CallerRunsPolicy())
     *
     * (This property is only applicable when using the
     * {@link DefaultAsyncJobExecutor}).
     */
    protected BlockingQueue<Runnable> asyncExecutorThreadPoolQueue;
    /**
     * The time (in seconds) that is waited to gracefully shut down the threadpool
     * used for job execution when the a shutdown on the executor (or process
     * engine) is requested. Default value = 60.
     *
     * (This property is only applicable when using the
     * {@link DefaultAsyncJobExecutor}).
     */
    protected long asyncExecutorSecondsToWaitOnShutdown = 60L;
    /**
     * The number of timer jobs that are acquired during one query (before a job
     * is executed, an acquirement thread fetches jobs from the database and puts
     * them on the queue).
     *
     * Default value = 1, as this lowers the potential on optimistic locking
     * exceptions. Change this value if you know what you are doing.
     *
     * (This property is only applicable when using the
     * {@link DefaultAsyncJobExecutor}).
     */
    protected int asyncExecutorMaxTimerJobsPerAcquisition = 1;
    /**
     * The number of async jobs that are acquired during one query (before a job
     * is executed, an acquirement thread fetches jobs from the database and puts
     * them on the queue).
     *
     * Default value = 1, as this lowers the potential on optimistic locking
     * exceptions. Change this value if you know what you are doing.
     *
     * (This property is only applicable when using the
     * {@link DefaultAsyncJobExecutor}).
     */
    protected int asyncExecutorMaxAsyncJobsDuePerAcquisition = 1;
    /**
     * The time (in milliseconds) the timer acquisition thread will wait to
     * execute the next acquirement query. This happens when no new timer jobs
     * were found or when less timer jobs have been fetched than set in
     * {@link #asyncExecutorMaxTimerJobsPerAcquisition}. Default value = 10
     * seconds.
     *
     * (This property is only applicable when using the
     * {@link DefaultAsyncJobExecutor}).
     */
    protected int asyncExecutorDefaultTimerJobAcquireWaitTime = 10 * 1000;
    /**
     * The time (in milliseconds) the async job acquisition thread will wait to
     * execute the next acquirement query. This happens when no new async jobs
     * were found or when less async jobs have been fetched than set in
     * {@link #asyncExecutorMaxAsyncJobsDuePerAcquisition}. Default value = 10
     * seconds.
     *
     * (This property is only applicable when using the
     * {@link DefaultAsyncJobExecutor}).
     */
    protected int asyncExecutorDefaultAsyncJobAcquireWaitTime = 10 * 1000;
    /**
     * The time (in milliseconds) the async job (both timer and async continuations) acquisition thread will
     * wait when the queueu is full to execute the next query. By default set to 0 (for backwards compatibility)
     */
    protected int asyncExecutorDefaultQueueSizeFullWaitTime = 0;
    /**
     * When a job is acquired, it is locked so other async executors can't lock
     * and execute it. While doing this, the 'name' of the lock owner is written
     * into a column of the job.
     *
     * By default, a random UUID will be generated when the executor is created.
     *
     * It is important that each async executor instance in a cluster of Activiti
     * engines has a different name!
     *
     * (This property is only applicable when using the
     * {@link DefaultAsyncJobExecutor}).
     */
    protected String asyncExecutorLockOwner;
    /**
     * The amount of time (in milliseconds) a timer job is locked when acquired by
     * the async executor. During this period of time, no other async executor
     * will try to acquire and lock this job.
     *
     * Default value = 5 minutes;
     *
     * (This property is only applicable when using the
     * {@link DefaultAsyncJobExecutor}).
     */
    protected int asyncExecutorTimerLockTimeInMillis = 5 * 60 * 1000;
    /**
     * The amount of time (in milliseconds) an async job is locked when acquired
     * by the async executor. During this period of time, no other async executor
     * will try to acquire and lock this job.
     *
     * Default value = 5 minutes;
     *
     * (This property is only applicable when using the
     * {@link DefaultAsyncJobExecutor}).
     */
    protected int asyncExecutorAsyncJobLockTimeInMillis = 5 * 60 * 1000;
    /**
     * The amount of time (in milliseconds) that is between two consecutive checks
     * of 'expired jobs'. Expired jobs are jobs that were locked (a lock owner + time
     * was written by some executor, but the job was never completed).
     *
     * During such a check, jobs that are expired are again made available,
     * meaning the lock owner and lock time will be removed. Other executors
     * will now be able to pick it up.
     *
     * A job is deemed expired if the lock time is before the current date.
     *
     * By default one minute.
     */
    protected int asyncExecutorResetExpiredJobsInterval = 60 * 1000;
    /**
     * The {@link AsyncExecutor} has a 'cleanup' thread that resets expired jobs
     * so they can be re-acquired by other executors. This setting defines the size
     * of the page being used when fetching these expired jobs.
     */
    protected int asyncExecutorResetExpiredJobsPageSize = 3;
    /**
     * Experimental!
     *
     * Set this to true when using the message queue based job executor.
     */
    protected boolean asyncExecutorMessageQueueMode;
    /**
     * Allows to define a custom factory for creating the {@link Runnable} that is executed by the async executor.
     *
     * (This property is only applicable when using the {@link DefaultAsyncJobExecutor}).
     */
    protected ExecuteAsyncRunnableFactory asyncExecutorExecuteAsyncRunnableFactory;
    // MYBATIS SQL SESSION FACTORY //////////////////////////////////////////////
    protected SqlSessionFactory sqlSessionFactory;
    protected TransactionFactory transactionFactory;
    protected Set<Class<?>> customMybatisMappers;
    protected Set<String> customMybatisXMLMappers;
    // ID GENERATOR ///////////////////////////////////////////////////////////////
    protected IdGenerator idGenerator;
    protected DataSource idGeneratorDataSource;
    protected String idGeneratorDataSourceJndiName;
    // BPMN PARSER //////////////////////////////////////////////////////////////
    protected List<BpmnParseHandler> preBpmnParseHandlers;
    protected List<BpmnParseHandler> postBpmnParseHandlers;
    protected List<BpmnParseHandler> customDefaultBpmnParseHandlers;
    protected ActivityBehaviorFactory activityBehaviorFactory;
    protected ListenerFactory listenerFactory;
    protected BpmnParseFactory bpmnParseFactory;
    // PROCESS VALIDATION //////////////////////////////////////////////////////////////
    protected ProcessValidator processValidator;
    // OTHER //////////////////////////////////////////////////////////////////////
    protected List<FormEngine> customFormEngines;
    protected Map<String, FormEngine> formEngines;
    protected List<AbstractFormType> customFormTypes;
    protected FormTypes formTypes;
    protected List<VariableType> customPreVariableTypes;
    protected List<VariableType> customPostVariableTypes;
    protected VariableTypes variableTypes;
    /**
     * This flag determines whether variables of the type 'serializable' will be tracked.
     * This means that, when true, in a JavaDelegate you can write
     *
     * MySerializableVariable myVariable = (MySerializableVariable) execution.getVariable("myVariable");
     * myVariable.setNumber(123);
     *
     * And the changes to the java object will be reflected in the database.
     * Otherwise, a manual call to setVariable will be needed.
     *
     * By default true for backwards compatibility.
     */
    protected boolean serializableVariableTypeTrackDeserializedObjects = true;
    protected ExpressionManager expressionManager;
    protected List<String> customScriptingEngineClasses;
    protected ScriptingEngines scriptingEngines;
    protected List<ResolverFactory> resolverFactories;
    protected BusinessCalendarManager businessCalendarManager;
    protected int executionQueryLimit = 20000;
    protected int taskQueryLimit = 20000;
    protected int historicTaskQueryLimit = 20000;
    protected int historicProcessInstancesQueryLimit = 20000;
    protected String wsSyncFactoryClassName = DEFAULT_WS_SYNC_FACTORY;
    protected ConcurrentMap<QName, URL> wsOverridenEndpointAddresses = new ConcurrentHashMap<QName, URL>();
    protected CommandContextFactory commandContextFactory;
    protected TransactionContextFactory transactionContextFactory;
    protected Map<Object, Object> beans;
    protected DelegateInterceptor delegateInterceptor;
    protected Map<String, EventHandler> eventHandlers;
    protected List<EventHandler> customEventHandlers;
    protected FailedJobCommandFactory failedJobCommandFactory;
    /**
     * Set this to true if you want to have extra checks on the BPMN xml that is parsed.
     *
     * Unfortunately, this feature is not available on some platforms (JDK 6, JBoss), hence the reason why it is disabled by default. If your platform allows the use of StaxSource during XML parsing, do
     * enable it.
     */
    protected boolean enableSafeBpmnXml;
    /**
     * The following settings will determine the amount of entities loaded at once when the engine needs to load multiple entities (eg. when suspending a process definition with all its process
     * instances).
     *
     * The default setting is quite low, as not to surprise anyone with sudden memory spikes. Change it to something higher if the environment Activiti runs in allows it.
     */
    protected int batchSizeProcessInstances = 25;
    protected int batchSizeTasks = 25;
    protected boolean enableEventDispatcher = true;
    protected ActivitiEventDispatcher eventDispatcher;
    protected List<ActivitiEventListener> eventListeners;
    protected Map<String, List<ActivitiEventListener>> typedEventListeners;
    // Event logging to database
    protected boolean enableDatabaseEventLogging;
    /**
     * Using field injection together with a delegate expression for a service
     * task / execution listener / task listener is not thread-sade , see user
     * guide section 'Field Injection' for more information.
     *
     * Set this flag to false to throw an exception at runtime when a field is
     * injected and a delegateExpression is used.
     *
     * @since 5.21
     */
    protected DelegateExpressionFieldInjectionMode delegateExpressionFieldInjectionMode = DelegateExpressionFieldInjectionMode.MIXED;
    /**
     *  Define a max length for storing String variable types in the database.
     *  Mainly used for the Oracle NVARCHAR2 limit of 2000 characters
     */
    protected int maxLengthStringVariableType = -1;
    /**
     * If set to true, enables bulk insert (grouping sql inserts together).
     * Default true. For some databases (eg DB2 on Zos: https://activiti.atlassian.net/browse/ACT-4042) 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.
     *
     * 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 = 70; // currently Execution has most params (28). 2000 / 28 = 71.
    protected ObjectMapper objectMapper = new ObjectMapper();
    /**
     * Flag that can be set to configure or nota relational database is used.
     * This is useful for custom implementations that do not use relational databases at all.
     *
     * If true (default), the {@link ProcessEngineConfiguration#getDatabaseSchemaUpdate()} value will be used to determine
     * what needs to happen wrt the database schema.
     *
     * If false, no validation or schema creation will be done. That means that the database schema must have been
     * created 'manually' before but the engine does not validate whether the schema is correct.
     * The {@link ProcessEngineConfiguration#getDatabaseSchemaUpdate()} value will not be used.
     */
    protected boolean usingRelationalDatabase = true;
    /**
     * Enabled a very verbose debug output of the execution tree whilst executing operations.
     * Most useful for core engine developers or people fiddling around with the execution tree.
     */
    protected boolean enableVerboseExecutionTreeLogging;
    protected PerformanceSettings performanceSettings = new PerformanceSettings();
    // Backwards compatibility //////////////////////////////////////////////////////////////
    protected boolean isActiviti5CompatibilityEnabled; // Default activiti 5 backwards compatibility is disabled!
    protected Activiti5CompatibilityHandlerFactory activiti5CompatibilityHandlerFactory;
    protected Activiti5CompatibilityHandler activiti5CompatibilityHandler;
    // Can't have a dependency on the activiti5-engine module
    protected Object activiti5ActivityBehaviorFactory;
    protected Object activiti5ListenerFactory;
    protected List<Object> activiti5PreBpmnParseHandlers;
    protected List<Object> activiti5PostBpmnParseHandlers;
    protected List<Object> activiti5CustomDefaultBpmnParseHandlers;
    protected Set<Class<?>> activiti5CustomMybatisMappers;
    protected Set<String> activiti5CustomMybatisXMLMappers;
    // buildProcessEngine
    // ///////////////////////////////////////////////////////
    @Override
    public ProcessEngine buildProcessEngine() {
        init();
        ProcessEngineImpl processEngine = new ProcessEngineImpl(this);
        // trigger build of Activiti 5 Engine
        if (isActiviti5CompatibilityEnabled && activiti5CompatibilityHandler != null) {
            Context.setProcessEngineConfiguration(processEngine.getProcessEngineConfiguration());
            activiti5CompatibilityHandler.getRawProcessEngine();
        }
        postProcessEngineInitialisation();
        return processEngine;
    }
    // init
    // /////////////////////////////////////////////////////////////////////
    public void init() {
        initConfigurators();
        configuratorsBeforeInit();
        initProcessDiagramGenerator();
        initHistoryLevel();
        initExpressionManager();
        if (usingRelationalDatabase) {
            initDataSource();
        }
        initAgendaFactory();
        initHelpers();
        initVariableTypes();
        initBeans();
        initFormEngines();
        initFormTypes();
        initScriptingEngines();
        initClock();
        initBusinessCalendarManager();
        initCommandContextFactory();
        initTransactionContextFactory();
        initCommandExecutors();
        initServices();
        initIdGenerator();
        initBehaviorFactory();
        initListenerFactory();
        initBpmnParser();
        initProcessDefinitionCache();
        initProcessDefinitionInfoCache();
        initKnowledgeBaseCache();
        initJobHandlers();
        initJobManager();
        initAsyncExecutor();
        initTransactionFactory();
        if (usingRelationalDatabase) {
            initSqlSessionFactory();
        }
        initSessionFactories();
        initDataManagers();
        initEntityManagers();
        initHistoryManager();
        initJpa();
        initDeployers();
        initDelegateInterceptor();
        initEventHandlers();
        initFailedJobCommandFactory();
        initEventDispatcher();
        initProcessValidator();
        initDatabaseEventLogging();
        initActiviti5CompatibilityHandler();
        configuratorsAfterInit();
    }
    // failedJobCommandFactory
    // ////////////////////////////////////////////////////////
    public void initFailedJobCommandFactory() {
        if (failedJobCommandFactory == null) {
            failedJobCommandFactory = new DefaultFailedJobCommandFactory();
        }
    }
    // command executors
    // ////////////////////////////////////////////////////////
    public void initCommandExecutors() {
        initDefaultCommandConfig();
        initSchemaCommandConfig();
        initCommandInvoker();
        initCommandInterceptors();
        initCommandExecutor();
    }
    public void initDefaultCommandConfig() {
        if (defaultCommandConfig == null) {
            defaultCommandConfig = new CommandConfig();
        }
    }
    public void initSchemaCommandConfig() {
        if (schemaCommandConfig == null) {
            schemaCommandConfig = new CommandConfig().transactionNotSupported();
        }
    }
    public void initCommandInvoker() {
        if (commandInvoker == null) {
            if (enableVerboseExecutionTreeLogging) {
                commandInvoker = new DebugCommandInvoker();
            } else {
                commandInvoker = new CommandInvoker();
            }
        }
    }
    public void initCommandInterceptors() {
        if (commandInterceptors == null) {
            commandInterceptors = new ArrayList<CommandInterceptor>();
            if (customPreCommandInterceptors != null) {
                commandInterceptors.addAll(customPreCommandInterceptors);
            }
            commandInterceptors.addAll(getDefaultCommandInterceptors());
            if (customPostCommandInterceptors != null) {
                commandInterceptors.addAll(customPostCommandInterceptors);
            }
            commandInterceptors.add(commandInvoker);
        }
    }
    public Collection<? extends CommandInterceptor> getDefaultCommandInterceptors() {
        List<CommandInterceptor> interceptors = new ArrayList<CommandInterceptor>();
        interceptors.add(new LogInterceptor());
        CommandInterceptor transactionInterceptor = createTransactionInterceptor();
        if (transactionInterceptor != null) {
            interceptors.add(transactionInterceptor);
        }
        if (commandContextFactory != null) {
            interceptors.add(new CommandContextInterceptor(commandContextFactory, this));
        }
        if (transactionContextFactory != null) {
            interceptors.add(new TransactionContextInterceptor(transactionContextFactory));
        }
        return interceptors;
    }
    public void initCommandExecutor() {
        if (commandExecutor == null) {
            CommandInterceptor first = initInterceptorChain(commandInterceptors);
            commandExecutor = new CommandExecutorImpl(getDefaultCommandConfig(), first);
        }
    }
    public CommandInterceptor initInterceptorChain(List<CommandInterceptor> chain) {
        if (chain == null || chain.isEmpty()) {
            throw new ActivitiException("invalid command interceptor chain configuration: " + chain);
        }
        for (int i = 0; i < chain.size() - 1; i++) {
            chain.get(i).setNext(chain.get(i + 1));
        }
        return chain.get(0);
    }
    public abstract CommandInterceptor createTransactionInterceptor();
    // services
    // /////////////////////////////////////////////////////////////////
    public void initServices() {
        initService(repositoryService);
        initService(runtimeService);
        initService(historyService);
        initService(identityService);
        initService(taskService);
        initService(formService);
        initService(managementService);
        initService(dynamicBpmnService);
    }
    public void initService(Object service) {
        if (service instanceof ServiceImpl) {
            ((ServiceImpl) service).setCommandExecutor(commandExecutor);
        }
    }
    // DataSource
    // ///////////////////////////////////////////////////////////////
    public void initDataSource() {
        if (dataSource == null) {
            if (dataSourceJndiName != null) {
                try {
                    dataSource = (DataSource) new InitialContext().lookup(dataSourceJndiName);
                } catch (Exception e) {
                    throw new ActivitiException("couldn't lookup datasource from " + dataSourceJndiName + ": " + e.getMessage(), e);
                }
            } else if (jdbcUrl != null) {
                if ((jdbcDriver == null) || (jdbcUsername == null)) {
                    throw new ActivitiException("DataSource or JDBC properties have to be specified in a process engine configuration");
                }
                log.debug("initializing datasource to db: {}", jdbcUrl);
                PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword);
                if (jdbcMaxActiveConnections > 0) {
                    pooledDataSource.setPoolMaximumActiveConnections(jdbcMaxActiveConnections);
                }
                if (jdbcMaxIdleConnections > 0) {
                    pooledDataSource.setPoolMaximumIdleConnections(jdbcMaxIdleConnections);
                }
                if (jdbcMaxCheckoutTime > 0) {
                    pooledDataSource.setPoolMaximumCheckoutTime(jdbcMaxCheckoutTime);
                }
                if (jdbcMaxWaitTime > 0) {
                    pooledDataSource.setPoolTimeToWait(jdbcMaxWaitTime);
                }
                if (jdbcPingEnabled == true) {
                    pooledDataSource.setPoolPingEnabled(true);
                    if (jdbcPingQuery != null) {
                        pooledDataSource.setPoolPingQuery(jdbcPingQuery);
                    }
                    pooledDataSource.setPoolPingConnectionsNotUsedFor(jdbcPingConnectionNotUsedFor);
                }
                if (jdbcDefaultTransactionIsolationLevel > 0) {
                    pooledDataSource.setDefaultTransactionIsolationLevel(jdbcDefaultTransactionIsolationLevel);
                }
                dataSource = pooledDataSource;
            }
            if (dataSource instanceof PooledDataSource) {
                // ACT-233: connection pool of Ibatis is not properly
                // initialized if this is not called!
                ((PooledDataSource) dataSource).forceCloseAll();
            }
        }
        if (databaseType == null) {
            initDatabaseType();
        }
    }
    protected static Properties databaseTypeMappings = getDefaultDatabaseTypeMappings();
    public static final String DATABASE_TYPE_DM = "dm";
    public static final String DATABASE_TYPE_H2 = "h2";
    public static final String DATABASE_TYPE_HSQL = "hsql";
    public static final String DATABASE_TYPE_MYSQL = "mysql";
    public static final String DATABASE_TYPE_ORACLE = "oracle";
    public static final String DATABASE_TYPE_POSTGRES = "postgres";
    public static final String DATABASE_TYPE_MSSQL = "mssql";
    public static final String DATABASE_TYPE_DB2 = "db2";
    public static Properties getDefaultDatabaseTypeMappings() {
        Properties databaseTypeMappings = new Properties();
        databaseTypeMappings.setProperty("H2", DATABASE_TYPE_H2);
        databaseTypeMappings.setProperty("HSQL Database Engine", DATABASE_TYPE_HSQL);
        databaseTypeMappings.setProperty("MySQL", DATABASE_TYPE_MYSQL);
        databaseTypeMappings.setProperty("Oracle", DATABASE_TYPE_ORACLE);
        databaseTypeMappings.setProperty("PostgreSQL", DATABASE_TYPE_POSTGRES);
        databaseTypeMappings.setProperty("Microsoft SQL Server", DATABASE_TYPE_MSSQL);
        databaseTypeMappings.setProperty(DATABASE_TYPE_DB2, DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2",DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/NT", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/NT64", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2 UDP", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUX", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUX390", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUXX8664", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUXZ64", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUXPPC64",DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUXPPC64LE",DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/400 SQL", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/6000", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2 UDB iSeries", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/AIX64", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/HPUX", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/HP64", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/SUN", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/SUN64", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/PTX", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/2", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2 UDB AS400", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("dm", DATABASE_TYPE_DM);
        databaseTypeMappings.setProperty("DM DBMS",DATABASE_TYPE_ORACLE);
        return databaseTypeMappings;
    }
    public void initDatabaseType() {
        Connection connection = null;
        try {
            connection = dataSource.getConnection();
            DatabaseMetaData databaseMetaData = connection.getMetaData();
            String databaseProductName = databaseMetaData.getDatabaseProductName();
            log.debug("database product name: '{}'", databaseProductName);
            databaseType = databaseTypeMappings.getProperty(databaseProductName);
            if (databaseType == null) {
                throw new ActivitiException("couldn't deduct database type from database product name '" + databaseProductName + "'");
            }
            log.debug("using database type: {}", databaseType);
            // Special care for MSSQL, as it has a hard limit of 2000 params per statement (incl bulk statement).
            // Especially with executions, with 100 as default, this limit is passed.
            if (DATABASE_TYPE_MSSQL.equals(databaseType)) {
                maxNrOfStatementsInBulkInsert = DEFAULT_MAX_NR_OF_STATEMENTS_BULK_INSERT_SQL_SERVER;
            }
        } catch (SQLException e) {
            log.error("Exception while initializing Database connection", e);
        } finally {
            try {
                if (connection != null) {
                    connection.close();
                }
            } catch (SQLException e) {
                log.error("Exception while closing the Database connection", e);
            }
        }
    }
    // myBatis SqlSessionFactory
    // ////////////////////////////////////////////////
    public void initTransactionFactory() {
        if (transactionFactory == null) {
            if (transactionsExternallyManaged) {
                transactionFactory = new ManagedTransactionFactory();
            } else {
                transactionFactory = new JdbcTransactionFactory();
            }
        }
    }
    public void initSqlSessionFactory() {
        if (sqlSessionFactory == null) {
            InputStream inputStream = null;
            try {
                inputStream = getMyBatisXmlConfigurationStream();
                Environment environment = new Environment("default", transactionFactory, dataSource);
                Reader reader = new InputStreamReader(inputStream);
                Properties properties = new Properties();
                properties.put("prefix", databaseTablePrefix);
                String wildcardEscapeClause = "";
                if ((databaseWildcardEscapeCharacter != null) && (databaseWildcardEscapeCharacter.length() != 0)) {
                    wildcardEscapeClause = " escape '" + databaseWildcardEscapeCharacter + "'";
                }
                properties.put("wildcardEscapeClause", wildcardEscapeClause);
                //set default properties
                properties.put("limitBefore" , "");
                properties.put("limitAfter" , "");
                properties.put("limitBetween" , "");
                properties.put("limitOuterJoinBetween" , "");
                properties.put("limitBeforeNativeQuery" , "");
                properties.put("orderBy" , "order by ${orderByColumns}");
                properties.put("blobType" , "BLOB");
                properties.put("boolValue" , "TRUE");
                if (databaseType != null) {
                    properties.load(getResourceAsStream("org/activiti/db/properties/"+databaseType+".properties"));
                }
                Configuration configuration = initMybatisConfiguration(environment, reader, properties);
                sqlSessionFactory = new DefaultSqlSessionFactory(configuration);
            } catch (Exception e) {
                throw new ActivitiException("Error while building ibatis SqlSessionFactory: " + e.getMessage(), e);
            } finally {
                IoUtil.closeSilently(inputStream);
            }
        }
    }
    public Configuration initMybatisConfiguration(Environment environment, Reader reader, Properties properties) {
        XMLConfigBuilder parser = new XMLConfigBuilder(reader, "", properties);
        Configuration configuration = parser.getConfiguration();
        if(databaseType != null) {
            configuration.setDatabaseId(databaseType);
        }
        configuration.setEnvironment(environment);
        initMybatisTypeHandlers(configuration);
        initCustomMybatisMappers(configuration);
        configuration = parseMybatisConfiguration(configuration, parser);
        return configuration;
    }
    public void initMybatisTypeHandlers(Configuration configuration) {
        configuration.getTypeHandlerRegistry().register(VariableType.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler());
    }
    public void initCustomMybatisMappers(Configuration configuration) {
        if (getCustomMybatisMappers() != null) {
            for (Class<?> clazz : getCustomMybatisMappers()) {
                configuration.addMapper(clazz);
            }
        }
    }
    public Configuration parseMybatisConfiguration(Configuration configuration, XMLConfigBuilder parser) {
        return parseCustomMybatisXMLMappers(parser.parse());
    }
    public Configuration parseCustomMybatisXMLMappers(Configuration configuration) {
        if (getCustomMybatisXMLMappers() != null)
            // see XMLConfigBuilder.mapperElement()
            for (String resource : getCustomMybatisXMLMappers()) {
                XMLMapperBuilder mapperParser = new XMLMapperBuilder(getResourceAsStream(resource), configuration, resource, configuration.getSqlFragments());
                mapperParser.parse();
            }
        return configuration;
    }
    protected InputStream getResourceAsStream(String resource) {
        return ReflectUtil.getResourceAsStream(resource);
    }
    public InputStream getMyBatisXmlConfigurationStream() {
        return getResourceAsStream(DEFAULT_MYBATIS_MAPPING_FILE);
    }
    public Set<Class<?>> getCustomMybatisMappers() {
        return customMybatisMappers;
    }
    public void setCustomMybatisMappers(Set<Class<?>> customMybatisMappers) {
        this.customMybatisMappers = customMybatisMappers;
    }
    public Set<String> getCustomMybatisXMLMappers() {
        return customMybatisXMLMappers;
    }
    public void setCustomMybatisXMLMappers(Set<String> customMybatisXMLMappers) {
        this.customMybatisXMLMappers = customMybatisXMLMappers;
    }
    // Data managers ///////////////////////////////////////////////////////////
    public void initDataManagers() {
        if (attachmentDataManager == null) {
            attachmentDataManager = new MybatisAttachmentDataManager(this);
        }
        if (byteArrayDataManager == null) {
            byteArrayDataManager = new MybatisByteArrayDataManager(this);
        }
        if (commentDataManager == null) {
            commentDataManager = new MybatisCommentDataManager(this);
        }
        if (deploymentDataManager == null) {
            deploymentDataManager = new MybatisDeploymentDataManager(this);
        }
        if (eventLogEntryDataManager == null) {
            eventLogEntryDataManager = new MybatisEventLogEntryDataManager(this);
        }
        if (eventSubscriptionDataManager == null) {
            eventSubscriptionDataManager = new MybatisEventSubscriptionDataManager(this);
        }
        if (executionDataManager == null) {
            executionDataManager = new MybatisExecutionDataManager(this);
        }
        if (groupDataManager == null) {
            groupDataManager = new MybatisGroupDataManager(this);
        }
        if (historicActivityInstanceDataManager == null) {
            historicActivityInstanceDataManager = new MybatisHistoricActivityInstanceDataManager(this);
        }
        if (historicDetailDataManager == null) {
            historicDetailDataManager = new MybatisHistoricDetailDataManager(this);
        }
        if (historicIdentityLinkDataManager == null) {
            historicIdentityLinkDataManager = new MybatisHistoricIdentityLinkDataManager(this);
        }
        if (historicProcessInstanceDataManager == null) {
            historicProcessInstanceDataManager = new MybatisHistoricProcessInstanceDataManager(this);
        }
        if (historicTaskInstanceDataManager == null) {
            historicTaskInstanceDataManager = new MybatisHistoricTaskInstanceDataManager(this);
        }
        if (historicVariableInstanceDataManager == null) {
            historicVariableInstanceDataManager = new MybatisHistoricVariableInstanceDataManager(this);
        }
        if (identityInfoDataManager == null) {
            identityInfoDataManager = new MybatisIdentityInfoDataManager(this);
        }
        if (identityLinkDataManager == null) {
            identityLinkDataManager = new MybatisIdentityLinkDataManager(this);
        }
        if (jobDataManager == null) {
            jobDataManager = new MybatisJobDataManager(this);
        }
        if (timerJobDataManager == null) {
            timerJobDataManager = new MybatisTimerJobDataManager(this);
        }
        if (suspendedJobDataManager == null) {
            suspendedJobDataManager = new MybatisSuspendedJobDataManager(this);
        }
        if (deadLetterJobDataManager == null) {
            deadLetterJobDataManager = new MybatisDeadLetterJobDataManager(this);
        }
        if (membershipDataManager == null) {
            membershipDataManager = new MybatisMembershipDataManager(this);
        }
        if (modelDataManager == null) {
            modelDataManager = new MybatisModelDataManager(this);
        }
        if (processDefinitionDataManager == null) {
            processDefinitionDataManager = new MybatisProcessDefinitionDataManager(this);
        }
        if (processDefinitionInfoDataManager == null) {
            processDefinitionInfoDataManager = new MybatisProcessDefinitionInfoDataManager(this);
        }
        if (propertyDataManager == null) {
            propertyDataManager = new MybatisPropertyDataManager(this);
        }
        if (resourceDataManager == null) {
            resourceDataManager = new MybatisResourceDataManager(this);
        }
        if (taskDataManager == null) {
            taskDataManager = new MybatisTaskDataManager(this);
        }
        if (userDataManager == null) {
            userDataManager = new MybatisUserDataManager(this);
        }
        if (variableInstanceDataManager == null) {
            variableInstanceDataManager = new MybatisVariableInstanceDataManager(this);
        }
    }
    // Entity managers //////////////////////////////////////////////////////////
    public void initEntityManagers() {
        if (attachmentEntityManager == null) {
            attachmentEntityManager = new AttachmentEntityManagerImpl(this, attachmentDataManager);
        }
        if (byteArrayEntityManager == null) {
            byteArrayEntityManager = new ByteArrayEntityManagerImpl(this, byteArrayDataManager);
        }
        if (commentEntityManager == null) {
            commentEntityManager = new CommentEntityManagerImpl(this, commentDataManager);
        }
        if (deploymentEntityManager == null) {
            deploymentEntityManager = new DeploymentEntityManagerImpl(this, deploymentDataManager);
        }
        if (eventLogEntryEntityManager == null) {
            eventLogEntryEntityManager = new EventLogEntryEntityManagerImpl(this, eventLogEntryDataManager);
        }
        if (eventSubscriptionEntityManager == null) {
            eventSubscriptionEntityManager = new EventSubscriptionEntityManagerImpl(this, eventSubscriptionDataManager);
        }
        if (executionEntityManager == null) {
            executionEntityManager = new ExecutionEntityManagerImpl(this, executionDataManager);
        }
        if (groupEntityManager == null) {
            groupEntityManager = new GroupEntityManagerImpl(this, groupDataManager);
        }
        if (historicActivityInstanceEntityManager == null) {
            historicActivityInstanceEntityManager = new HistoricActivityInstanceEntityManagerImpl(this, historicActivityInstanceDataManager);
        }
        if (historicDetailEntityManager == null) {
            historicDetailEntityManager = new HistoricDetailEntityManagerImpl(this, historicDetailDataManager);
        }
        if (historicIdentityLinkEntityManager == null) {
            historicIdentityLinkEntityManager = new HistoricIdentityLinkEntityManagerImpl(this, historicIdentityLinkDataManager);
        }
        if (historicProcessInstanceEntityManager == null) {
            historicProcessInstanceEntityManager = new HistoricProcessInstanceEntityManagerImpl(this, historicProcessInstanceDataManager);
        }
        if (historicTaskInstanceEntityManager == null) {
            historicTaskInstanceEntityManager = new HistoricTaskInstanceEntityManagerImpl(this, historicTaskInstanceDataManager);
        }
        if (historicVariableInstanceEntityManager == null) {
            historicVariableInstanceEntityManager = new HistoricVariableInstanceEntityManagerImpl(this, historicVariableInstanceDataManager);
        }
        if (identityInfoEntityManager == null) {
            identityInfoEntityManager = new IdentityInfoEntityManagerImpl(this, identityInfoDataManager);
        }
        if (identityLinkEntityManager == null) {
            identityLinkEntityManager = new IdentityLinkEntityManagerImpl(this, identityLinkDataManager);
        }
        if (jobEntityManager == null) {
            jobEntityManager = new JobEntityManagerImpl(this, jobDataManager);
        }
        if (timerJobEntityManager == null) {
            timerJobEntityManager = new TimerJobEntityManagerImpl(this, timerJobDataManager);
        }
        if (suspendedJobEntityManager == null) {
            suspendedJobEntityManager = new SuspendedJobEntityManagerImpl(this, suspendedJobDataManager);
        }
        if (deadLetterJobEntityManager == null) {
            deadLetterJobEntityManager = new DeadLetterJobEntityManagerImpl(this, deadLetterJobDataManager);
        }
        if (membershipEntityManager == null) {
            membershipEntityManager = new MembershipEntityManagerImpl(this, membershipDataManager);
        }
        if (modelEntityManager == null) {
            modelEntityManager = new ModelEntityManagerImpl(this, modelDataManager);
        }
        if (processDefinitionEntityManager == null) {
            processDefinitionEntityManager = new ProcessDefinitionEntityManagerImpl(this, processDefinitionDataManager);
        }
        if (processDefinitionInfoEntityManager == null) {
            processDefinitionInfoEntityManager = new ProcessDefinitionInfoEntityManagerImpl(this, processDefinitionInfoDataManager);
        }
        if (propertyEntityManager == null) {
            propertyEntityManager = new PropertyEntityManagerImpl(this, propertyDataManager);
        }
        if (resourceEntityManager == null) {
            resourceEntityManager = new ResourceEntityManagerImpl(this, resourceDataManager);
        }
        if (tableDataManager == null) {
            tableDataManager = new TableDataManagerImpl(this);
        }
        if (taskEntityManager == null) {
            taskEntityManager = new TaskEntityManagerImpl(this, taskDataManager);
        }
        if (userEntityManager == null) {
            userEntityManager = new UserEntityManagerImpl(this, userDataManager);
        }
        if (variableInstanceEntityManager == null) {
            variableInstanceEntityManager = new VariableInstanceEntityManagerImpl(this, variableInstanceDataManager);
        }
    }
    // History manager ///////////////////////////////////////////////////////////
    public void initHistoryManager() {
        if (historyManager == null) {
            historyManager = new DefaultHistoryManager(this, historyLevel);
        }
    }
    // Job manager ///////////////////////////////////////////////////////////
    public void initJobManager() {
        if (jobManager == null) {
            jobManager = new DefaultJobManager(this);
        }
        jobManager.setProcessEngineConfiguration(this);
    }
    // session factories ////////////////////////////////////////////////////////
    public void initSessionFactories() {
        if (sessionFactories == null) {
            sessionFactories = new HashMap<Class<?>, SessionFactory>();
            if (usingRelationalDatabase) {
                initDbSqlSessionFactory();
            }
            addSessionFactory(new GenericManagerFactory(EntityCache.class, EntityCacheImpl.class));
        }
        if (customSessionFactories != null) {
            for (SessionFactory sessionFactory : customSessionFactories) {
                addSessionFactory(sessionFactory);
            }
        }
    }
    public void initDbSqlSessionFactory() {
        if (dbSqlSessionFactory == null) {
            dbSqlSessionFactory = createDbSqlSessionFactory();
        }
        dbSqlSessionFactory.setDatabaseType(databaseType);
        dbSqlSessionFactory.setIdGenerator(idGenerator);
        dbSqlSessionFactory.setSqlSessionFactory(sqlSessionFactory);
        dbSqlSessionFactory.setDbIdentityUsed(isDbIdentityUsed);
        dbSqlSessionFactory.setDbHistoryUsed(isDbHistoryUsed);
        dbSqlSessionFactory.setDatabaseTablePrefix(databaseTablePrefix);
        dbSqlSessionFactory.setTablePrefixIsSchema(tablePrefixIsSchema);
        dbSqlSessionFactory.setDatabaseCatalog(databaseCatalog);
        dbSqlSessionFactory.setDatabaseSchema(databaseSchema);
        dbSqlSessionFactory.setBulkInsertEnabled(isBulkInsertEnabled, databaseType);
        dbSqlSessionFactory.setMaxNrOfStatementsInBulkInsert(maxNrOfStatementsInBulkInsert);
        addSessionFactory(dbSqlSessionFactory);
    }
    public DbSqlSessionFactory createDbSqlSessionFactory() {
        return new DbSqlSessionFactory();
    }
    public void addSessionFactory(SessionFactory sessionFactory) {
        sessionFactories.put(sessionFactory.getSessionType(), sessionFactory);
    }
    public void initConfigurators() {
        allConfigurators = new ArrayList<ProcessEngineConfigurator>();
        // Configurators that are explicitly added to the config
        if (configurators != null) {
            for (ProcessEngineConfigurator configurator : configurators) {
                allConfigurators.add(configurator);
            }
        }
        // Auto discovery through ServiceLoader
        if (enableConfiguratorServiceLoader) {
            ClassLoader classLoader = getClassLoader();
            if (classLoader == null) {
                classLoader = ReflectUtil.getClassLoader();
            }
            ServiceLoader<ProcessEngineConfigurator> configuratorServiceLoader = ServiceLoader.load(ProcessEngineConfigurator.class, classLoader);
            int nrOfServiceLoadedConfigurators = 0;
            for (ProcessEngineConfigurator configurator : configuratorServiceLoader) {
                allConfigurators.add(configurator);
                nrOfServiceLoadedConfigurators++;
            }
            if (nrOfServiceLoadedConfigurators > 0) {
                log.info("Found {} auto-discoverable Process Engine Configurator{}", nrOfServiceLoadedConfigurators++, nrOfServiceLoadedConfigurators > 1 ? "s" : "");
            }
            if (!allConfigurators.isEmpty()) {
                // Order them according to the priorities (useful for dependent
                // configurator)
                Collections.sort(allConfigurators, new Comparator<ProcessEngineConfigurator>() {
                    @Override
                    public int compare(ProcessEngineConfigurator configurator1, ProcessEngineConfigurator configurator2) {
                        int priority1 = configurator1.getPriority();
                        int priority2 = configurator2.getPriority();
                        if (priority1 < priority2) {
                            return -1;
                        } else if (priority1 > priority2) {
                            return 1;
                        }
                        return 0;
                    }
                });
                // Execute the configurators
                log.info("Found {} Process Engine Configurators in total:", allConfigurators.size());
                for (ProcessEngineConfigurator configurator : allConfigurators) {
                    log.info("{} (priority:{})", configurator.getClass(), configurator.getPriority());
                }
            }
        }
    }
    public void configuratorsBeforeInit() {
        for (ProcessEngineConfigurator configurator : allConfigurators) {
            log.info("Executing beforeInit() of {} (priority:{})", configurator.getClass(), configurator.getPriority());
            configurator.beforeInit(this);
        }
    }
    public void configuratorsAfterInit() {
        for (ProcessEngineConfigurator configurator : allConfigurators) {
            log.info("Executing configure() of {} (priority:{})", configurator.getClass(), configurator.getPriority());
            configurator.configure(this);
        }
    }
    // deployers
    // ////////////////////////////////////////////////////////////////
    public void initProcessDefinitionCache() {
        if (processDefinitionCache == null) {
            if (processDefinitionCacheLimit <= 0) {
                processDefinitionCache = new DefaultDeploymentCache<ProcessDefinitionCacheEntry>();
            } else {
                processDefinitionCache = new DefaultDeploymentCache<ProcessDefinitionCacheEntry>(processDefinitionCacheLimit);
            }
        }
    }
    public void initProcessDefinitionInfoCache() {
        if (processDefinitionInfoCache == null) {
            if (processDefinitionInfoCacheLimit <= 0) {
                processDefinitionInfoCache = new ProcessDefinitionInfoCache(commandExecutor);
            } else {
                processDefinitionInfoCache = new ProcessDefinitionInfoCache(commandExecutor, processDefinitionInfoCacheLimit);
            }
        }
    }
    public void initKnowledgeBaseCache() {
        if (knowledgeBaseCache == null) {
            if (knowledgeBaseCacheLimit <= 0) {
                knowledgeBaseCache = new DefaultDeploymentCache<Object>();
            } else {
                knowledgeBaseCache = new DefaultDeploymentCache<Object>(knowledgeBaseCacheLimit);
            }
        }
    }
    public void initDeployers() {
        if (this.deployers == null) {
            this.deployers = new ArrayList<Deployer>();
            if (customPreDeployers != null) {
                this.deployers.addAll(customPreDeployers);
            }
            this.deployers.addAll(getDefaultDeployers());
            if (customPostDeployers != null) {
                this.deployers.addAll(customPostDeployers);
            }
        }
        if (deploymentManager == null) {
            deploymentManager = new DeploymentManager();
            deploymentManager.setDeployers(deployers);
            deploymentManager.setProcessDefinitionCache(processDefinitionCache);
            deploymentManager.setProcessDefinitionInfoCache(processDefinitionInfoCache);
            deploymentManager.setKnowledgeBaseCache(knowledgeBaseCache);
            deploymentManager.setProcessEngineConfiguration(this);
            deploymentManager.setProcessDefinitionEntityManager(processDefinitionEntityManager);
            deploymentManager.setDeploymentEntityManager(deploymentEntityManager);
        }
    }
    public void initBpmnDeployerDependencies() {
        if (parsedDeploymentBuilderFactory == null) {
            parsedDeploymentBuilderFactory = new ParsedDeploymentBuilderFactory();
        }
        if (parsedDeploymentBuilderFactory.getBpmnParser() == null) {
            parsedDeploymentBuilderFactory.setBpmnParser(bpmnParser);
        }
        if (timerManager == null) {
            timerManager = new TimerManager();
        }
        if (eventSubscriptionManager == null) {
            eventSubscriptionManager = new EventSubscriptionManager();
        }
        if (bpmnDeploymentHelper == null) {
            bpmnDeploymentHelper = new BpmnDeploymentHelper();
        }
        if (bpmnDeploymentHelper.getTimerManager() == null) {
            bpmnDeploymentHelper.setTimerManager(timerManager);
        }
        if (bpmnDeploymentHelper.getEventSubscriptionManager() == null) {
            bpmnDeploymentHelper.setEventSubscriptionManager(eventSubscriptionManager);
        }
        if (cachingAndArtifactsManager == null) {
            cachingAndArtifactsManager = new CachingAndArtifactsManager();
        }
        if (processDefinitionDiagramHelper == null) {
            processDefinitionDiagramHelper = new ProcessDefinitionDiagramHelper();
        }
    }
    public Collection<? extends Deployer> getDefaultDeployers() {
        List<Deployer> defaultDeployers = new ArrayList<Deployer>();
        if (bpmnDeployer == null) {
            bpmnDeployer = new BpmnDeployer();
        }
        initBpmnDeployerDependencies();
        bpmnDeployer.setIdGenerator(idGenerator);
        bpmnDeployer.setParsedDeploymentBuilderFactory(parsedDeploymentBuilderFactory);
        bpmnDeployer.setBpmnDeploymentHelper(bpmnDeploymentHelper);
        bpmnDeployer.setCachingAndArtifactsManager(cachingAndArtifactsManager);
        bpmnDeployer.setProcessDefinitionDiagramHelper(processDefinitionDiagramHelper);
        defaultDeployers.add(bpmnDeployer);
        return defaultDeployers;
    }
    public void initListenerFactory() {
        if (listenerFactory == null) {
            DefaultListenerFactory defaultListenerFactory = new DefaultListenerFactory();
            defaultListenerFactory.setExpressionManager(expressionManager);
            listenerFactory = defaultListenerFactory;
        } else if ((listenerFactory instanceof AbstractBehaviorFactory) && ((AbstractBehaviorFactory) listenerFactory).getExpressionManager() == null) {
            ((AbstractBehaviorFactory) listenerFactory).setExpressionManager(expressionManager);
        }
    }
    public void initBehaviorFactory() {
        if (activityBehaviorFactory == null) {
            DefaultActivityBehaviorFactory defaultActivityBehaviorFactory = new DefaultActivityBehaviorFactory();
            defaultActivityBehaviorFactory.setExpressionManager(expressionManager);
            activityBehaviorFactory = defaultActivityBehaviorFactory;
        } else if ((activityBehaviorFactory instanceof AbstractBehaviorFactory) && ((AbstractBehaviorFactory) activityBehaviorFactory).getExpressionManager() == null) {
            ((AbstractBehaviorFactory) activityBehaviorFactory).setExpressionManager(expressionManager);
        }
    }
    public void initBpmnParser() {
        if (bpmnParser == null) {
            bpmnParser = new BpmnParser();
        }
        if (bpmnParseFactory == null) {
            bpmnParseFactory = new DefaultBpmnParseFactory();
        }
        bpmnParser.setBpmnParseFactory(bpmnParseFactory);
        bpmnParser.setActivityBehaviorFactory(activityBehaviorFactory);
        bpmnParser.setListenerFactory(listenerFactory);
        List<BpmnParseHandler> parseHandlers = new ArrayList<BpmnParseHandler>();
        if (getPreBpmnParseHandlers() != null) {
            parseHandlers.addAll(getPreBpmnParseHandlers());
        }
        parseHandlers.addAll(getDefaultBpmnParseHandlers());
        if (getPostBpmnParseHandlers() != null) {
            parseHandlers.addAll(getPostBpmnParseHandlers());
        }
        BpmnParseHandlers bpmnParseHandlers = new BpmnParseHandlers();
        bpmnParseHandlers.addHandlers(parseHandlers);
        bpmnParser.setBpmnParserHandlers(bpmnParseHandlers);
    }
    public List<BpmnParseHandler> getDefaultBpmnParseHandlers() {
        // Alphabetic list of default parse handler classes
        List<BpmnParseHandler> bpmnParserHandlers = new ArrayList<BpmnParseHandler>();
        bpmnParserHandlers.add(new BoundaryEventParseHandler());
        bpmnParserHandlers.add(new BusinessRuleParseHandler());
        bpmnParserHandlers.add(new CallActivityParseHandler());
        bpmnParserHandlers.add(new CancelEventDefinitionParseHandler());
        bpmnParserHandlers.add(new CompensateEventDefinitionParseHandler());
        bpmnParserHandlers.add(new EndEventParseHandler());
        bpmnParserHandlers.add(new ErrorEventDefinitionParseHandler());
        bpmnParserHandlers.add(new EventBasedGatewayParseHandler());
        bpmnParserHandlers.add(new ExclusiveGatewayParseHandler());
        bpmnParserHandlers.add(new InclusiveGatewayParseHandler());
        bpmnParserHandlers.add(new IntermediateCatchEventParseHandler());
        bpmnParserHandlers.add(new IntermediateThrowEventParseHandler());
        bpmnParserHandlers.add(new ManualTaskParseHandler());
        bpmnParserHandlers.add(new MessageEventDefinitionParseHandler());
        bpmnParserHandlers.add(new ParallelGatewayParseHandler());
        bpmnParserHandlers.add(new ProcessParseHandler());
        bpmnParserHandlers.add(new ReceiveTaskParseHandler());
        bpmnParserHandlers.add(new ScriptTaskParseHandler());
        bpmnParserHandlers.add(new SendTaskParseHandler());
        bpmnParserHandlers.add(new SequenceFlowParseHandler());
        bpmnParserHandlers.add(new ServiceTaskParseHandler());
        bpmnParserHandlers.add(new SignalEventDefinitionParseHandler());
        bpmnParserHandlers.add(new StartEventParseHandler());
        bpmnParserHandlers.add(new SubProcessParseHandler());
        bpmnParserHandlers.add(new EventSubProcessParseHandler());
        bpmnParserHandlers.add(new AdhocSubProcessParseHandler());
        bpmnParserHandlers.add(new TaskParseHandler());
        bpmnParserHandlers.add(new TimerEventDefinitionParseHandler());
        bpmnParserHandlers.add(new TransactionParseHandler());
        bpmnParserHandlers.add(new UserTaskParseHandler());
        // Replace any default handler if the user wants to replace them
        if (customDefaultBpmnParseHandlers != null) {
            Map<Class<?>, BpmnParseHandler> customParseHandlerMap = new HashMap<Class<?>, BpmnParseHandler>();
            for (BpmnParseHandler bpmnParseHandler : customDefaultBpmnParseHandlers) {
                for (Class<?> handledType : bpmnParseHandler.getHandledTypes()) {
                    customParseHandlerMap.put(handledType, bpmnParseHandler);
                }
            }
            for (int i = 0; i < bpmnParserHandlers.size(); i++) {
                // All the default handlers support only one type
                BpmnParseHandler defaultBpmnParseHandler = bpmnParserHandlers.get(i);
                if (defaultBpmnParseHandler.getHandledTypes().size() != 1) {
                    StringBuilder supportedTypes = new StringBuilder();
                    for (Class<?> type : defaultBpmnParseHandler.getHandledTypes()) {
                        supportedTypes.append(" ").append(type.getCanonicalName()).append(" ");
                    }
                    throw new ActivitiException("The default BPMN parse handlers should only support one type, but " + defaultBpmnParseHandler.getClass() + " supports " + supportedTypes.toString()
                            + ". This is likely a programmatic error");
                } else {
                    Class<?> handledType = defaultBpmnParseHandler.getHandledTypes().iterator().next();
                    if (customParseHandlerMap.containsKey(handledType)) {
                        BpmnParseHandler newBpmnParseHandler = customParseHandlerMap.get(handledType);
                        log.info("Replacing default BpmnParseHandler " + defaultBpmnParseHandler.getClass().getName() + " with " + newBpmnParseHandler.getClass().getName());
                        bpmnParserHandlers.set(i, newBpmnParseHandler);
                    }
                }
            }
        }
        return bpmnParserHandlers;
    }
    public void initClock() {
        if (clock == null) {
            clock = new DefaultClockImpl();
        }
    }
    public void initProcessDiagramGenerator() {
        if (processDiagramGenerator == null) {
            processDiagramGenerator = new DefaultProcessDiagramGenerator();
        }
    }
    public void initAgendaFactory() {
        if (this.engineAgendaFactory == null) {
            this.engineAgendaFactory = new DefaultActivitiEngineAgendaFactory();
        }
    }
    public void initJobHandlers() {
        jobHandlers = new HashMap<String, JobHandler>();
        AsyncContinuationJobHandler asyncContinuationJobHandler = new AsyncContinuationJobHandler();
        jobHandlers.put(asyncContinuationJobHandler.getType(), asyncContinuationJobHandler);
        TriggerTimerEventJobHandler triggerTimerEventJobHandler = new TriggerTimerEventJobHandler();
        jobHandlers.put(triggerTimerEventJobHandler.getType(), triggerTimerEventJobHandler);
        TimerStartEventJobHandler timerStartEvent = new TimerStartEventJobHandler();
        jobHandlers.put(timerStartEvent.getType(), timerStartEvent);
        TimerSuspendProcessDefinitionHandler suspendProcessDefinitionHandler = new TimerSuspendProcessDefinitionHandler();
        jobHandlers.put(suspendProcessDefinitionHandler.getType(), suspendProcessDefinitionHandler);
        TimerActivateProcessDefinitionHandler activateProcessDefinitionHandler = new TimerActivateProcessDefinitionHandler();
        jobHandlers.put(activateProcessDefinitionHandler.getType(), activateProcessDefinitionHandler);
        ProcessEventJobHandler processEventJobHandler = new ProcessEventJobHandler();
        jobHandlers.put(processEventJobHandler.getType(), processEventJobHandler);
        // if we have custom job handlers, register them
        if (getCustomJobHandlers() != null) {
            for (JobHandler customJobHandler : getCustomJobHandlers()) {
                jobHandlers.put(customJobHandler.getType(), customJobHandler);
            }
        }
    }
    // async executor
    // /////////////////////////////////////////////////////////////
    public void initAsyncExecutor() {
        if (asyncExecutor == null) {
            DefaultAsyncJobExecutor defaultAsyncExecutor = new DefaultAsyncJobExecutor();
            // Message queue mode
            defaultAsyncExecutor.setMessageQueueMode(asyncExecutorMessageQueueMode);
            // Thread pool config
            defaultAsyncExecutor.setCorePoolSize(asyncExecutorCorePoolSize);
            defaultAsyncExecutor.setMaxPoolSize(asyncExecutorMaxPoolSize);
            defaultAsyncExecutor.setKeepAliveTime(asyncExecutorThreadKeepAliveTime);
            // Threadpool queue
            if (asyncExecutorThreadPoolQueue != null) {
                defaultAsyncExecutor.setThreadPoolQueue(asyncExecutorThreadPoolQueue);
            }
            defaultAsyncExecutor.setQueueSize(asyncExecutorThreadPoolQueueSize);
            // Acquisition wait time
            defaultAsyncExecutor.setDefaultTimerJobAcquireWaitTimeInMillis(asyncExecutorDefaultTimerJobAcquireWaitTime);
            defaultAsyncExecutor.setDefaultAsyncJobAcquireWaitTimeInMillis(asyncExecutorDefaultAsyncJobAcquireWaitTime);
            // Queue full wait time
            defaultAsyncExecutor.setDefaultQueueSizeFullWaitTimeInMillis(asyncExecutorDefaultQueueSizeFullWaitTime);
            // Job locking
            defaultAsyncExecutor.setTimerLockTimeInMillis(asyncExecutorTimerLockTimeInMillis);
            defaultAsyncExecutor.setAsyncJobLockTimeInMillis(asyncExecutorAsyncJobLockTimeInMillis);
            if (asyncExecutorLockOwner != null) {
                defaultAsyncExecutor.setLockOwner(asyncExecutorLockOwner);
            }
            // Reset expired
            defaultAsyncExecutor.setResetExpiredJobsInterval(asyncExecutorResetExpiredJobsInterval);
            defaultAsyncExecutor.setResetExpiredJobsPageSize(asyncExecutorResetExpiredJobsPageSize);
            // Shutdown
            defaultAsyncExecutor.setSecondsToWaitOnShutdown(asyncExecutorSecondsToWaitOnShutdown);
            asyncExecutor = defaultAsyncExecutor;
        }
        asyncExecutor.setProcessEngineConfiguration(this);
        asyncExecutor.setAutoActivate(asyncExecutorActivate);
    }
    // history
    // //////////////////////////////////////////////////////////////////
    public void initHistoryLevel() {
        if (historyLevel == null) {
            historyLevel = HistoryLevel.getHistoryLevelForKey(getHistory());
        }
    }
    // id generator
    // /////////////////////////////////////////////////////////////
    public void initIdGenerator() {
        if (idGenerator == null) {
            CommandExecutor idGeneratorCommandExecutor = null;
            if (idGeneratorDataSource != null) {
                ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneProcessEngineConfiguration();
                processEngineConfiguration.setDataSource(idGeneratorDataSource);
                processEngineConfiguration.setDatabaseSchemaUpdate(DB_SCHEMA_UPDATE_FALSE);
                processEngineConfiguration.init();
                idGeneratorCommandExecutor = processEngineConfiguration.getCommandExecutor();
            } else if (idGeneratorDataSourceJndiName != null) {
                ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneProcessEngineConfiguration();
                processEngineConfiguration.setDataSourceJndiName(idGeneratorDataSourceJndiName);
                processEngineConfiguration.setDatabaseSchemaUpdate(DB_SCHEMA_UPDATE_FALSE);
                processEngineConfiguration.init();
                idGeneratorCommandExecutor = processEngineConfiguration.getCommandExecutor();
            } else {
                idGeneratorCommandExecutor = getCommandExecutor();
            }
            DbIdGenerator dbIdGenerator = new DbIdGenerator();
            dbIdGenerator.setIdBlockSize(idBlockSize);
            dbIdGenerator.setCommandExecutor(idGeneratorCommandExecutor);
            dbIdGenerator.setCommandConfig(getDefaultCommandConfig().transactionRequiresNew());
            idGenerator = dbIdGenerator;
        }
    }
    // OTHER
    // ////////////////////////////////////////////////////////////////////
    public void initCommandContextFactory() {
        if (commandContextFactory == null) {
            commandContextFactory = new CommandContextFactory();
        }
        commandContextFactory.setProcessEngineConfiguration(this);
    }
    public void initTransactionContextFactory() {
        if (transactionContextFactory == null) {
            transactionContextFactory = new StandaloneMybatisTransactionContextFactory();
        }
    }
    public void initHelpers() {
        if (processInstanceHelper == null) {
            processInstanceHelper = new ProcessInstanceHelper();
        }
        if (listenerNotificationHelper == null) {
            listenerNotificationHelper = new ListenerNotificationHelper();
        }
    }
    public void initVariableTypes() {
        if (variableTypes == null) {
            variableTypes = new DefaultVariableTypes();
            if (customPreVariableTypes != null) {
                for (VariableType customVariableType : customPreVariableTypes) {
                    variableTypes.addType(customVariableType);
                }
            }
            variableTypes.addType(new NullType());
            variableTypes.addType(new StringType(getMaxLengthString()));
            variableTypes.addType(new LongStringType(getMaxLengthString() + 1));
            variableTypes.addType(new BooleanType());
            variableTypes.addType(new ShortType());
            variableTypes.addType(new IntegerType());
            variableTypes.addType(new LongType());
            variableTypes.addType(new DateType());
            variableTypes.addType(new JodaDateType());
            variableTypes.addType(new JodaDateTimeType());
            variableTypes.addType(new DoubleType());
            variableTypes.addType(new UUIDType());
            variableTypes.addType(new JsonType(getMaxLengthString(), objectMapper));
            variableTypes.addType(new LongJsonType(getMaxLengthString() + 1, objectMapper));
            variableTypes.addType(new ByteArrayType());
            variableTypes.addType(new SerializableType(serializableVariableTypeTrackDeserializedObjects));
            variableTypes.addType(new CustomObjectType("item", ItemInstance.class));
            variableTypes.addType(new CustomObjectType("message", MessageInstance.class));
            if (customPostVariableTypes != null) {
                for (VariableType customVariableType : customPostVariableTypes) {
                    variableTypes.addType(customVariableType);
                }
            }
        }
    }
    public int getMaxLengthString() {
        if (maxLengthStringVariableType == -1) {
            if ("oracle".equalsIgnoreCase(databaseType) == true) {
                return DEFAULT_ORACLE_MAX_LENGTH_STRING;
            } else {
                return DEFAULT_GENERIC_MAX_LENGTH_STRING;
            }
        } else {
            return maxLengthStringVariableType;
        }
    }
    public void initFormEngines() {
        if (formEngines == null) {
            formEngines = new HashMap<String, FormEngine>();
            FormEngine defaultFormEngine = new JuelFormEngine();
            formEngines.put(null, defaultFormEngine); // default form engine is
            // looked up with null
            formEngines.put(defaultFormEngine.getName(), defaultFormEngine);
        }
        if (customFormEngines != null) {
            for (FormEngine formEngine : customFormEngines) {
                formEngines.put(formEngine.getName(), formEngine);
            }
        }
    }
    public void initFormTypes() {
        if (formTypes == null) {
            formTypes = new FormTypes();
            formTypes.addFormType(new StringFormType());
            formTypes.addFormType(new LongFormType());
            formTypes.addFormType(new DateFormType("dd/MM/yyyy"));
            formTypes.addFormType(new BooleanFormType());
            formTypes.addFormType(new DoubleFormType());
        }
        if (customFormTypes != null) {
            for (AbstractFormType customFormType : customFormTypes) {
                formTypes.addFormType(customFormType);
            }
        }
    }
    public void initScriptingEngines() {
        if (resolverFactories == null) {
            resolverFactories = new ArrayList<ResolverFactory>();
            resolverFactories.add(new VariableScopeResolverFactory());
            resolverFactories.add(new BeansResolverFactory());
        }
        if (scriptingEngines == null) {
            scriptingEngines = new ScriptingEngines(new ScriptBindingsFactory(this, resolverFactories));
        }
    }
    public void initExpressionManager() {
        if (expressionManager == null) {
            expressionManager = new ExpressionManager(beans);
        }
    }
    public void initBusinessCalendarManager() {
        if (businessCalendarManager == null) {
            MapBusinessCalendarManager mapBusinessCalendarManager = new MapBusinessCalendarManager();
            mapBusinessCalendarManager.addBusinessCalendar(DurationBusinessCalendar.NAME, new DurationBusinessCalendar(this.clock));
            mapBusinessCalendarManager.addBusinessCalendar(DueDateBusinessCalendar.NAME, new DueDateBusinessCalendar(this.clock));
            mapBusinessCalendarManager.addBusinessCalendar(CycleBusinessCalendar.NAME, new CycleBusinessCalendar(this.clock));
            businessCalendarManager = mapBusinessCalendarManager;
        }
    }
    public void initDelegateInterceptor() {
        if (delegateInterceptor == null) {
            delegateInterceptor = new DefaultDelegateInterceptor();
        }
    }
    public void initEventHandlers() {
        if (eventHandlers == null) {
            eventHandlers = new HashMap<String, EventHandler>();
            SignalEventHandler signalEventHandler = new SignalEventHandler();
            eventHandlers.put(signalEventHandler.getEventHandlerType(), signalEventHandler);
            CompensationEventHandler compensationEventHandler = new CompensationEventHandler();
            eventHandlers.put(compensationEventHandler.getEventHandlerType(), compensationEventHandler);
            MessageEventHandler messageEventHandler = new MessageEventHandler();
            eventHandlers.put(messageEventHandler.getEventHandlerType(), messageEventHandler);
        }
        if (customEventHandlers != null) {
            for (EventHandler eventHandler : customEventHandlers) {
                eventHandlers.put(eventHandler.getEventHandlerType(), eventHandler);
            }
        }
    }
    // JPA
    // //////////////////////////////////////////////////////////////////////
    public void initJpa() {
        if (jpaPersistenceUnitName != null) {
            jpaEntityManagerFactory = JpaHelper.createEntityManagerFactory(jpaPersistenceUnitName);
        }
        if (jpaEntityManagerFactory != null) {
            sessionFactories.put(EntityManagerSession.class, new EntityManagerSessionFactory(jpaEntityManagerFactory, jpaHandleTransaction, jpaCloseEntityManager));
            VariableType jpaType = variableTypes.getVariableType(JPAEntityVariableType.TYPE_NAME);
            // Add JPA-type
            if (jpaType == null) {
                // We try adding the variable right before SerializableType, if
                // available
                int serializableIndex = variableTypes.getTypeIndex(SerializableType.TYPE_NAME);
                if (serializableIndex > -1) {
                    variableTypes.addType(new JPAEntityVariableType(), serializableIndex);
                } else {
                    variableTypes.addType(new JPAEntityVariableType());
                }
            }
            jpaType = variableTypes.getVariableType(JPAEntityListVariableType.TYPE_NAME);
            // Add JPA-list type after regular JPA type if not already present
            if (jpaType == null) {
                variableTypes.addType(new JPAEntityListVariableType(), variableTypes.getTypeIndex(JPAEntityVariableType.TYPE_NAME));
            }
        }
    }
    public void initBeans() {
        if (beans == null) {
            beans = new HashMap<Object, Object>();
        }
    }
    public void initEventDispatcher() {
        if (this.eventDispatcher == null) {
            this.eventDispatcher = new ActivitiEventDispatcherImpl();
        }
        this.eventDispatcher.setEnabled(enableEventDispatcher);
        if (eventListeners != null) {
            for (ActivitiEventListener listenerToAdd : eventListeners) {
                this.eventDispatcher.addEventListener(listenerToAdd);
            }
        }
        if (typedEventListeners != null) {
            for (Entry<String, List<ActivitiEventListener>> listenersToAdd : typedEventListeners.entrySet()) {
                // Extract types from the given string
                ActivitiEventType[] types = ActivitiEventType.getTypesFromString(listenersToAdd.getKey());
                for (ActivitiEventListener listenerToAdd : listenersToAdd.getValue()) {
                    this.eventDispatcher.addEventListener(listenerToAdd, types);
                }
            }
        }
    }
    public void initProcessValidator() {
        if (this.processValidator == null) {
            this.processValidator = new ProcessValidatorFactory().createDefaultProcessValidator();
        }
    }
    public void initDatabaseEventLogging() {
        if (enableDatabaseEventLogging) {
            // Database event logging uses the default logging mechanism and adds
            // a specific event listener to the list of event listeners
            getEventDispatcher().addEventListener(new EventLogger(clock, objectMapper));
        }
    }
    public void initActiviti5CompatibilityHandler() {
        // If Activiti 5 compatibility is disabled, no need to do anything
        // If handler is injected, no need to do anything
        if (!isActiviti5CompatibilityEnabled || activiti5CompatibilityHandler == null) {
            // Create default factory if nothing set
            if (activiti5CompatibilityHandlerFactory == null) {
                activiti5CompatibilityHandlerFactory = new DefaultActiviti5CompatibilityHandlerFactory();
            }
            // Create handler instance
            activiti5CompatibilityHandler = activiti5CompatibilityHandlerFactory.createActiviti5CompatibilityHandler();
            if (activiti5CompatibilityHandler != null) {
                log.info("Found compatibility handler instance : " + activiti5CompatibilityHandler.getClass());
            }
        }
    }
    /**
     * Called when the {@link ProcessEngine} is initialized, but before it is returned
     */
    protected void postProcessEngineInitialisation() {
        if (performanceSettings.isValidateExecutionRelationshipCountConfigOnBoot()) {
            commandExecutor.execute(new ValidateExecutionRelatedEntityCountCfgCmd());
        }
    }
    // getters and setters
    // //////////////////////////////////////////////////////
    public CommandConfig getDefaultCommandConfig() {
        return defaultCommandConfig;
    }
    public void setDefaultCommandConfig(CommandConfig defaultCommandConfig) {
        this.defaultCommandConfig = defaultCommandConfig;
    }
    public CommandConfig getSchemaCommandConfig() {
        return schemaCommandConfig;
    }
    public void setSchemaCommandConfig(CommandConfig schemaCommandConfig) {
        this.schemaCommandConfig = schemaCommandConfig;
    }
    public CommandInterceptor getCommandInvoker() {
        return commandInvoker;
    }
    public void setCommandInvoker(CommandInterceptor commandInvoker) {
        this.commandInvoker = commandInvoker;
    }
    public List<CommandInterceptor> getCustomPreCommandInterceptors() {
        return customPreCommandInterceptors;
    }
    public ProcessEngineConfigurationImpl setCustomPreCommandInterceptors(List<CommandInterceptor> customPreCommandInterceptors) {
        this.customPreCommandInterceptors = customPreCommandInterceptors;
        return this;
    }
    public List<CommandInterceptor> getCustomPostCommandInterceptors() {
        return customPostCommandInterceptors;
    }
    public ProcessEngineConfigurationImpl setCustomPostCommandInterceptors(List<CommandInterceptor> customPostCommandInterceptors) {
        this.customPostCommandInterceptors = customPostCommandInterceptors;
        return this;
    }
    public List<CommandInterceptor> getCommandInterceptors() {
        return commandInterceptors;
    }
    public ProcessEngineConfigurationImpl setCommandInterceptors(List<CommandInterceptor> commandInterceptors) {
        this.commandInterceptors = commandInterceptors;
        return this;
    }
    public CommandExecutor getCommandExecutor() {
        return commandExecutor;
    }
    public ProcessEngineConfigurationImpl setCommandExecutor(CommandExecutor commandExecutor) {
        this.commandExecutor = commandExecutor;
        return this;
    }
    public RepositoryService getRepositoryService() {
        return repositoryService;
    }
    public ProcessEngineConfigurationImpl setRepositoryService(RepositoryService repositoryService) {
        this.repositoryService = repositoryService;
        return this;
    }
    public RuntimeService getRuntimeService() {
        return runtimeService;
    }
    public ProcessEngineConfigurationImpl setRuntimeService(RuntimeService runtimeService) {
        this.runtimeService = runtimeService;
        return this;
    }
    public HistoryService getHistoryService() {
        return historyService;
    }
    public ProcessEngineConfigurationImpl setHistoryService(HistoryService historyService) {
        this.historyService = historyService;
        return this;
    }
    public IdentityService getIdentityService() {
        return identityService;
    }
    public ProcessEngineConfigurationImpl setIdentityService(IdentityService identityService) {
        this.identityService = identityService;
        return this;
    }
    public TaskService getTaskService() {
        return taskService;
    }
    public ProcessEngineConfigurationImpl setTaskService(TaskService taskService) {
        this.taskService = taskService;
        return this;
    }
    public FormService getFormService() {
        return formService;
    }
    public ProcessEngineConfigurationImpl setFormService(FormService formService) {
        this.formService = formService;
        return this;
    }
    public ManagementService getManagementService() {
        return managementService;
    }
    public ProcessEngineConfigurationImpl setManagementService(ManagementService managementService) {
        this.managementService = managementService;
        return this;
    }
    public DynamicBpmnService getDynamicBpmnService() {
        return dynamicBpmnService;
    }
    public ProcessEngineConfigurationImpl setDynamicBpmnService(DynamicBpmnService dynamicBpmnService) {
        this.dynamicBpmnService = dynamicBpmnService;
        return this;
    }
    public ProcessEngineConfigurationImpl getProcessEngineConfiguration() {
        return this;
    }
    public boolean isFormEngineInitialized() {
        return formEngineInitialized;
    }
    public ProcessEngineConfigurationImpl setFormEngineInitialized(boolean formEngineInitialized) {
        this.formEngineInitialized = formEngineInitialized;
        return this;
    }
    public FormRepositoryService getFormEngineRepositoryService() {
        return formEngineRepositoryService;
    }
    public ProcessEngineConfigurationImpl setFormEngineRepositoryService(FormRepositoryService formEngineRepositoryService) {
        this.formEngineRepositoryService = formEngineRepositoryService;
        return this;
    }
    public org.activiti.form.api.FormService getFormEngineFormService() {
        return formEngineFormService;
    }
    public ProcessEngineConfigurationImpl setFormEngineFormService(org.activiti.form.api.FormService formEngineFormService) {
        this.formEngineFormService = formEngineFormService;
        return this;
    }
    public boolean isDmnEngineInitialized() {
        return dmnEngineInitialized;
    }
    public ProcessEngineConfigurationImpl setDmnEngineInitialized(boolean dmnEngineInitialized) {
        this.dmnEngineInitialized = dmnEngineInitialized;
        return this;
    }
    public DmnRepositoryService getDmnEngineRepositoryService() {
        return dmnEngineRepositoryService;
    }
    public ProcessEngineConfigurationImpl setDmnEngineRepositoryService(DmnRepositoryService dmnEngineRepositoryService) {
        this.dmnEngineRepositoryService = dmnEngineRepositoryService;
        return this;
    }
    public DmnRuleService getDmnEngineRuleService() {
        return dmnEngineRuleService;
    }
    public ProcessEngineConfigurationImpl setDmnEngineRuleService(DmnRuleService dmnEngineRuleService) {
        this.dmnEngineRuleService = dmnEngineRuleService;
        return this;
    }
    public Map<Class<?>, SessionFactory> getSessionFactories() {
        return sessionFactories;
    }
    public ProcessEngineConfigurationImpl setSessionFactories(Map<Class<?>, SessionFactory> sessionFactories) {
        this.sessionFactories = sessionFactories;
        return this;
    }
    public List<ProcessEngineConfigurator> getConfigurators() {
        return configurators;
    }
    public ProcessEngineConfigurationImpl addConfigurator(ProcessEngineConfigurator configurator) {
        if (this.configurators == null) {
            this.configurators = new ArrayList<ProcessEngineConfigurator>();
        }
        this.configurators.add(configurator);
        return this;
    }
    public ProcessEngineConfigurationImpl setConfigurators(List<ProcessEngineConfigurator> configurators) {
        this.configurators = configurators;
        return this;
    }
    public void setEnableConfiguratorServiceLoader(boolean enableConfiguratorServiceLoader) {
        this.enableConfiguratorServiceLoader = enableConfiguratorServiceLoader;
    }
    public List<ProcessEngineConfigurator> getAllConfigurators() {
        return allConfigurators;
    }
    public BpmnDeployer getBpmnDeployer() {
        return bpmnDeployer;
    }
    public ProcessEngineConfigurationImpl setBpmnDeployer(BpmnDeployer bpmnDeployer) {
        this.bpmnDeployer = bpmnDeployer;
        return this;
    }
    public BpmnParser getBpmnParser() {
        return bpmnParser;
    }
    public ProcessEngineConfigurationImpl setBpmnParser(BpmnParser bpmnParser) {
        this.bpmnParser = bpmnParser;
        return this;
    }
    public ParsedDeploymentBuilderFactory getParsedDeploymentBuilderFactory() {
        return parsedDeploymentBuilderFactory;
    }
    public ProcessEngineConfigurationImpl setParsedDeploymentBuilderFactory(ParsedDeploymentBuilderFactory parsedDeploymentBuilderFactory) {
        this.parsedDeploymentBuilderFactory = parsedDeploymentBuilderFactory;
        return this;
    }
    public TimerManager getTimerManager() {
        return timerManager;
    }
    public void setTimerManager(TimerManager timerManager) {
        this.timerManager = timerManager;
    }
    public EventSubscriptionManager getEventSubscriptionManager() {
        return eventSubscriptionManager;
    }
    public void setEventSubscriptionManager(EventSubscriptionManager eventSubscriptionManager) {
        this.eventSubscriptionManager = eventSubscriptionManager;
    }
    public BpmnDeploymentHelper getBpmnDeploymentHelper() {
        return bpmnDeploymentHelper;
    }
    public ProcessEngineConfigurationImpl setBpmnDeploymentHelper(BpmnDeploymentHelper bpmnDeploymentHelper) {
        this.bpmnDeploymentHelper = bpmnDeploymentHelper;
        return this;
    }
    public CachingAndArtifactsManager getCachingAndArtifactsManager() {
        return cachingAndArtifactsManager;
    }
    public void setCachingAndArtifactsManager(CachingAndArtifactsManager cachingAndArtifactsManager) {
        this.cachingAndArtifactsManager = cachingAndArtifactsManager;
    }
    public ProcessDefinitionDiagramHelper getProcessDefinitionDiagramHelper() {
        return processDefinitionDiagramHelper;
    }
    public ProcessEngineConfigurationImpl setProcessDefinitionDiagramHelper(ProcessDefinitionDiagramHelper processDefinitionDiagramHelper) {
        this.processDefinitionDiagramHelper = processDefinitionDiagramHelper;
        return this;
    }
    public List<Deployer> getDeployers() {
        return deployers;
    }
    public ProcessEngineConfigurationImpl setDeployers(List<Deployer> deployers) {
        this.deployers = deployers;
        return this;
    }
    public IdGenerator getIdGenerator() {
        return idGenerator;
    }
    public ProcessEngineConfigurationImpl setIdGenerator(IdGenerator idGenerator) {
        this.idGenerator = idGenerator;
        return this;
    }
    public String getWsSyncFactoryClassName() {
        return wsSyncFactoryClassName;
    }
    public ProcessEngineConfigurationImpl setWsSyncFactoryClassName(String wsSyncFactoryClassName) {
        this.wsSyncFactoryClassName = wsSyncFactoryClassName;
        return this;
    }
    /**
     * Add or replace the address of the given web-service endpoint with the given value
     * @param endpointName The endpoint name for which a new address must be set
     * @param address The new address of the endpoint
     */
    public ProcessEngineConfiguration addWsEndpointAddress(QName endpointName, URL address) {
        this.wsOverridenEndpointAddresses.put(endpointName, address);
        return this;
    }
    /**
     * Remove the address definition of the given web-service endpoint
     * @param endpointName The endpoint name for which the address definition must be removed
     */
    public ProcessEngineConfiguration removeWsEndpointAddress(QName endpointName) {
        this.wsOverridenEndpointAddresses.remove(endpointName);
        return this;
    }
    public ConcurrentMap<QName, URL> getWsOverridenEndpointAddresses() {
        return this.wsOverridenEndpointAddresses;
    }
    public ProcessEngineConfiguration setWsOverridenEndpointAddresses(final ConcurrentMap<QName, URL> wsOverridenEndpointAddress) {
        this.wsOverridenEndpointAddresses.putAll(wsOverridenEndpointAddress);
        return this;
    }
    public Map<String, FormEngine> getFormEngines() {
        return formEngines;
    }
    public ProcessEngineConfigurationImpl setFormEngines(Map<String, FormEngine> formEngines) {
        this.formEngines = formEngines;
        return this;
    }
    public FormTypes getFormTypes() {
        return formTypes;
    }
    public ProcessEngineConfigurationImpl setFormTypes(FormTypes formTypes) {
        this.formTypes = formTypes;
        return this;
    }
    public ScriptingEngines getScriptingEngines() {
        return scriptingEngines;
    }
    public ProcessEngineConfigurationImpl setScriptingEngines(ScriptingEngines scriptingEngines) {
        this.scriptingEngines = scriptingEngines;
        return this;
    }
    public VariableTypes getVariableTypes() {
        return variableTypes;
    }
    public ProcessEngineConfigurationImpl setVariableTypes(VariableTypes variableTypes) {
        this.variableTypes = variableTypes;
        return this;
    }
    public boolean isSerializableVariableTypeTrackDeserializedObjects() {
        return serializableVariableTypeTrackDeserializedObjects;
    }
    public void setSerializableVariableTypeTrackDeserializedObjects(boolean serializableVariableTypeTrackDeserializedObjects) {
        this.serializableVariableTypeTrackDeserializedObjects = serializableVariableTypeTrackDeserializedObjects;
    }
    public ExpressionManager getExpressionManager() {
        return expressionManager;
    }
    public ProcessEngineConfigurationImpl setExpressionManager(ExpressionManager expressionManager) {
        this.expressionManager = expressionManager;
        return this;
    }
    public BusinessCalendarManager getBusinessCalendarManager() {
        return businessCalendarManager;
    }
    public ProcessEngineConfigurationImpl setBusinessCalendarManager(BusinessCalendarManager businessCalendarManager) {
        this.businessCalendarManager = businessCalendarManager;
        return this;
    }
    public int getExecutionQueryLimit() {
        return executionQueryLimit;
    }
    public ProcessEngineConfigurationImpl setExecutionQueryLimit(int executionQueryLimit) {
        this.executionQueryLimit = executionQueryLimit;
        return this;
    }
    public int getTaskQueryLimit() {
        return taskQueryLimit;
    }
    public ProcessEngineConfigurationImpl setTaskQueryLimit(int taskQueryLimit) {
        this.taskQueryLimit = taskQueryLimit;
        return this;
    }
    public int getHistoricTaskQueryLimit() {
        return historicTaskQueryLimit;
    }
    public ProcessEngineConfigurationImpl setHistoricTaskQueryLimit(int historicTaskQueryLimit) {
        this.historicTaskQueryLimit = historicTaskQueryLimit;
        return this;
    }
    public int getHistoricProcessInstancesQueryLimit() {
        return historicProcessInstancesQueryLimit;
    }
    public ProcessEngineConfigurationImpl setHistoricProcessInstancesQueryLimit(int historicProcessInstancesQueryLimit) {
        this.historicProcessInstancesQueryLimit = historicProcessInstancesQueryLimit;
        return this;
    }
    public CommandContextFactory getCommandContextFactory() {
        return commandContextFactory;
    }
    public ProcessEngineConfigurationImpl setCommandContextFactory(CommandContextFactory commandContextFactory) {
        this.commandContextFactory = commandContextFactory;
        return this;
    }
    public TransactionContextFactory getTransactionContextFactory() {
        return transactionContextFactory;
    }
    public ProcessEngineConfigurationImpl setTransactionContextFactory(TransactionContextFactory transactionContextFactory) {
        this.transactionContextFactory = transactionContextFactory;
        return this;
    }
    public List<Deployer> getCustomPreDeployers() {
        return customPreDeployers;
    }
    public ProcessEngineConfigurationImpl setCustomPreDeployers(List<Deployer> customPreDeployers) {
        this.customPreDeployers = customPreDeployers;
        return this;
    }
    public List<Deployer> getCustomPostDeployers() {
        return customPostDeployers;
    }
    public ProcessEngineConfigurationImpl setCustomPostDeployers(List<Deployer> customPostDeployers) {
        this.customPostDeployers = customPostDeployers;
        return this;
    }
    public Map<String, JobHandler> getJobHandlers() {
        return jobHandlers;
    }
    public ProcessEngineConfigurationImpl setJobHandlers(Map<String, JobHandler> jobHandlers) {
        this.jobHandlers = jobHandlers;
        return this;
    }
    public ProcessInstanceHelper getProcessInstanceHelper() {
        return processInstanceHelper;
    }
    public ProcessEngineConfigurationImpl setProcessInstanceHelper(ProcessInstanceHelper processInstanceHelper) {
        this.processInstanceHelper = processInstanceHelper;
        return this;
    }
    public ListenerNotificationHelper getListenerNotificationHelper() {
        return listenerNotificationHelper;
    }
    public ProcessEngineConfigurationImpl setListenerNotificationHelper(ListenerNotificationHelper listenerNotificationHelper) {
        this.listenerNotificationHelper = listenerNotificationHelper;
        return this;
    }
    public SqlSessionFactory getSqlSessionFactory() {
        return sqlSessionFactory;
    }
    public ProcessEngineConfigurationImpl setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;
        return this;
    }
    public DbSqlSessionFactory getDbSqlSessionFactory() {
        return dbSqlSessionFactory;
    }
    public ProcessEngineConfigurationImpl setDbSqlSessionFactory(DbSqlSessionFactory dbSqlSessionFactory) {
        this.dbSqlSessionFactory = dbSqlSessionFactory;
        return this;
    }
    public TransactionFactory getTransactionFactory() {
        return transactionFactory;
    }
    public ProcessEngineConfigurationImpl setTransactionFactory(TransactionFactory transactionFactory) {
        this.transactionFactory = transactionFactory;
        return this;
    }
    public List<SessionFactory> getCustomSessionFactories() {
        return customSessionFactories;
    }
    public ProcessEngineConfigurationImpl setCustomSessionFactories(List<SessionFactory> customSessionFactories) {
        this.customSessionFactories = customSessionFactories;
        return this;
    }
    public List<JobHandler> getCustomJobHandlers() {
        return customJobHandlers;
    }
    public ProcessEngineConfigurationImpl setCustomJobHandlers(List<JobHandler> customJobHandlers) {
        this.customJobHandlers = customJobHandlers;
        return this;
    }
    public List<FormEngine> getCustomFormEngines() {
        return customFormEngines;
    }
    public ProcessEngineConfigurationImpl setCustomFormEngines(List<FormEngine> customFormEngines) {
        this.customFormEngines = customFormEngines;
        return this;
    }
    public List<AbstractFormType> getCustomFormTypes() {
        return customFormTypes;
    }
    public ProcessEngineConfigurationImpl setCustomFormTypes(List<AbstractFormType> customFormTypes) {
        this.customFormTypes = customFormTypes;
        return this;
    }
    public List<String> getCustomScriptingEngineClasses() {
        return customScriptingEngineClasses;
    }
    public ProcessEngineConfigurationImpl setCustomScriptingEngineClasses(List<String> customScriptingEngineClasses) {
        this.customScriptingEngineClasses = customScriptingEngineClasses;
        return this;
    }
    public List<VariableType> getCustomPreVariableTypes() {
        return customPreVariableTypes;
    }
    public ProcessEngineConfigurationImpl setCustomPreVariableTypes(List<VariableType> customPreVariableTypes) {
        this.customPreVariableTypes = customPreVariableTypes;
        return this;
    }
    public List<VariableType> getCustomPostVariableTypes() {
        return customPostVariableTypes;
    }
    public ProcessEngineConfigurationImpl setCustomPostVariableTypes(List<VariableType> customPostVariableTypes) {
        this.customPostVariableTypes = customPostVariableTypes;
        return this;
    }
    public List<BpmnParseHandler> getPreBpmnParseHandlers() {
        return preBpmnParseHandlers;
    }
    public ProcessEngineConfigurationImpl setPreBpmnParseHandlers(List<BpmnParseHandler> preBpmnParseHandlers) {
        this.preBpmnParseHandlers = preBpmnParseHandlers;
        return this;
    }
    public List<BpmnParseHandler> getCustomDefaultBpmnParseHandlers() {
        return customDefaultBpmnParseHandlers;
    }
    public ProcessEngineConfigurationImpl setCustomDefaultBpmnParseHandlers(List<BpmnParseHandler> customDefaultBpmnParseHandlers) {
        this.customDefaultBpmnParseHandlers = customDefaultBpmnParseHandlers;
        return this;
    }
    public List<BpmnParseHandler> getPostBpmnParseHandlers() {
        return postBpmnParseHandlers;
    }
    public ProcessEngineConfigurationImpl setPostBpmnParseHandlers(List<BpmnParseHandler> postBpmnParseHandlers) {
        this.postBpmnParseHandlers = postBpmnParseHandlers;
        return this;
    }
    public ActivityBehaviorFactory getActivityBehaviorFactory() {
        return activityBehaviorFactory;
    }
    public ProcessEngineConfigurationImpl setActivityBehaviorFactory(ActivityBehaviorFactory activityBehaviorFactory) {
        this.activityBehaviorFactory = activityBehaviorFactory;
        return this;
    }
    public ListenerFactory getListenerFactory() {
        return listenerFactory;
    }
    public ProcessEngineConfigurationImpl setListenerFactory(ListenerFactory listenerFactory) {
        this.listenerFactory = listenerFactory;
        return this;
    }
    public BpmnParseFactory getBpmnParseFactory() {
        return bpmnParseFactory;
    }
    public ProcessEngineConfigurationImpl setBpmnParseFactory(BpmnParseFactory bpmnParseFactory) {
        this.bpmnParseFactory = bpmnParseFactory;
        return this;
    }
    public Map<Object, Object> getBeans() {
        return beans;
    }
    public ProcessEngineConfigurationImpl setBeans(Map<Object, Object> beans) {
        this.beans = beans;
        return this;
    }
    public List<ResolverFactory> getResolverFactories() {
        return resolverFactories;
    }
    public ProcessEngineConfigurationImpl setResolverFactories(List<ResolverFactory> resolverFactories) {
        this.resolverFactories = resolverFactories;
        return this;
    }
    public DeploymentManager getDeploymentManager() {
        return deploymentManager;
    }
    public ProcessEngineConfigurationImpl setDeploymentManager(DeploymentManager deploymentManager) {
        this.deploymentManager = deploymentManager;
        return this;
    }
    public ProcessEngineConfigurationImpl setDelegateInterceptor(DelegateInterceptor delegateInterceptor) {
        this.delegateInterceptor = delegateInterceptor;
        return this;
    }
    public DelegateInterceptor getDelegateInterceptor() {
        return delegateInterceptor;
    }
    public EventHandler getEventHandler(String eventType) {
        return eventHandlers.get(eventType);
    }
    public ProcessEngineConfigurationImpl setEventHandlers(Map<String, EventHandler> eventHandlers) {
        this.eventHandlers = eventHandlers;
        return this;
    }
    public Map<String, EventHandler> getEventHandlers() {
        return eventHandlers;
    }
    public List<EventHandler> getCustomEventHandlers() {
        return customEventHandlers;
    }
    public ProcessEngineConfigurationImpl setCustomEventHandlers(List<EventHandler> customEventHandlers) {
        this.customEventHandlers = customEventHandlers;
        return this;
    }
    public FailedJobCommandFactory getFailedJobCommandFactory() {
        return failedJobCommandFactory;
    }
    public ProcessEngineConfigurationImpl setFailedJobCommandFactory(FailedJobCommandFactory failedJobCommandFactory) {
        this.failedJobCommandFactory = failedJobCommandFactory;
        return this;
    }
    public DataSource getIdGeneratorDataSource() {
        return idGeneratorDataSource;
    }
    public ProcessEngineConfigurationImpl setIdGeneratorDataSource(DataSource idGeneratorDataSource) {
        this.idGeneratorDataSource = idGeneratorDataSource;
        return this;
    }
    public String getIdGeneratorDataSourceJndiName() {
        return idGeneratorDataSourceJndiName;
    }
    public ProcessEngineConfigurationImpl setIdGeneratorDataSourceJndiName(String idGeneratorDataSourceJndiName) {
        this.idGeneratorDataSourceJndiName = idGeneratorDataSourceJndiName;
        return this;
    }
    public int getBatchSizeProcessInstances() {
        return batchSizeProcessInstances;
    }
    public ProcessEngineConfigurationImpl setBatchSizeProcessInstances(int batchSizeProcessInstances) {
        this.batchSizeProcessInstances = batchSizeProcessInstances;
        return this;
    }
    public int getBatchSizeTasks() {
        return batchSizeTasks;
    }
    public ProcessEngineConfigurationImpl setBatchSizeTasks(int batchSizeTasks) {
        this.batchSizeTasks = batchSizeTasks;
        return this;
    }
    public int getProcessDefinitionCacheLimit() {
        return processDefinitionCacheLimit;
    }
    public ProcessEngineConfigurationImpl setProcessDefinitionCacheLimit(int processDefinitionCacheLimit) {
        this.processDefinitionCacheLimit = processDefinitionCacheLimit;
        return this;
    }
    public DeploymentCache<ProcessDefinitionCacheEntry> getProcessDefinitionCache() {
        return processDefinitionCache;
    }
    public ProcessEngineConfigurationImpl setProcessDefinitionCache(DeploymentCache<ProcessDefinitionCacheEntry> processDefinitionCache) {
        this.processDefinitionCache = processDefinitionCache;
        return this;
    }
    public int getKnowledgeBaseCacheLimit() {
        return knowledgeBaseCacheLimit;
    }
    public ProcessEngineConfigurationImpl setKnowledgeBaseCacheLimit(int knowledgeBaseCacheLimit) {
        this.knowledgeBaseCacheLimit = knowledgeBaseCacheLimit;
        return this;
    }
    public DeploymentCache<Object> getKnowledgeBaseCache() {
        return knowledgeBaseCache;
    }
    public ProcessEngineConfigurationImpl setKnowledgeBaseCache(DeploymentCache<Object> knowledgeBaseCache) {
        this.knowledgeBaseCache = knowledgeBaseCache;
        return this;
    }
    public boolean isEnableSafeBpmnXml() {
        return enableSafeBpmnXml;
    }
    public ProcessEngineConfigurationImpl setEnableSafeBpmnXml(boolean enableSafeBpmnXml) {
        this.enableSafeBpmnXml = enableSafeBpmnXml;
        return this;
    }
    public ActivitiEventDispatcher getEventDispatcher() {
        return eventDispatcher;
    }
    public ProcessEngineConfigurationImpl setEventDispatcher(ActivitiEventDispatcher eventDispatcher) {
        this.eventDispatcher = eventDispatcher;
        return this;
    }
    public ProcessEngineConfigurationImpl setEnableEventDispatcher(boolean enableEventDispatcher) {
        this.enableEventDispatcher = enableEventDispatcher;
        return this;
    }
    public Map<String, List<ActivitiEventListener>> getTypedEventListeners() {
        return typedEventListeners;
    }
    public ProcessEngineConfigurationImpl setTypedEventListeners(Map<String, List<ActivitiEventListener>> typedListeners) {
        this.typedEventListeners = typedListeners;
        return this;
    }
    public List<ActivitiEventListener> getEventListeners() {
        return eventListeners;
    }
    public ProcessEngineConfigurationImpl setEventListeners(List<ActivitiEventListener> eventListeners) {
        this.eventListeners = eventListeners;
        return this;
    }
    public ProcessValidator getProcessValidator() {
        return processValidator;
    }
    public ProcessEngineConfigurationImpl setProcessValidator(ProcessValidator processValidator) {
        this.processValidator = processValidator;
        return this;
    }
    public boolean isEnableEventDispatcher() {
        return enableEventDispatcher;
    }
    public boolean isEnableDatabaseEventLogging() {
        return enableDatabaseEventLogging;
    }
    public ProcessEngineConfigurationImpl setEnableDatabaseEventLogging(boolean enableDatabaseEventLogging) {
        this.enableDatabaseEventLogging = enableDatabaseEventLogging;
        return this;
    }
    public int getMaxLengthStringVariableType() {
        return maxLengthStringVariableType;
    }
    public ProcessEngineConfigurationImpl setMaxLengthStringVariableType(int maxLengthStringVariableType) {
        this.maxLengthStringVariableType = maxLengthStringVariableType;
        return this;
    }
    public boolean isBulkInsertEnabled() {
        return isBulkInsertEnabled;
    }
    public ProcessEngineConfigurationImpl setBulkInsertEnabled(boolean isBulkInsertEnabled) {
        this.isBulkInsertEnabled = isBulkInsertEnabled;
        return this;
    }
    public int getMaxNrOfStatementsInBulkInsert() {
        return maxNrOfStatementsInBulkInsert;
    }
    public ProcessEngineConfigurationImpl setMaxNrOfStatementsInBulkInsert(int maxNrOfStatementsInBulkInsert) {
        this.maxNrOfStatementsInBulkInsert = maxNrOfStatementsInBulkInsert;
        return this;
    }
    public boolean isUsingRelationalDatabase() {
        return usingRelationalDatabase;
    }
    public ProcessEngineConfigurationImpl setUsingRelationalDatabase(boolean usingRelationalDatabase) {
        this.usingRelationalDatabase = usingRelationalDatabase;
        return this;
    }
    public boolean isEnableVerboseExecutionTreeLogging() {
        return enableVerboseExecutionTreeLogging;
    }
    public ProcessEngineConfigurationImpl setEnableVerboseExecutionTreeLogging(boolean enableVerboseExecutionTreeLogging) {
        this.enableVerboseExecutionTreeLogging = enableVerboseExecutionTreeLogging;
        return this;
    }
    public ProcessEngineConfigurationImpl setEnableEagerExecutionTreeFetching(boolean enableEagerExecutionTreeFetching) {
        this.performanceSettings.setEnableEagerExecutionTreeFetching(enableEagerExecutionTreeFetching);
        return this;
    }
    public ProcessEngineConfigurationImpl setEnableExecutionRelationshipCounts(boolean enableExecutionRelationshipCounts) {
        this.performanceSettings.setEnableExecutionRelationshipCounts(enableExecutionRelationshipCounts);
        return this;
    }
    public PerformanceSettings getPerformanceSettings() {
        return performanceSettings;
    }
    public void setPerformanceSettings(PerformanceSettings performanceSettings) {
        this.performanceSettings = performanceSettings;
    }
    public ProcessEngineConfigurationImpl setEnableLocalization(boolean enableLocalization) {
        this.performanceSettings.setEnableLocalization(enableLocalization);
        return this;
    }
    public AttachmentDataManager getAttachmentDataManager() {
        return attachmentDataManager;
    }
    public ProcessEngineConfigurationImpl setAttachmentDataManager(AttachmentDataManager attachmentDataManager) {
        this.attachmentDataManager = attachmentDataManager;
        return this;
    }
    public ByteArrayDataManager getByteArrayDataManager() {
        return byteArrayDataManager;
    }
    public ProcessEngineConfigurationImpl setByteArrayDataManager(ByteArrayDataManager byteArrayDataManager) {
        this.byteArrayDataManager = byteArrayDataManager;
        return this;
    }
    public CommentDataManager getCommentDataManager() {
        return commentDataManager;
    }
    public ProcessEngineConfigurationImpl setCommentDataManager(CommentDataManager commentDataManager) {
        this.commentDataManager = commentDataManager;
        return this;
    }
    public DeploymentDataManager getDeploymentDataManager() {
        return deploymentDataManager;
    }
    public ProcessEngineConfigurationImpl setDeploymentDataManager(DeploymentDataManager deploymentDataManager) {
        this.deploymentDataManager = deploymentDataManager;
        return this;
    }
    public EventLogEntryDataManager getEventLogEntryDataManager() {
        return eventLogEntryDataManager;
    }
    public ProcessEngineConfigurationImpl setEventLogEntryDataManager(EventLogEntryDataManager eventLogEntryDataManager) {
        this.eventLogEntryDataManager = eventLogEntryDataManager;
        return this;
    }
    public EventSubscriptionDataManager getEventSubscriptionDataManager() {
        return eventSubscriptionDataManager;
    }
    public ProcessEngineConfigurationImpl setEventSubscriptionDataManager(EventSubscriptionDataManager eventSubscriptionDataManager) {
        this.eventSubscriptionDataManager = eventSubscriptionDataManager;
        return this;
    }
    public ExecutionDataManager getExecutionDataManager() {
        return executionDataManager;
    }
    public ProcessEngineConfigurationImpl setExecutionDataManager(ExecutionDataManager executionDataManager) {
        this.executionDataManager = executionDataManager;
        return this;
    }
    public GroupDataManager getGroupDataManager() {
        return groupDataManager;
    }
    public ProcessEngineConfigurationImpl setGroupDataManager(GroupDataManager groupDataManager) {
        this.groupDataManager = groupDataManager;
        return this;
    }
    public HistoricActivityInstanceDataManager getHistoricActivityInstanceDataManager() {
        return historicActivityInstanceDataManager;
    }
    public ProcessEngineConfigurationImpl setHistoricActivityInstanceDataManager(HistoricActivityInstanceDataManager historicActivityInstanceDataManager) {
        this.historicActivityInstanceDataManager = historicActivityInstanceDataManager;
        return this;
    }
    public HistoricDetailDataManager getHistoricDetailDataManager() {
        return historicDetailDataManager;
    }
    public ProcessEngineConfigurationImpl setHistoricDetailDataManager(HistoricDetailDataManager historicDetailDataManager) {
        this.historicDetailDataManager = historicDetailDataManager;
        return this;
    }
    public HistoricIdentityLinkDataManager getHistoricIdentityLinkDataManager() {
        return historicIdentityLinkDataManager;
    }
    public ProcessEngineConfigurationImpl setHistoricIdentityLinkDataManager(HistoricIdentityLinkDataManager historicIdentityLinkDataManager) {
        this.historicIdentityLinkDataManager = historicIdentityLinkDataManager;
        return this;
    }
    public HistoricProcessInstanceDataManager getHistoricProcessInstanceDataManager() {
        return historicProcessInstanceDataManager;
    }
    public ProcessEngineConfigurationImpl setHistoricProcessInstanceDataManager(HistoricProcessInstanceDataManager historicProcessInstanceDataManager) {
        this.historicProcessInstanceDataManager = historicProcessInstanceDataManager;
        return this;
    }
    public HistoricTaskInstanceDataManager getHistoricTaskInstanceDataManager() {
        return historicTaskInstanceDataManager;
    }
    public ProcessEngineConfigurationImpl setHistoricTaskInstanceDataManager(HistoricTaskInstanceDataManager historicTaskInstanceDataManager) {
        this.historicTaskInstanceDataManager = historicTaskInstanceDataManager;
        return this;
    }
    public HistoricVariableInstanceDataManager getHistoricVariableInstanceDataManager() {
        return historicVariableInstanceDataManager;
    }
    public ProcessEngineConfigurationImpl setHistoricVariableInstanceDataManager(HistoricVariableInstanceDataManager historicVariableInstanceDataManager) {
        this.historicVariableInstanceDataManager = historicVariableInstanceDataManager;
        return this;
    }
    public IdentityInfoDataManager getIdentityInfoDataManager() {
        return identityInfoDataManager;
    }
    public ProcessEngineConfigurationImpl setIdentityInfoDataManager(IdentityInfoDataManager identityInfoDataManager) {
        this.identityInfoDataManager = identityInfoDataManager;
        return this;
    }
    public IdentityLinkDataManager getIdentityLinkDataManager() {
        return identityLinkDataManager;
    }
    public ProcessEngineConfigurationImpl setIdentityLinkDataManager(IdentityLinkDataManager identityLinkDataManager) {
        this.identityLinkDataManager = identityLinkDataManager;
        return this;
    }
    public JobDataManager getJobDataManager() {
        return jobDataManager;
    }
    public ProcessEngineConfigurationImpl setJobDataManager(JobDataManager jobDataManager) {
        this.jobDataManager = jobDataManager;
        return this;
    }
    public TimerJobDataManager getTimerJobDataManager() {
        return timerJobDataManager;
    }
    public ProcessEngineConfigurationImpl setTimerJobDataManager(TimerJobDataManager timerJobDataManager) {
        this.timerJobDataManager = timerJobDataManager;
        return this;
    }
    public SuspendedJobDataManager getSuspendedJobDataManager() {
        return suspendedJobDataManager;
    }
    public ProcessEngineConfigurationImpl setSuspendedJobDataManager(SuspendedJobDataManager suspendedJobDataManager) {
        this.suspendedJobDataManager = suspendedJobDataManager;
        return this;
    }
    public DeadLetterJobDataManager getDeadLetterJobDataManager() {
        return deadLetterJobDataManager;
    }
    public ProcessEngineConfigurationImpl setDeadLetterJobDataManager(DeadLetterJobDataManager deadLetterJobDataManager) {
        this.deadLetterJobDataManager = deadLetterJobDataManager;
        return this;
    }
    public MembershipDataManager getMembershipDataManager() {
        return membershipDataManager;
    }
    public ProcessEngineConfigurationImpl setMembershipDataManager(MembershipDataManager membershipDataManager) {
        this.membershipDataManager = membershipDataManager;
        return this;
    }
    public ModelDataManager getModelDataManager() {
        return modelDataManager;
    }
    public ProcessEngineConfigurationImpl setModelDataManager(ModelDataManager modelDataManager) {
        this.modelDataManager = modelDataManager;
        return this;
    }
    public ProcessDefinitionDataManager getProcessDefinitionDataManager() {
        return processDefinitionDataManager;
    }
    public ProcessEngineConfigurationImpl setProcessDefinitionDataManager(ProcessDefinitionDataManager processDefinitionDataManager) {
        this.processDefinitionDataManager = processDefinitionDataManager;
        return this;
    }
    public ProcessDefinitionInfoDataManager getProcessDefinitionInfoDataManager() {
        return processDefinitionInfoDataManager;
    }
    public ProcessEngineConfigurationImpl setProcessDefinitionInfoDataManager(ProcessDefinitionInfoDataManager processDefinitionInfoDataManager) {
        this.processDefinitionInfoDataManager = processDefinitionInfoDataManager;
        return this;
    }
    public PropertyDataManager getPropertyDataManager() {
        return propertyDataManager;
    }
    public ProcessEngineConfigurationImpl setPropertyDataManager(PropertyDataManager propertyDataManager) {
        this.propertyDataManager = propertyDataManager;
        return this;
    }
    public ResourceDataManager getResourceDataManager() {
        return resourceDataManager;
    }
    public ProcessEngineConfigurationImpl setResourceDataManager(ResourceDataManager resourceDataManager) {
        this.resourceDataManager = resourceDataManager;
        return this;
    }
    public TaskDataManager getTaskDataManager() {
        return taskDataManager;
    }
    public ProcessEngineConfigurationImpl setTaskDataManager(TaskDataManager taskDataManager) {
        this.taskDataManager = taskDataManager;
        return this;
    }
    public UserDataManager getUserDataManager() {
        return userDataManager;
    }
    public ProcessEngineConfigurationImpl setUserDataManager(UserDataManager userDataManager) {
        this.userDataManager = userDataManager;
        return this;
    }
    public VariableInstanceDataManager getVariableInstanceDataManager() {
        return variableInstanceDataManager;
    }
    public ProcessEngineConfigurationImpl setVariableInstanceDataManager(VariableInstanceDataManager variableInstanceDataManager) {
        this.variableInstanceDataManager = variableInstanceDataManager;
        return this;
    }
    public boolean isEnableConfiguratorServiceLoader() {
        return enableConfiguratorServiceLoader;
    }
    public AttachmentEntityManager getAttachmentEntityManager() {
        return attachmentEntityManager;
    }
    public ProcessEngineConfigurationImpl setAttachmentEntityManager(AttachmentEntityManager attachmentEntityManager) {
        this.attachmentEntityManager = attachmentEntityManager;
        return this;
    }
    public ByteArrayEntityManager getByteArrayEntityManager() {
        return byteArrayEntityManager;
    }
    public ProcessEngineConfigurationImpl setByteArrayEntityManager(ByteArrayEntityManager byteArrayEntityManager) {
        this.byteArrayEntityManager = byteArrayEntityManager;
        return this;
    }
    public CommentEntityManager getCommentEntityManager() {
        return commentEntityManager;
    }
    public ProcessEngineConfigurationImpl setCommentEntityManager(CommentEntityManager commentEntityManager) {
        this.commentEntityManager = commentEntityManager;
        return this;
    }
    public DeploymentEntityManager getDeploymentEntityManager() {
        return deploymentEntityManager;
    }
    public ProcessEngineConfigurationImpl setDeploymentEntityManager(DeploymentEntityManager deploymentEntityManager) {
        this.deploymentEntityManager = deploymentEntityManager;
        return this;
    }
    public EventLogEntryEntityManager getEventLogEntryEntityManager() {
        return eventLogEntryEntityManager;
    }
    public ProcessEngineConfigurationImpl setEventLogEntryEntityManager(EventLogEntryEntityManager eventLogEntryEntityManager) {
        this.eventLogEntryEntityManager = eventLogEntryEntityManager;
        return this;
    }
    public EventSubscriptionEntityManager getEventSubscriptionEntityManager() {
        return eventSubscriptionEntityManager;
    }
    public ProcessEngineConfigurationImpl setEventSubscriptionEntityManager(EventSubscriptionEntityManager eventSubscriptionEntityManager) {
        this.eventSubscriptionEntityManager = eventSubscriptionEntityManager;
        return this;
    }
    public ExecutionEntityManager getExecutionEntityManager() {
        return executionEntityManager;
    }
    public ProcessEngineConfigurationImpl setExecutionEntityManager(ExecutionEntityManager executionEntityManager) {
        this.executionEntityManager = executionEntityManager;
        return this;
    }
    public GroupEntityManager getGroupEntityManager() {
        return groupEntityManager;
    }
    public ProcessEngineConfigurationImpl setGroupEntityManager(GroupEntityManager groupEntityManager) {
        this.groupEntityManager = groupEntityManager;
        return this;
    }
    public HistoricActivityInstanceEntityManager getHistoricActivityInstanceEntityManager() {
        return historicActivityInstanceEntityManager;
    }
    public ProcessEngineConfigurationImpl setHistoricActivityInstanceEntityManager(HistoricActivityInstanceEntityManager historicActivityInstanceEntityManager) {
        this.historicActivityInstanceEntityManager = historicActivityInstanceEntityManager;
        return this;
    }
    public HistoricDetailEntityManager getHistoricDetailEntityManager() {
        return historicDetailEntityManager;
    }
    public ProcessEngineConfigurationImpl setHistoricDetailEntityManager(HistoricDetailEntityManager historicDetailEntityManager) {
        this.historicDetailEntityManager = historicDetailEntityManager;
        return this;
    }
    public HistoricIdentityLinkEntityManager getHistoricIdentityLinkEntityManager() {
        return historicIdentityLinkEntityManager;
    }
    public ProcessEngineConfigurationImpl setHistoricIdentityLinkEntityManager(HistoricIdentityLinkEntityManager historicIdentityLinkEntityManager) {
        this.historicIdentityLinkEntityManager = historicIdentityLinkEntityManager;
        return this;
    }
    public HistoricProcessInstanceEntityManager getHistoricProcessInstanceEntityManager() {
        return historicProcessInstanceEntityManager;
    }
    public ProcessEngineConfigurationImpl setHistoricProcessInstanceEntityManager(HistoricProcessInstanceEntityManager historicProcessInstanceEntityManager) {
        this.historicProcessInstanceEntityManager = historicProcessInstanceEntityManager;
        return this;
    }
    public HistoricTaskInstanceEntityManager getHistoricTaskInstanceEntityManager() {
        return historicTaskInstanceEntityManager;
    }
    public ProcessEngineConfigurationImpl setHistoricTaskInstanceEntityManager(HistoricTaskInstanceEntityManager historicTaskInstanceEntityManager) {
        this.historicTaskInstanceEntityManager = historicTaskInstanceEntityManager;
        return this;
    }
    public HistoricVariableInstanceEntityManager getHistoricVariableInstanceEntityManager() {
        return historicVariableInstanceEntityManager;
    }
    public ProcessEngineConfigurationImpl setHistoricVariableInstanceEntityManager(HistoricVariableInstanceEntityManager historicVariableInstanceEntityManager) {
        this.historicVariableInstanceEntityManager = historicVariableInstanceEntityManager;
        return this;
    }
    public IdentityInfoEntityManager getIdentityInfoEntityManager() {
        return identityInfoEntityManager;
    }
    public ProcessEngineConfigurationImpl setIdentityInfoEntityManager(IdentityInfoEntityManager identityInfoEntityManager) {
        this.identityInfoEntityManager = identityInfoEntityManager;
        return this;
    }
    public IdentityLinkEntityManager getIdentityLinkEntityManager() {
        return identityLinkEntityManager;
    }
    public ProcessEngineConfigurationImpl setIdentityLinkEntityManager(IdentityLinkEntityManager identityLinkEntityManager) {
        this.identityLinkEntityManager = identityLinkEntityManager;
        return this;
    }
    public JobEntityManager getJobEntityManager() {
        return jobEntityManager;
    }
    public ProcessEngineConfigurationImpl setJobEntityManager(JobEntityManager jobEntityManager) {
        this.jobEntityManager = jobEntityManager;
        return this;
    }
    public TimerJobEntityManager getTimerJobEntityManager() {
        return timerJobEntityManager;
    }
    public ProcessEngineConfigurationImpl setTimerJobEntityManager(TimerJobEntityManager timerJobEntityManager) {
        this.timerJobEntityManager = timerJobEntityManager;
        return this;
    }
    public SuspendedJobEntityManager getSuspendedJobEntityManager() {
        return suspendedJobEntityManager;
    }
    public ProcessEngineConfigurationImpl setSuspendedJobEntityManager(SuspendedJobEntityManager suspendedJobEntityManager) {
        this.suspendedJobEntityManager = suspendedJobEntityManager;
        return this;
    }
    public DeadLetterJobEntityManager getDeadLetterJobEntityManager() {
        return deadLetterJobEntityManager;
    }
    public ProcessEngineConfigurationImpl setDeadLetterJobEntityManager(DeadLetterJobEntityManager deadLetterJobEntityManager) {
        this.deadLetterJobEntityManager = deadLetterJobEntityManager;
        return this;
    }
    public MembershipEntityManager getMembershipEntityManager() {
        return membershipEntityManager;
    }
    public ProcessEngineConfigurationImpl setMembershipEntityManager(MembershipEntityManager membershipEntityManager) {
        this.membershipEntityManager = membershipEntityManager;
        return this;
    }
    public ModelEntityManager getModelEntityManager() {
        return modelEntityManager;
    }
    public ProcessEngineConfigurationImpl setModelEntityManager(ModelEntityManager modelEntityManager) {
        this.modelEntityManager = modelEntityManager;
        return this;
    }
    public ProcessDefinitionEntityManager getProcessDefinitionEntityManager() {
        return processDefinitionEntityManager;
    }
    public ProcessEngineConfigurationImpl setProcessDefinitionEntityManager(ProcessDefinitionEntityManager processDefinitionEntityManager) {
        this.processDefinitionEntityManager = processDefinitionEntityManager;
        return this;
    }
    public ProcessDefinitionInfoEntityManager getProcessDefinitionInfoEntityManager() {
        return processDefinitionInfoEntityManager;
    }
    public ProcessEngineConfigurationImpl setProcessDefinitionInfoEntityManager(ProcessDefinitionInfoEntityManager processDefinitionInfoEntityManager) {
        this.processDefinitionInfoEntityManager = processDefinitionInfoEntityManager;
        return this;
    }
    public PropertyEntityManager getPropertyEntityManager() {
        return propertyEntityManager;
    }
    public ProcessEngineConfigurationImpl setPropertyEntityManager(PropertyEntityManager propertyEntityManager) {
        this.propertyEntityManager = propertyEntityManager;
        return this;
    }
    public ResourceEntityManager getResourceEntityManager() {
        return resourceEntityManager;
    }
    public ProcessEngineConfigurationImpl setResourceEntityManager(ResourceEntityManager resourceEntityManager) {
        this.resourceEntityManager = resourceEntityManager;
        return this;
    }
    public TaskEntityManager getTaskEntityManager() {
        return taskEntityManager;
    }
    public ProcessEngineConfigurationImpl setTaskEntityManager(TaskEntityManager taskEntityManager) {
        this.taskEntityManager = taskEntityManager;
        return this;
    }
    public UserEntityManager getUserEntityManager() {
        return userEntityManager;
    }
    public ProcessEngineConfigurationImpl setUserEntityManager(UserEntityManager userEntityManager) {
        this.userEntityManager = userEntityManager;
        return this;
    }
    public VariableInstanceEntityManager getVariableInstanceEntityManager() {
        return variableInstanceEntityManager;
    }
    public ProcessEngineConfigurationImpl setVariableInstanceEntityManager(VariableInstanceEntityManager variableInstanceEntityManager) {
        this.variableInstanceEntityManager = variableInstanceEntityManager;
        return this;
    }
    public TableDataManager getTableDataManager() {
        return tableDataManager;
    }
    public ProcessEngineConfigurationImpl setTableDataManager(TableDataManager tableDataManager) {
        this.tableDataManager = tableDataManager;
        return this;
    }
    public HistoryManager getHistoryManager() {
        return historyManager;
    }
    public ProcessEngineConfigurationImpl setHistoryManager(HistoryManager historyManager) {
        this.historyManager = historyManager;
        return this;
    }
    public JobManager getJobManager() {
        return jobManager;
    }
    public ProcessEngineConfigurationImpl setJobManager(JobManager jobManager) {
        this.jobManager = jobManager;
        return this;
    }
    public ProcessEngineConfigurationImpl setClock(Clock clock) {
        if (this.clock == null) {
            this.clock = clock;
        } else {
            this.clock.setCurrentCalendar(clock.getCurrentCalendar());
        }
        if (isActiviti5CompatibilityEnabled && activiti5CompatibilityHandler != null) {
            getActiviti5CompatibilityHandler().setClock(clock);
        }
        return this;
    }
    public void resetClock() {
        if (this.clock != null) {
            clock.reset();
            if (isActiviti5CompatibilityEnabled && activiti5CompatibilityHandler != null) {
                getActiviti5CompatibilityHandler().resetClock();
            }
        }
    }
    public DelegateExpressionFieldInjectionMode getDelegateExpressionFieldInjectionMode() {
        return delegateExpressionFieldInjectionMode;
    }
    public ProcessEngineConfigurationImpl setDelegateExpressionFieldInjectionMode(DelegateExpressionFieldInjectionMode delegateExpressionFieldInjectionMode) {
        this.delegateExpressionFieldInjectionMode = delegateExpressionFieldInjectionMode;
        return this;
    }
    public ObjectMapper getObjectMapper() {
        return objectMapper;
    }
    public ProcessEngineConfigurationImpl setObjectMapper(ObjectMapper objectMapper) {
        this.objectMapper = objectMapper;
        return this;
    }
    // Activiti 5
    public boolean isActiviti5CompatibilityEnabled() {
        return isActiviti5CompatibilityEnabled;
    }
    public ProcessEngineConfigurationImpl setActiviti5CompatibilityEnabled(boolean isActiviti5CompatibilityEnabled) {
        this.isActiviti5CompatibilityEnabled = isActiviti5CompatibilityEnabled;
        return this;
    }
    public Activiti5CompatibilityHandlerFactory getActiviti5CompatibilityHandlerFactory() {
        return activiti5CompatibilityHandlerFactory;
    }
    public ProcessEngineConfigurationImpl setActiviti5CompatibilityHandlerFactory(Activiti5CompatibilityHandlerFactory activiti5CompatibilityHandlerFactory) {
        this.activiti5CompatibilityHandlerFactory = activiti5CompatibilityHandlerFactory;
        return this;
    }
    public Activiti5CompatibilityHandler getActiviti5CompatibilityHandler() {
        return activiti5CompatibilityHandler;
    }
    public ProcessEngineConfigurationImpl setActiviti5CompatibilityHandler(Activiti5CompatibilityHandler activiti5CompatibilityHandler) {
        this.activiti5CompatibilityHandler = activiti5CompatibilityHandler;
        return this;
    }
    public Object getActiviti5ActivityBehaviorFactory() {
        return activiti5ActivityBehaviorFactory;
    }
    public ProcessEngineConfigurationImpl setActiviti5ActivityBehaviorFactory(Object activiti5ActivityBehaviorFactory) {
        this.activiti5ActivityBehaviorFactory = activiti5ActivityBehaviorFactory;
        return this;
    }
    public Object getActiviti5ListenerFactory() {
        return activiti5ListenerFactory;
    }
    public ProcessEngineConfigurationImpl setActiviti5ListenerFactory(Object activiti5ListenerFactory) {
        this.activiti5ListenerFactory = activiti5ListenerFactory;
        return this;
    }
    public List<Object> getActiviti5PreBpmnParseHandlers() {
        return activiti5PreBpmnParseHandlers;
    }
    public ProcessEngineConfigurationImpl setActiviti5PreBpmnParseHandlers(List<Object> activiti5PreBpmnParseHandlers) {
        this.activiti5PreBpmnParseHandlers = activiti5PreBpmnParseHandlers;
        return this;
    }
    public List<Object> getActiviti5PostBpmnParseHandlers() {
        return activiti5PostBpmnParseHandlers;
    }
    public ProcessEngineConfigurationImpl setActiviti5PostBpmnParseHandlers(List<Object> activiti5PostBpmnParseHandlers) {
        this.activiti5PostBpmnParseHandlers = activiti5PostBpmnParseHandlers;
        return this;
    }
    public List<Object> getActiviti5CustomDefaultBpmnParseHandlers() {
        return activiti5CustomDefaultBpmnParseHandlers;
    }
    public ProcessEngineConfigurationImpl setActiviti5CustomDefaultBpmnParseHandlers(List<Object> activiti5CustomDefaultBpmnParseHandlers) {
        this.activiti5CustomDefaultBpmnParseHandlers = activiti5CustomDefaultBpmnParseHandlers;
        return this;
    }
    public Set<Class<?>> getActiviti5CustomMybatisMappers() {
        return activiti5CustomMybatisMappers;
    }
    public ProcessEngineConfigurationImpl setActiviti5CustomMybatisMappers(Set<Class<?>> activiti5CustomMybatisMappers) {
        this.activiti5CustomMybatisMappers = activiti5CustomMybatisMappers;
        return this;
    }
    public Set<String> getActiviti5CustomMybatisXMLMappers() {
        return activiti5CustomMybatisXMLMappers;
    }
    public ProcessEngineConfigurationImpl setActiviti5CustomMybatisXMLMappers(Set<String> activiti5CustomMybatisXMLMappers) {
        this.activiti5CustomMybatisXMLMappers = activiti5CustomMybatisXMLMappers;
        return this;
    }
    public int getAsyncExecutorCorePoolSize() {
        return asyncExecutorCorePoolSize;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorCorePoolSize(int asyncExecutorCorePoolSize) {
        this.asyncExecutorCorePoolSize = asyncExecutorCorePoolSize;
        return this;
    }
    public int getAsyncExecutorNumberOfRetries() {
        return asyncExecutorNumberOfRetries;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorNumberOfRetries(int asyncExecutorNumberOfRetries) {
        this.asyncExecutorNumberOfRetries = asyncExecutorNumberOfRetries;
        return this;
    }
    public int getAsyncExecutorMaxPoolSize() {
        return asyncExecutorMaxPoolSize;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorMaxPoolSize(int asyncExecutorMaxPoolSize) {
        this.asyncExecutorMaxPoolSize = asyncExecutorMaxPoolSize;
        return this;
    }
    public long getAsyncExecutorThreadKeepAliveTime() {
        return asyncExecutorThreadKeepAliveTime;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorThreadKeepAliveTime(long asyncExecutorThreadKeepAliveTime) {
        this.asyncExecutorThreadKeepAliveTime = asyncExecutorThreadKeepAliveTime;
        return this;
    }
    public int getAsyncExecutorThreadPoolQueueSize() {
        return asyncExecutorThreadPoolQueueSize;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorThreadPoolQueueSize(int asyncExecutorThreadPoolQueueSize) {
        this.asyncExecutorThreadPoolQueueSize = asyncExecutorThreadPoolQueueSize;
        return this;
    }
    public BlockingQueue<Runnable> getAsyncExecutorThreadPoolQueue() {
        return asyncExecutorThreadPoolQueue;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorThreadPoolQueue(BlockingQueue<Runnable> asyncExecutorThreadPoolQueue) {
        this.asyncExecutorThreadPoolQueue = asyncExecutorThreadPoolQueue;
        return this;
    }
    public long getAsyncExecutorSecondsToWaitOnShutdown() {
        return asyncExecutorSecondsToWaitOnShutdown;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorSecondsToWaitOnShutdown(long asyncExecutorSecondsToWaitOnShutdown) {
        this.asyncExecutorSecondsToWaitOnShutdown = asyncExecutorSecondsToWaitOnShutdown;
        return this;
    }
    public int getAsyncExecutorMaxTimerJobsPerAcquisition() {
        return asyncExecutorMaxTimerJobsPerAcquisition;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorMaxTimerJobsPerAcquisition(int asyncExecutorMaxTimerJobsPerAcquisition) {
        this.asyncExecutorMaxTimerJobsPerAcquisition = asyncExecutorMaxTimerJobsPerAcquisition;
        return this;
    }
    public int getAsyncExecutorMaxAsyncJobsDuePerAcquisition() {
        return asyncExecutorMaxAsyncJobsDuePerAcquisition;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorMaxAsyncJobsDuePerAcquisition(int asyncExecutorMaxAsyncJobsDuePerAcquisition) {
        this.asyncExecutorMaxAsyncJobsDuePerAcquisition = asyncExecutorMaxAsyncJobsDuePerAcquisition;
        return this;
    }
    public int getAsyncExecutorDefaultTimerJobAcquireWaitTime() {
        return asyncExecutorDefaultTimerJobAcquireWaitTime;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorDefaultTimerJobAcquireWaitTime(int asyncExecutorDefaultTimerJobAcquireWaitTime) {
        this.asyncExecutorDefaultTimerJobAcquireWaitTime = asyncExecutorDefaultTimerJobAcquireWaitTime;
        return this;
    }
    public int getAsyncExecutorDefaultAsyncJobAcquireWaitTime() {
        return asyncExecutorDefaultAsyncJobAcquireWaitTime;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorDefaultAsyncJobAcquireWaitTime(int asyncExecutorDefaultAsyncJobAcquireWaitTime) {
        this.asyncExecutorDefaultAsyncJobAcquireWaitTime = asyncExecutorDefaultAsyncJobAcquireWaitTime;
        return this;
    }
    public int getAsyncExecutorDefaultQueueSizeFullWaitTime() {
        return asyncExecutorDefaultQueueSizeFullWaitTime;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorDefaultQueueSizeFullWaitTime(int asyncExecutorDefaultQueueSizeFullWaitTime) {
        this.asyncExecutorDefaultQueueSizeFullWaitTime = asyncExecutorDefaultQueueSizeFullWaitTime;
        return this;
    }
    public String getAsyncExecutorLockOwner() {
        return asyncExecutorLockOwner;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorLockOwner(String asyncExecutorLockOwner) {
        this.asyncExecutorLockOwner = asyncExecutorLockOwner;
        return this;
    }
    public int getAsyncExecutorTimerLockTimeInMillis() {
        return asyncExecutorTimerLockTimeInMillis;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorTimerLockTimeInMillis(int asyncExecutorTimerLockTimeInMillis) {
        this.asyncExecutorTimerLockTimeInMillis = asyncExecutorTimerLockTimeInMillis;
        return this;
    }
    public int getAsyncExecutorAsyncJobLockTimeInMillis() {
        return asyncExecutorAsyncJobLockTimeInMillis;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorAsyncJobLockTimeInMillis(int asyncExecutorAsyncJobLockTimeInMillis) {
        this.asyncExecutorAsyncJobLockTimeInMillis = asyncExecutorAsyncJobLockTimeInMillis;
        return this;
    }
    public int getAsyncExecutorResetExpiredJobsInterval() {
        return asyncExecutorResetExpiredJobsInterval;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorResetExpiredJobsInterval(int asyncExecutorResetExpiredJobsInterval) {
        this.asyncExecutorResetExpiredJobsInterval = asyncExecutorResetExpiredJobsInterval;
        return this;
    }
    public ExecuteAsyncRunnableFactory getAsyncExecutorExecuteAsyncRunnableFactory() {
        return asyncExecutorExecuteAsyncRunnableFactory;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorExecuteAsyncRunnableFactory(ExecuteAsyncRunnableFactory asyncExecutorExecuteAsyncRunnableFactory) {
        this.asyncExecutorExecuteAsyncRunnableFactory = asyncExecutorExecuteAsyncRunnableFactory;
        return this;
    }
    public int getAsyncExecutorResetExpiredJobsPageSize() {
        return asyncExecutorResetExpiredJobsPageSize;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorResetExpiredJobsPageSize(int asyncExecutorResetExpiredJobsPageSize) {
        this.asyncExecutorResetExpiredJobsPageSize = asyncExecutorResetExpiredJobsPageSize;
        return this;
    }
    public boolean isAsyncExecutorIsMessageQueueMode() {
        return asyncExecutorMessageQueueMode;
    }
    public ProcessEngineConfigurationImpl setAsyncExecutorMessageQueueMode(boolean asyncExecutorMessageQueueMode) {
        this.asyncExecutorMessageQueueMode = asyncExecutorMessageQueueMode;
        return this;
    }
}
src/main/java/org/activiti/engine/impl/db/DbSqlSession.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,1274 @@
package org.activiti.engine.impl.db;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiOptimisticLockingException;
import org.activiti.engine.ActivitiWrongDbException;
import org.activiti.engine.impl.*;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.db.upgrade.DbUpgradeStep;
import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.persistence.cache.CachedEntity;
import org.activiti.engine.impl.persistence.cache.EntityCache;
import org.activiti.engine.impl.persistence.entity.Entity;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.PropertyEntity;
import org.activiti.engine.impl.util.IoUtil;
import org.activiti.engine.impl.util.ReflectUtil;
import org.apache.ibatis.session.SqlSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DbSqlSession implements Session {
    private static final Logger log = LoggerFactory.getLogger(DbSqlSession.class);
    protected static final Pattern CLEAN_VERSION_REGEX = Pattern.compile("\\d\\.\\d*");
    protected static final String LAST_V5_VERSION = "5.99.0.0";
    protected static final List<ActivitiVersion> ACTIVITI_VERSIONS = new ArrayList();
    protected SqlSession sqlSession;
    protected DbSqlSessionFactory dbSqlSessionFactory;
    protected EntityCache entityCache;
    protected Map<Class<? extends Entity>, Map<String, Entity>> insertedObjects = new HashMap();
    protected Map<Class<? extends Entity>, Map<String, Entity>> deletedObjects = new HashMap();
    protected Map<Class<? extends Entity>, List<BulkDeleteOperation>> bulkDeleteOperations = new HashMap();
    protected List<Entity> updatedObjects = new ArrayList();
    protected String connectionMetadataDefaultCatalog;
    protected String connectionMetadataDefaultSchema;
    public static String[] JDBC_METADATA_TABLE_TYPES;
    public DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory, EntityCache entityCache) {
        this.dbSqlSessionFactory = dbSqlSessionFactory;
        this.sqlSession = dbSqlSessionFactory.getSqlSessionFactory().openSession();
        this.entityCache = entityCache;
        this.connectionMetadataDefaultCatalog = dbSqlSessionFactory.getDatabaseCatalog();
        this.connectionMetadataDefaultSchema = dbSqlSessionFactory.getDatabaseSchema();
    }
    public DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory, EntityCache entityCache, Connection connection, String catalog, String schema) {
        this.dbSqlSessionFactory = dbSqlSessionFactory;
        this.sqlSession = dbSqlSessionFactory.getSqlSessionFactory().openSession(connection);
        this.entityCache = entityCache;
        this.connectionMetadataDefaultCatalog = catalog;
        this.connectionMetadataDefaultSchema = schema;
    }
    public void insert(Entity entity) {
        if (entity.getId() == null) {
            String id = this.dbSqlSessionFactory.getIdGenerator().getNextId();
            entity.setId(id);
        }
        Class<? extends Entity> clazz = entity.getClass();
        if (!this.insertedObjects.containsKey(clazz)) {
            this.insertedObjects.put(clazz, new LinkedHashMap());
        }
        ((Map)this.insertedObjects.get(clazz)).put(entity.getId(), entity);
        this.entityCache.put(entity, false);
        entity.setInserted(true);
    }
    public void update(Entity entity) {
        this.entityCache.put(entity, false);
        entity.setUpdated(true);
    }
    public int update(String statement, Object parameters) {
        String updateStatement = this.dbSqlSessionFactory.mapStatement(statement);
        return this.getSqlSession().update(updateStatement, parameters);
    }
    public void delete(String statement, Object parameter, Class<? extends Entity> entityClass) {
        if (!this.bulkDeleteOperations.containsKey(entityClass)) {
            this.bulkDeleteOperations.put(entityClass, new ArrayList(1));
        }
        ((List)this.bulkDeleteOperations.get(entityClass)).add(new BulkDeleteOperation(this.dbSqlSessionFactory.mapStatement(statement), parameter));
    }
    public void delete(Entity entity) {
        Class<? extends Entity> clazz = entity.getClass();
        if (!this.deletedObjects.containsKey(clazz)) {
            this.deletedObjects.put(clazz, new LinkedHashMap());
        }
        ((Map)this.deletedObjects.get(clazz)).put(entity.getId(), entity);
        entity.setDeleted(true);
    }
    public List selectList(String statement) {
        return this.selectList(statement, (Object)null, 0, Integer.MAX_VALUE);
    }
    public List selectList(String statement, Object parameter) {
        return this.selectList(statement, parameter, 0, Integer.MAX_VALUE);
    }
    public List selectList(String statement, Object parameter, boolean useCache) {
        return this.selectList(statement, parameter, 0, Integer.MAX_VALUE, useCache);
    }
    public List selectList(String statement, Object parameter, Page page) {
        return this.selectList(statement, parameter, page, true);
    }
    public List selectList(String statement, Object parameter, Page page, boolean useCache) {
        return page != null ? this.selectList(statement, parameter, page.getFirstResult(), page.getMaxResults(), useCache) : this.selectList(statement, parameter, 0, Integer.MAX_VALUE, useCache);
    }
    public List selectList(String statement, ListQueryParameterObject parameter, Page page) {
        return this.selectList(statement, parameter, page, true);
    }
    public List selectList(String statement, ListQueryParameterObject parameter, Page page, boolean useCache) {
        ListQueryParameterObject parameterToUse = parameter;
        if (parameterToUse == null) {
            parameterToUse = new ListQueryParameterObject();
        }
        if (page != null) {
            parameterToUse.setFirstResult(page.getFirstResult());
            parameterToUse.setMaxResults(page.getMaxResults());
        }
        return this.selectList(statement, parameterToUse, useCache);
    }
    public List selectList(String statement, Object parameter, int firstResult, int maxResults) {
        return this.selectList(statement, parameter, firstResult, maxResults, true);
    }
    public List selectList(String statement, Object parameter, int firstResult, int maxResults, boolean useCache) {
        return this.selectList(statement, new ListQueryParameterObject(parameter, firstResult, maxResults), useCache);
    }
    public List selectList(String statement, ListQueryParameterObject parameter) {
        return this.selectList(statement, parameter, true);
    }
    public List selectList(String statement, ListQueryParameterObject parameter, boolean useCache) {
        return this.selectListWithRawParameter(statement, parameter, parameter.getFirstResult(), parameter.getMaxResults(), useCache);
    }
    public List selectListWithRawParameter(String statement, Object parameter, int firstResult, int maxResults) {
        return this.selectListWithRawParameter(statement, parameter, firstResult, maxResults, true);
    }
    public List selectListWithRawParameter(String statement, Object parameter, int firstResult, int maxResults, boolean useCache) {
        statement = this.dbSqlSessionFactory.mapStatement(statement);
        if (firstResult != -1 && maxResults != -1) {
            List loadedObjects = this.sqlSession.selectList(statement, parameter);
            return useCache ? this.cacheLoadOrStore(loadedObjects) : loadedObjects;
        } else {
            return Collections.EMPTY_LIST;
        }
    }
    public List selectListWithRawParameterWithoutFilter(String statement, Object parameter, int firstResult, int maxResults) {
        statement = this.dbSqlSessionFactory.mapStatement(statement);
        return firstResult != -1 && maxResults != -1 ? this.sqlSession.selectList(statement, parameter) : Collections.EMPTY_LIST;
    }
    public Object selectOne(String statement, Object parameter) {
        statement = this.dbSqlSessionFactory.mapStatement(statement);
        Object result = this.sqlSession.selectOne(statement, parameter);
        if (result instanceof Entity) {
            Entity loadedObject = (Entity)result;
            result = this.cacheLoadOrStore(loadedObject);
        }
        return result;
    }
    public <T extends Entity> T selectById(Class<T> entityClass, String id) {
        return this.selectById(entityClass, id, true);
    }
    public <T extends Entity> T selectById(Class<T> entityClass, String id, boolean useCache) {
        T entity = null;
        if (useCache) {
            entity = (T) this.entityCache.findInCache(entityClass, id);
            if (entity != null) {
                return entity;
            }
        }
        String selectStatement = this.dbSqlSessionFactory.getSelectStatement(entityClass);
        selectStatement = this.dbSqlSessionFactory.mapStatement(selectStatement);
        entity = (T) this.sqlSession.selectOne(selectStatement, id);
        if (entity == null) {
            return null;
        } else {
            this.entityCache.put(entity, true);
            return entity;
        }
    }
    protected List cacheLoadOrStore(List<Object> loadedObjects) {
        if (loadedObjects.isEmpty()) {
            return loadedObjects;
        } else if (!(loadedObjects.get(0) instanceof Entity)) {
            return loadedObjects;
        } else {
            List<Entity> filteredObjects = new ArrayList(loadedObjects.size());
            Iterator var3 = loadedObjects.iterator();
            while(var3.hasNext()) {
                Object loadedObject = var3.next();
                Entity cachedEntity = this.cacheLoadOrStore((Entity)loadedObject);
                filteredObjects.add(cachedEntity);
            }
            return filteredObjects;
        }
    }
    protected Entity cacheLoadOrStore(Entity entity) {
        Entity cachedEntity = (Entity)this.entityCache.findInCache(entity.getClass(), entity.getId());
        if (cachedEntity != null) {
            return cachedEntity;
        } else {
            this.entityCache.put(entity, true);
            return entity;
        }
    }
    public void flush() {
        this.determineUpdatedObjects();
        this.removeUnnecessaryOperations();
        if (log.isDebugEnabled()) {
            this.debugFlush();
        }
        this.flushInserts();
        this.flushUpdates();
        this.flushDeletes();
    }
    protected void removeUnnecessaryOperations() {
        Iterator var1 = this.deletedObjects.keySet().iterator();
        while(var1.hasNext()) {
            Class<? extends Entity> entityClass = (Class)var1.next();
            Set<String> ids = new HashSet();
            Iterator<Entity> entitiesToDeleteIterator = ((Map)this.deletedObjects.get(entityClass)).values().iterator();
            while(entitiesToDeleteIterator.hasNext()) {
                Entity entityToDelete = (Entity)entitiesToDeleteIterator.next();
                if (!ids.contains(entityToDelete.getId())) {
                    ids.add(entityToDelete.getId());
                } else {
                    entitiesToDeleteIterator.remove();
                }
            }
            Iterator var7 = ids.iterator();
            while(var7.hasNext()) {
                String id = (String)var7.next();
                if (this.insertedObjects.containsKey(entityClass) && ((Map)this.insertedObjects.get(entityClass)).containsKey(id)) {
                    ((Map)this.insertedObjects.get(entityClass)).remove(id);
                    ((Map)this.deletedObjects.get(entityClass)).remove(id);
                }
            }
        }
    }
    public void determineUpdatedObjects() {
        this.updatedObjects = new ArrayList();
        Map<Class<?>, Map<String, CachedEntity>> cachedObjects = this.entityCache.getAllCachedEntities();
        Iterator var2 = cachedObjects.keySet().iterator();
        label34:
        while(var2.hasNext()) {
            Class<?> clazz = (Class)var2.next();
            Map<String, CachedEntity> classCache = (Map)cachedObjects.get(clazz);
            Iterator var5 = classCache.values().iterator();
            while(true) {
                CachedEntity cachedObject;
                Entity cachedEntity;
                do {
                    do {
                        if (!var5.hasNext()) {
                            continue label34;
                        }
                        cachedObject = (CachedEntity)var5.next();
                        cachedEntity = cachedObject.getEntity();
                    } while(this.isEntityInserted(cachedEntity));
                } while(!ExecutionEntity.class.isAssignableFrom(cachedEntity.getClass()) && this.isEntityToBeDeleted(cachedEntity));
                if (cachedObject.hasChanged()) {
                    this.updatedObjects.add(cachedEntity);
                }
            }
        }
    }
    protected void debugFlush() {
        log.debug("Flushing dbSqlSession");
        int nrOfInserts = 0;
        int nrOfUpdates = 0;
        int nrOfDeletes = 0;
        Iterator var4 = this.insertedObjects.values().iterator();
        Map deletedObjectMap;
        Iterator var6;
        Entity deletedObject;
        while(var4.hasNext()) {
            deletedObjectMap = (Map)var4.next();
            for(var6 = deletedObjectMap.values().iterator(); var6.hasNext(); ++nrOfInserts) {
                deletedObject = (Entity)var6.next();
                log.debug("  insert {}", deletedObject);
            }
        }
        for(var4 = this.updatedObjects.iterator(); var4.hasNext(); ++nrOfUpdates) {
            Entity updatedObject = (Entity)var4.next();
            log.debug("  update {}", updatedObject);
        }
        var4 = this.deletedObjects.values().iterator();
        while(var4.hasNext()) {
            deletedObjectMap = (Map)var4.next();
            for(var6 = deletedObjectMap.values().iterator(); var6.hasNext(); ++nrOfDeletes) {
                deletedObject = (Entity)var6.next();
                log.debug("  delete {} with id {}", deletedObject, deletedObject.getId());
            }
        }
        var4 = this.bulkDeleteOperations.values().iterator();
        while(var4.hasNext()) {
            Collection<BulkDeleteOperation> bulkDeleteOperationList = (Collection)var4.next();
            for(var6 = bulkDeleteOperationList.iterator(); var6.hasNext(); ++nrOfDeletes) {
                BulkDeleteOperation bulkDeleteOperation = (BulkDeleteOperation)var6.next();
                log.debug("  {}", bulkDeleteOperation);
            }
        }
        log.debug("flush summary: {} insert, {} update, {} delete.", new Object[]{nrOfInserts, nrOfUpdates, nrOfDeletes});
        log.debug("now executing flush...");
    }
    public boolean isEntityInserted(Entity entity) {
        return this.insertedObjects.containsKey(entity.getClass()) && ((Map)this.insertedObjects.get(entity.getClass())).containsKey(entity.getId());
    }
    public boolean isEntityToBeDeleted(Entity entity) {
        return this.deletedObjects.containsKey(entity.getClass()) && ((Map)this.deletedObjects.get(entity.getClass())).containsKey(entity.getId());
    }
    protected void flushInserts() {
        if (this.insertedObjects.size() != 0) {
            Iterator var1 = EntityDependencyOrder.INSERT_ORDER.iterator();
            Class entityClass;
            while(var1.hasNext()) {
                entityClass = (Class)var1.next();
                if (this.insertedObjects.containsKey(entityClass)) {
                    this.flushInsertEntities(entityClass, ((Map)this.insertedObjects.get(entityClass)).values());
                    this.insertedObjects.remove(entityClass);
                }
            }
            if (this.insertedObjects.size() > 0) {
                var1 = this.insertedObjects.keySet().iterator();
                while(var1.hasNext()) {
                    entityClass = (Class)var1.next();
                    this.flushInsertEntities(entityClass, ((Map)this.insertedObjects.get(entityClass)).values());
                }
            }
            this.insertedObjects.clear();
        }
    }
    protected void flushInsertEntities(Class<? extends Entity> entityClass, Collection<Entity> entitiesToInsert) {
        if (entitiesToInsert.size() == 1) {
            this.flushRegularInsert((Entity)entitiesToInsert.iterator().next(), entityClass);
        } else if (Boolean.FALSE.equals(this.dbSqlSessionFactory.isBulkInsertable(entityClass))) {
            Iterator var3 = entitiesToInsert.iterator();
            while(var3.hasNext()) {
                Entity entity = (Entity)var3.next();
                this.flushRegularInsert(entity, entityClass);
            }
        } else {
            this.flushBulkInsert(entitiesToInsert, entityClass);
        }
    }
    protected Collection<Entity> orderExecutionEntities(Map<String, Entity> executionEntities, boolean parentBeforeChildExecution) {
        List<Entity> result = new ArrayList(executionEntities.size());
        Map<String, String> childToParentExecutionMapping = new HashMap();
        Map<String, List<ExecutionEntity>> parentToChildrenMapping = new HashMap();
        Collection<Entity> executionCollection = executionEntities.values();
        Iterator executionIterator;
        ExecutionEntity currentExecutionEntity;
        String executionId;
        String parentId;
        for(executionIterator = executionCollection.iterator(); executionIterator.hasNext(); ((List)parentToChildrenMapping.get(parentId)).add(currentExecutionEntity)) {
            currentExecutionEntity = (ExecutionEntity)executionIterator.next();
            parentId = currentExecutionEntity.getParentId();
            executionId = currentExecutionEntity.getSuperExecutionId();
            parentId = parentId != null ? parentId : executionId;
            childToParentExecutionMapping.put(currentExecutionEntity.getId(), parentId);
            if (!parentToChildrenMapping.containsKey(parentId)) {
                parentToChildrenMapping.put(parentId, new ArrayList());
            }
        }
        Set<String> handledExecutionIds = new HashSet(executionEntities.size());
        executionIterator = executionCollection.iterator();
        while(true) {
            do {
                if (!executionIterator.hasNext()) {
                    return result;
                }
                currentExecutionEntity = (ExecutionEntity)executionIterator.next();
                executionId = currentExecutionEntity.getId();
            } while(handledExecutionIds.contains(executionId));
            parentId = (String)childToParentExecutionMapping.get(executionId);
            if (parentId != null) {
                while(parentId != null) {
                    String newParentId = (String)childToParentExecutionMapping.get(parentId);
                    if (newParentId == null) {
                        break;
                    }
                    parentId = newParentId;
                }
            }
            if (parentId == null) {
                parentId = executionId;
            }
            if (executionEntities.containsKey(parentId) && !handledExecutionIds.contains(parentId)) {
                handledExecutionIds.add(parentId);
                if (parentBeforeChildExecution) {
                    result.add(executionEntities.get(parentId));
                } else {
                    result.add(0, executionEntities.get(parentId));
                }
            }
            this.collectChildExecutionsForInsertion(result, parentToChildrenMapping, handledExecutionIds, parentId, parentBeforeChildExecution);
        }
    }
    protected void collectChildExecutionsForInsertion(List<Entity> result, Map<String, List<ExecutionEntity>> parentToChildrenMapping, Set<String> handledExecutionIds, String parentId, boolean parentBeforeChildExecution) {
        List<ExecutionEntity> childExecutionEntities = (List)parentToChildrenMapping.get(parentId);
        if (childExecutionEntities != null) {
            ExecutionEntity childExecutionEntity;
            for(Iterator var7 = childExecutionEntities.iterator(); var7.hasNext(); this.collectChildExecutionsForInsertion(result, parentToChildrenMapping, handledExecutionIds, childExecutionEntity.getId(), parentBeforeChildExecution)) {
                childExecutionEntity = (ExecutionEntity)var7.next();
                handledExecutionIds.add(childExecutionEntity.getId());
                if (parentBeforeChildExecution) {
                    result.add(childExecutionEntity);
                } else {
                    result.add(0, childExecutionEntity);
                }
            }
        }
    }
    protected void flushRegularInsert(Entity entity, Class<? extends Entity> clazz) {
        String insertStatement = this.dbSqlSessionFactory.getInsertStatement(entity);
        insertStatement = this.dbSqlSessionFactory.mapStatement(insertStatement);
        if (insertStatement == null) {
            throw new ActivitiException("no insert statement for " + entity.getClass() + " in the ibatis mapping files");
        } else {
            log.debug("inserting: {}", entity);
            this.sqlSession.insert(insertStatement, entity);
            if (entity instanceof HasRevision) {
                this.incrementRevision(entity);
            }
        }
    }
    protected void flushBulkInsert(Collection<Entity> entities, Class<? extends Entity> clazz) {
        String insertStatement = this.dbSqlSessionFactory.getBulkInsertStatement(clazz);
        insertStatement = this.dbSqlSessionFactory.mapStatement(insertStatement);
        if (insertStatement == null) {
            throw new ActivitiException("no insert statement for " + ((Entity)entities.iterator().next()).getClass() + " in the ibatis mapping files");
        } else {
            Iterator<Entity> entityIterator = entities.iterator();
            Boolean hasRevision = null;
            while(entityIterator.hasNext()) {
                List<Entity> subList = new ArrayList();
                for(int index = 0; entityIterator.hasNext() && index < this.dbSqlSessionFactory.getMaxNrOfStatementsInBulkInsert(); ++index) {
                    Entity entity = (Entity)entityIterator.next();
                    subList.add(entity);
                    if (hasRevision == null) {
                        hasRevision = entity instanceof HasRevision;
                    }
                }
                this.sqlSession.insert(insertStatement, subList);
            }
            if (hasRevision != null && hasRevision) {
                entityIterator = entities.iterator();
                while(entityIterator.hasNext()) {
                    this.incrementRevision((Entity)entityIterator.next());
                }
            }
        }
    }
    protected void incrementRevision(Entity insertedObject) {
        HasRevision revisionEntity = (HasRevision)insertedObject;
        if (revisionEntity.getRevision() == 0) {
            revisionEntity.setRevision(revisionEntity.getRevisionNext());
        }
    }
    protected void flushUpdates() {
        Iterator var1 = this.updatedObjects.iterator();
        while(var1.hasNext()) {
            Entity updatedObject = (Entity)var1.next();
            String updateStatement = this.dbSqlSessionFactory.getUpdateStatement(updatedObject);
            updateStatement = this.dbSqlSessionFactory.mapStatement(updateStatement);
            if (updateStatement == null) {
                throw new ActivitiException("no update statement for " + updatedObject.getClass() + " in the ibatis mapping files");
            }
            log.debug("updating: {}", updatedObject);
            int updatedRecords = this.sqlSession.update(updateStatement, updatedObject);
            if (updatedRecords == 0) {
                throw new ActivitiOptimisticLockingException(updatedObject + " was updated by another transaction concurrently");
            }
            if (updatedObject instanceof HasRevision) {
                ((HasRevision)updatedObject).setRevision(((HasRevision)updatedObject).getRevisionNext());
            }
        }
        this.updatedObjects.clear();
    }
    protected void flushDeletes() {
        if (this.deletedObjects.size() != 0 || this.bulkDeleteOperations.size() != 0) {
            Iterator var1;
            Class entityClass;
            for(var1 = EntityDependencyOrder.DELETE_ORDER.iterator(); var1.hasNext(); this.flushBulkDeletes(entityClass)) {
                entityClass = (Class)var1.next();
                if (this.deletedObjects.containsKey(entityClass)) {
                    this.flushDeleteEntities(entityClass, ((Map)this.deletedObjects.get(entityClass)).values());
                    this.deletedObjects.remove(entityClass);
                }
            }
            if (this.deletedObjects.size() > 0) {
                var1 = this.deletedObjects.keySet().iterator();
                while(var1.hasNext()) {
                    entityClass = (Class)var1.next();
                    this.flushDeleteEntities(entityClass, ((Map)this.deletedObjects.get(entityClass)).values());
                    this.flushBulkDeletes(entityClass);
                }
            }
            this.deletedObjects.clear();
        }
    }
    protected void flushBulkDeletes(Class<? extends Entity> entityClass) {
        if (this.bulkDeleteOperations.containsKey(entityClass)) {
            Iterator var2 = ((List)this.bulkDeleteOperations.get(entityClass)).iterator();
            while(var2.hasNext()) {
                BulkDeleteOperation bulkDeleteOperation = (BulkDeleteOperation)var2.next();
                bulkDeleteOperation.execute(this.sqlSession);
            }
        }
    }
    protected void flushDeleteEntities(Class<? extends Entity> entityClass, Collection<Entity> entitiesToDelete) {
        Iterator var3 = entitiesToDelete.iterator();
        while(var3.hasNext()) {
            Entity entity = (Entity)var3.next();
            String deleteStatement = this.dbSqlSessionFactory.getDeleteStatement(entity.getClass());
            deleteStatement = this.dbSqlSessionFactory.mapStatement(deleteStatement);
            if (deleteStatement == null) {
                throw new ActivitiException("no delete statement for " + entity.getClass() + " in the ibatis mapping files");
            }
            if (entity instanceof HasRevision) {
                int nrOfRowsDeleted = this.sqlSession.delete(deleteStatement, entity);
                if (nrOfRowsDeleted == 0) {
                    throw new ActivitiOptimisticLockingException(entity + " was updated by another transaction concurrently");
                }
            } else {
                this.sqlSession.delete(deleteStatement, entity);
            }
        }
    }
    public void close() {
        this.sqlSession.close();
    }
    public void commit() {
        this.sqlSession.commit();
    }
    public void rollback() {
        this.sqlSession.rollback();
    }
    public void dbSchemaCheckVersion() {
        try {
            String dbVersion = this.getDbVersion();
            if (!"6.0.0.4".equals(dbVersion)) {
                throw new ActivitiWrongDbException("6.0.0.4", dbVersion);
            }
            String errorMessage = null;
            if (!this.isEngineTablePresent()) {
                errorMessage = this.addMissingComponent(errorMessage, "engine");
            }
            if (this.dbSqlSessionFactory.isDbHistoryUsed() && !this.isHistoryTablePresent()) {
                errorMessage = this.addMissingComponent(errorMessage, "history");
            }
            if (this.dbSqlSessionFactory.isDbIdentityUsed() && !this.isIdentityTablePresent()) {
                errorMessage = this.addMissingComponent(errorMessage, "identity");
            }
            if (errorMessage != null) {
                throw new ActivitiException("Activiti database problem: " + errorMessage);
            }
        } catch (Exception var3) {
            Exception e = var3;
            if (this.isMissingTablesException(e)) {
                throw new ActivitiException("no activiti tables in db. set <property name=\"databaseSchemaUpdate\" to value=\"true\" or value=\"create-drop\" (use create-drop for testing only!) in bean processEngineConfiguration in activiti.cfg.xml for automatic schema creation", e);
            }
            if (e instanceof RuntimeException) {
                throw (RuntimeException)e;
            }
            throw new ActivitiException("couldn't get db schema version", e);
        }
        log.debug("activiti db schema check successful");
    }
    protected String addMissingComponent(String missingComponents, String component) {
        return missingComponents == null ? "Tables missing for component(s) " + component : missingComponents + ", " + component;
    }
    protected String getDbVersion() {
        String selectSchemaVersionStatement = this.dbSqlSessionFactory.mapStatement("selectDbSchemaVersion");
        return (String)this.sqlSession.selectOne(selectSchemaVersionStatement);
    }
    public void dbSchemaCreate() {
        if (this.isEngineTablePresent()) {
            String dbVersion = this.getDbVersion();
            if (!"6.0.0.4".equals(dbVersion)) {
                throw new ActivitiWrongDbException("6.0.0.4", dbVersion);
            }
        } else {
            this.dbSchemaCreateEngine();
        }
        if (this.dbSqlSessionFactory.isDbHistoryUsed()) {
            this.dbSchemaCreateHistory();
        }
        if (this.dbSqlSessionFactory.isDbIdentityUsed()) {
            this.dbSchemaCreateIdentity();
        }
    }
    protected void dbSchemaCreateIdentity() {
        this.executeMandatorySchemaResource("create", "identity");
    }
    protected void dbSchemaCreateHistory() {
        this.executeMandatorySchemaResource("create", "history");
    }
    protected void dbSchemaCreateEngine() {
        this.executeMandatorySchemaResource("create", "engine");
    }
    public void dbSchemaDrop() {
        this.executeMandatorySchemaResource("drop", "engine");
        if (this.dbSqlSessionFactory.isDbHistoryUsed()) {
            this.executeMandatorySchemaResource("drop", "history");
        }
        if (this.dbSqlSessionFactory.isDbIdentityUsed()) {
            this.executeMandatorySchemaResource("drop", "identity");
        }
    }
    public void dbSchemaPrune() {
        if (this.isHistoryTablePresent() && !this.dbSqlSessionFactory.isDbHistoryUsed()) {
            this.executeMandatorySchemaResource("drop", "history");
        }
        if (this.isIdentityTablePresent() && this.dbSqlSessionFactory.isDbIdentityUsed()) {
            this.executeMandatorySchemaResource("drop", "identity");
        }
    }
    public void executeMandatorySchemaResource(String operation, String component) {
        this.executeSchemaResource(operation, component, this.getResourceForDbOperation(operation, operation, component), false);
    }
    public String dbSchemaUpdate() {
        String feedback = null;
        boolean isUpgradeNeeded = false;
        int matchingVersionIndex = -1;
        if (this.isEngineTablePresent()) {
            PropertyEntity dbVersionProperty = (PropertyEntity)this.selectById(PropertyEntity.class, "schema.version");
            String dbVersion = dbVersionProperty.getValue();
            matchingVersionIndex = this.findMatchingVersionIndex(dbVersion);
            if (matchingVersionIndex < 0 && dbVersion != null && dbVersion.startsWith("5.")) {
                matchingVersionIndex = this.findMatchingVersionIndex("5.99.0.0");
            }
            if (matchingVersionIndex < 0) {
                throw new ActivitiException("Could not update Activiti database schema: unknown version from database: '" + dbVersion + "'");
            }
            isUpgradeNeeded = matchingVersionIndex != ACTIVITI_VERSIONS.size() - 1;
            if (isUpgradeNeeded) {
                dbVersionProperty.setValue("6.0.0.4");
                PropertyEntity dbHistoryProperty;
                if ("5.0".equals(dbVersion)) {
                    dbHistoryProperty = (PropertyEntity)Context.getCommandContext().getPropertyEntityManager().create();
                    dbHistoryProperty.setName("schema.history");
                    dbHistoryProperty.setValue("create(5.0)");
                    this.insert(dbHistoryProperty);
                } else {
                    dbHistoryProperty = (PropertyEntity)this.selectById(PropertyEntity.class, "schema.history");
                }
                String dbHistoryValue = dbHistoryProperty.getValue() + " upgrade(" + dbVersion + "->" + "6.0.0.4" + ")";
                dbHistoryProperty.setValue(dbHistoryValue);
                this.dbSchemaUpgrade("engine", matchingVersionIndex);
                feedback = "upgraded Activiti from " + dbVersion + " to " + "6.0.0.4";
            }
        } else {
            this.dbSchemaCreateEngine();
        }
        if (this.isHistoryTablePresent()) {
            if (isUpgradeNeeded) {
                this.dbSchemaUpgrade("history", matchingVersionIndex);
            }
        } else if (this.dbSqlSessionFactory.isDbHistoryUsed()) {
            this.dbSchemaCreateHistory();
        }
        if (this.isIdentityTablePresent()) {
            if (isUpgradeNeeded) {
                this.dbSchemaUpgrade("identity", matchingVersionIndex);
            }
        } else if (this.dbSqlSessionFactory.isDbIdentityUsed()) {
            this.dbSchemaCreateIdentity();
        }
        return feedback;
    }
    protected int findMatchingVersionIndex(String dbVersion) {
        int index = 0;
        int matchingVersionIndex = -1;
        while(matchingVersionIndex < 0 && index < ACTIVITI_VERSIONS.size()) {
            if (((ActivitiVersion)ACTIVITI_VERSIONS.get(index)).matches(dbVersion)) {
                matchingVersionIndex = index;
            } else {
                ++index;
            }
        }
        return matchingVersionIndex;
    }
    public boolean isEngineTablePresent() {
        return this.isTablePresent("ACT_RU_EXECUTION");
    }
    public boolean isHistoryTablePresent() {
        return this.isTablePresent("ACT_HI_PROCINST");
    }
    public boolean isIdentityTablePresent() {
        return this.isTablePresent("ACT_ID_USER");
    }
    public boolean isTablePresent(String tableName) {
        if (!this.dbSqlSessionFactory.isTablePrefixIsSchema()) {
            tableName = this.prependDatabaseTablePrefix(tableName);
        }
        Connection connection = null;
        try {
            connection = this.sqlSession.getConnection();
            DatabaseMetaData databaseMetaData = connection.getMetaData();
            ResultSet tables = null;
            String catalog = this.connectionMetadataDefaultCatalog;
            if (this.dbSqlSessionFactory.getDatabaseCatalog() != null && this.dbSqlSessionFactory.getDatabaseCatalog().length() > 0) {
                catalog = this.dbSqlSessionFactory.getDatabaseCatalog();
            }
            String schema = this.connectionMetadataDefaultSchema;
            if (this.dbSqlSessionFactory.getDatabaseSchema() != null && this.dbSqlSessionFactory.getDatabaseSchema().length() > 0) {
                schema = this.dbSqlSessionFactory.getDatabaseSchema();
            }
            String databaseType = this.dbSqlSessionFactory.getDatabaseType();
            if ("postgres".equals(databaseType)) {
                tableName = tableName.toLowerCase();
            }
            if (schema != null && "oracle".equals(databaseType)) {
                schema = schema.toUpperCase();
            }
            if (catalog != null && catalog.length() == 0) {
                catalog = null;
            }
            boolean var8;
            try {
                tables = databaseMetaData.getTables(catalog, schema, tableName, JDBC_METADATA_TABLE_TYPES);
                var8 = tables.next();
            } finally {
                try {
                    tables.close();
                } catch (Exception var16) {
                    Exception e = var16;
                    log.error("Error closing meta data tables", e);
                }
            }
            return var8;
        } catch (Exception var18) {
            Exception e = var18;
            throw new ActivitiException("couldn't check if tables are already present using metadata: " + e.getMessage(), e);
        }
    }
    protected boolean isUpgradeNeeded(String versionInDatabase) {
        if ("6.0.0.4".equals(versionInDatabase)) {
            return false;
        } else {
            String cleanDbVersion = this.getCleanVersion(versionInDatabase);
            String[] cleanDbVersionSplitted = cleanDbVersion.split("\\.");
            int dbMajorVersion = Integer.valueOf(cleanDbVersionSplitted[0]);
            int dbMinorVersion = Integer.valueOf(cleanDbVersionSplitted[1]);
            String cleanEngineVersion = this.getCleanVersion("6.0.0.4");
            String[] cleanEngineVersionSplitted = cleanEngineVersion.split("\\.");
            int engineMajorVersion = Integer.valueOf(cleanEngineVersionSplitted[0]);
            int engineMinorVersion = Integer.valueOf(cleanEngineVersionSplitted[1]);
            if (dbMajorVersion <= engineMajorVersion && (dbMajorVersion > engineMajorVersion || dbMinorVersion <= engineMinorVersion)) {
                if (cleanDbVersion.compareTo(cleanEngineVersion) == 0) {
                    log.warn("Engine-version is the same, but not an exact match: {} vs. {}. Not performing database-upgrade.", versionInDatabase, "6.0.0.4");
                    return false;
                } else {
                    return true;
                }
            } else {
                throw new ActivitiException("Version of activiti database (" + versionInDatabase + ") is more recent than the engine (" + "6.0.0.4" + ")");
            }
        }
    }
    protected String getCleanVersion(String versionString) {
        Matcher matcher = CLEAN_VERSION_REGEX.matcher(versionString);
        if (!matcher.find()) {
            throw new ActivitiException("Illegal format for version: " + versionString);
        } else {
            String cleanString = matcher.group();
            try {
                Double.parseDouble(cleanString);
                return cleanString;
            } catch (NumberFormatException var5) {
                throw new ActivitiException("Illegal format for version: " + versionString);
            }
        }
    }
    protected String prependDatabaseTablePrefix(String tableName) {
        return this.dbSqlSessionFactory.getDatabaseTablePrefix() + tableName;
    }
    protected void dbSchemaUpgrade(String component, int currentDatabaseVersionsIndex) {
        ActivitiVersion activitiVersion = (ActivitiVersion)ACTIVITI_VERSIONS.get(currentDatabaseVersionsIndex);
        String dbVersion = activitiVersion.getMainVersion();
        log.info("upgrading activiti {} schema from {} to {}", new Object[]{component, dbVersion, "6.0.0.4"});
        for(int i = currentDatabaseVersionsIndex + 1; i < ACTIVITI_VERSIONS.size(); ++i) {
            String nextVersion = ((ActivitiVersion)ACTIVITI_VERSIONS.get(i)).getMainVersion();
            if (nextVersion.endsWith("-SNAPSHOT")) {
                nextVersion = nextVersion.substring(0, nextVersion.length() - "-SNAPSHOT".length());
            }
            dbVersion = dbVersion.replace(".", "");
            nextVersion = nextVersion.replace(".", "");
            log.info("Upgrade needed: {} -> {}. Looking for schema update resource for component '{}'", new Object[]{dbVersion, nextVersion, component});
            this.executeSchemaResource("upgrade", component, this.getResourceForDbOperation("upgrade", "upgradestep." + dbVersion + ".to." + nextVersion, component), true);
            dbVersion = nextVersion;
        }
    }
    public String getResourceForDbOperation(String directory, String operation, String component) {
        String databaseType = this.dbSqlSessionFactory.getDatabaseType();
        // å½“databaseType ä¸ºdm时,借用oracle的sql文件来代替执行
        if (ProcessEngineConfigurationImpl.DATABASE_TYPE_DM.equals(databaseType)) {
            databaseType = ProcessEngineConfigurationImpl.DATABASE_TYPE_ORACLE;
        }
        return "org/activiti/db/" + directory + "/activiti." + databaseType + "." + operation + "." + component + ".sql";
    }
    public void executeSchemaResource(String operation, String component, String resourceName, boolean isOptional) {
        InputStream inputStream = null;
        try {
            inputStream = ReflectUtil.getResourceAsStream(resourceName);
            if (inputStream == null) {
                if (!isOptional) {
                    throw new ActivitiException("resource '" + resourceName + "' is not available");
                }
                log.info("no schema resource {} for {}", resourceName, operation);
            } else {
                this.executeSchemaResource(operation, component, resourceName, inputStream);
            }
        } finally {
            IoUtil.closeSilently(inputStream);
        }
    }
    private void executeSchemaResource(String operation, String component, String resourceName, InputStream inputStream) {
        log.info("performing {} on {} with resource {}", new Object[]{operation, component, resourceName});
        String sqlStatement = null;
        String exceptionSqlStatement = null;
        try {
            Connection connection = this.sqlSession.getConnection();
            Exception exception = null;
            byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);
            String ddlStatements = new String(bytes);
            try {
                if (this.isMysql()) {
                    DatabaseMetaData databaseMetaData = connection.getMetaData();
                    int majorVersion = databaseMetaData.getDatabaseMajorVersion();
                    int minorVersion = databaseMetaData.getDatabaseMinorVersion();
                    log.info("Found MySQL: majorVersion=" + majorVersion + " minorVersion=" + minorVersion);
                    if (majorVersion <= 5 && minorVersion < 6) {
                        ddlStatements = this.updateDdlForMySqlVersionLowerThan56(ddlStatements);
                    }
                }
            } catch (Exception var26) {
                Exception e = var26;
                log.info("Could not get database metadata", e);
            }
            BufferedReader reader = new BufferedReader(new StringReader(ddlStatements));
            String line = this.readNextTrimmedLine(reader);
            for(boolean inOraclePlsqlBlock = false; line != null; line = this.readNextTrimmedLine(reader)) {
                if (line.startsWith("# ")) {
                    log.debug(line.substring(2));
                } else if (line.startsWith("-- ")) {
                    log.debug(line.substring(3));
                } else {
                    Exception e;
                    if (line.startsWith("execute java ")) {
                        String upgradestepClassName = line.substring(13).trim();
                        e = null;
                        DbUpgradeStep dbUpgradeStep;
                        try {
                            dbUpgradeStep = (DbUpgradeStep)ReflectUtil.instantiate(upgradestepClassName);
                        } catch (ActivitiException var25) {
                            ActivitiException ex = var25;
                            throw new ActivitiException("database update java class '" + upgradestepClassName + "' can't be instantiated: " + ex.getMessage(), ex);
                        }
                        try {
                            log.debug("executing upgrade step java class {}", upgradestepClassName);
                            dbUpgradeStep.execute(this);
                        } catch (Exception var24) {
                            Exception ex = var24;
                            throw new ActivitiException("error while executing database update java class '" + upgradestepClassName + "': " + ex.getMessage(), ex);
                        }
                    } else if (line.length() > 0) {
                        if (this.isOracle() && line.startsWith("begin")) {
                            inOraclePlsqlBlock = true;
                            sqlStatement = this.addSqlStatementPiece(sqlStatement, line);
                        } else if ((!line.endsWith(";") || inOraclePlsqlBlock) && (!line.startsWith("/") || !inOraclePlsqlBlock)) {
                            sqlStatement = this.addSqlStatementPiece(sqlStatement, line);
                        } else {
                            if (inOraclePlsqlBlock) {
                                inOraclePlsqlBlock = false;
                            } else {
                                sqlStatement = this.addSqlStatementPiece(sqlStatement, line.substring(0, line.length() - 1));
                            }
                            Statement jdbcStatement = connection.createStatement();
                            try {
                                log.debug("SQL: {}", sqlStatement);
                                jdbcStatement.execute(sqlStatement);
                                jdbcStatement.close();
                            } catch (Exception var27) {
                                e = var27;
                                if (exception == null) {
                                    exception = e;
                                }
                                log.error("problem during schema {}, statement {}", new Object[]{operation, sqlStatement, e});
                            } finally {
                                sqlStatement = null;
                            }
                        }
                    }
                }
            }
            if (exception != null) {
                throw exception;
            } else {
                log.debug("activiti db schema {} for component {} successful", operation, component);
            }
        } catch (Exception var29) {
            Exception e = var29;
            throw new ActivitiException("couldn't " + operation + " db schema: " + exceptionSqlStatement, e);
        }
    }
    protected String updateDdlForMySqlVersionLowerThan56(String ddlStatements) {
        return ddlStatements.replace("timestamp(3)", "timestamp").replace("datetime(3)", "datetime").replace("TIMESTAMP(3)", "TIMESTAMP").replace("DATETIME(3)", "DATETIME");
    }
    protected String addSqlStatementPiece(String sqlStatement, String line) {
        return sqlStatement == null ? line : sqlStatement + " \n" + line;
    }
    protected String readNextTrimmedLine(BufferedReader reader) throws IOException {
        String line = reader.readLine();
        if (line != null) {
            line = line.trim();
        }
        return line;
    }
    protected boolean isMissingTablesException(Exception e) {
        String exceptionMessage = e.getMessage();
        if (e.getMessage() != null) {
            if (exceptionMessage.indexOf("Table") != -1 && exceptionMessage.indexOf("not found") != -1) {
                return true;
            }
            if ((exceptionMessage.indexOf("Table") != -1 || exceptionMessage.indexOf("table") != -1) && exceptionMessage.indexOf("doesn't exist") != -1) {
                return true;
            }
            if ((exceptionMessage.indexOf("relation") != -1 || exceptionMessage.indexOf("table") != -1) && exceptionMessage.indexOf("does not exist") != -1) {
                return true;
            }
        }
        return false;
    }
    public void performSchemaOperationsProcessEngineBuild() {
        String databaseSchemaUpdate = Context.getProcessEngineConfiguration().getDatabaseSchemaUpdate();
        log.debug("Executing performSchemaOperationsProcessEngineBuild with setting " + databaseSchemaUpdate);
        if ("drop-create".equals(databaseSchemaUpdate)) {
            try {
                this.dbSchemaDrop();
            } catch (RuntimeException var3) {
            }
        }
        if (!"create-drop".equals(databaseSchemaUpdate) && !"drop-create".equals(databaseSchemaUpdate) && !"create".equals(databaseSchemaUpdate)) {
            if ("false".equals(databaseSchemaUpdate)) {
                this.dbSchemaCheckVersion();
            } else if ("true".equals(databaseSchemaUpdate)) {
                this.dbSchemaUpdate();
            }
        } else {
            this.dbSchemaCreate();
        }
    }
    public void performSchemaOperationsProcessEngineClose() {
        String databaseSchemaUpdate = Context.getProcessEngineConfiguration().getDatabaseSchemaUpdate();
        if ("create-drop".equals(databaseSchemaUpdate)) {
            this.dbSchemaDrop();
        }
    }
    public <T> T getCustomMapper(Class<T> type) {
        return this.sqlSession.getMapper(type);
    }
    public boolean isMysql() {
        return this.dbSqlSessionFactory.getDatabaseType().equals("mysql");
    }
    public boolean isOracle() {
        return this.dbSqlSessionFactory.getDatabaseType().equals("oracle");
    }
    public DeploymentQueryImpl createDeploymentQuery() {
        return new DeploymentQueryImpl();
    }
    public ModelQueryImpl createModelQueryImpl() {
        return new ModelQueryImpl();
    }
    public ProcessDefinitionQueryImpl createProcessDefinitionQuery() {
        return new ProcessDefinitionQueryImpl();
    }
    public ProcessInstanceQueryImpl createProcessInstanceQuery() {
        return new ProcessInstanceQueryImpl();
    }
    public ExecutionQueryImpl createExecutionQuery() {
        return new ExecutionQueryImpl();
    }
    public TaskQueryImpl createTaskQuery() {
        return new TaskQueryImpl();
    }
    public JobQueryImpl createJobQuery() {
        return new JobQueryImpl();
    }
    public HistoricProcessInstanceQueryImpl createHistoricProcessInstanceQuery() {
        return new HistoricProcessInstanceQueryImpl();
    }
    public HistoricActivityInstanceQueryImpl createHistoricActivityInstanceQuery() {
        return new HistoricActivityInstanceQueryImpl();
    }
    public HistoricTaskInstanceQueryImpl createHistoricTaskInstanceQuery() {
        return new HistoricTaskInstanceQueryImpl();
    }
    public HistoricDetailQueryImpl createHistoricDetailQuery() {
        return new HistoricDetailQueryImpl();
    }
    public HistoricVariableInstanceQueryImpl createHistoricVariableInstanceQuery() {
        return new HistoricVariableInstanceQueryImpl();
    }
    public UserQueryImpl createUserQuery() {
        return new UserQueryImpl();
    }
    public GroupQueryImpl createGroupQuery() {
        return new GroupQueryImpl();
    }
    public SqlSession getSqlSession() {
        return this.sqlSession;
    }
    public DbSqlSessionFactory getDbSqlSessionFactory() {
        return this.dbSqlSessionFactory;
    }
    static {
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.7"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.8"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.9"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.10"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.11"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.12", Arrays.asList("5.12.1", "5.12T")));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.13"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.14"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.15"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.15.1"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.16"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.16.1"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.16.2-SNAPSHOT"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.16.2"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.16.3.0"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.16.4.0"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.17.0.0"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.17.0.1"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.17.0.2"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.18.0.0"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.18.0.1"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.20.0.0"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.20.0.1"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.20.0.2"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.21.0.0"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.22.0.0"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("5.99.0.0"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("6.0.0.0"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("6.0.0.1"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("6.0.0.2"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("6.0.0.3"));
        ACTIVITI_VERSIONS.add(new ActivitiVersion("6.0.0.4"));
        JDBC_METADATA_TABLE_TYPES = new String[]{"TABLE"};
    }
}
src/main/java/org/activiti/engine/impl/db/DbSqlSessionFactory.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,301 @@
package org.activiti.engine.impl.db;
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.cfg.IdGenerator;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.persistence.entity.Entity;
import org.activiti.engine.impl.persistence.entity.EventLogEntryEntityImpl;
import org.apache.ibatis.session.SqlSessionFactory;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class DbSqlSessionFactory implements SessionFactory {
    protected static final Map<String, Map<String, String>> databaseSpecificStatements = new HashMap();
    protected static Map<Class<? extends Entity>, Boolean> bulkInsertableMap;
    protected String databaseType;
    protected String databaseTablePrefix = "";
    private boolean tablePrefixIsSchema;
    protected String databaseCatalog;
    protected String databaseSchema;
    protected SqlSessionFactory sqlSessionFactory;
    protected IdGenerator idGenerator;
    protected Map<String, String> statementMappings;
    protected Map<Class<?>, String> insertStatements = new ConcurrentHashMap();
    protected Map<Class<?>, String> bulkInsertStatements = new ConcurrentHashMap();
    protected Map<Class<?>, String> updateStatements = new ConcurrentHashMap();
    protected Map<Class<?>, String> deleteStatements = new ConcurrentHashMap();
    protected Map<Class<?>, String> bulkDeleteStatements = new ConcurrentHashMap();
    protected Map<Class<?>, String> selectStatements = new ConcurrentHashMap();
    protected boolean isDbIdentityUsed = true;
    protected boolean isDbHistoryUsed = true;
    protected int maxNrOfStatementsInBulkInsert = 100;
    public DbSqlSessionFactory() {
    }
    public Class<?> getSessionType() {
        return DbSqlSession.class;
    }
    public Session openSession(CommandContext commandContext) {
        DbSqlSession dbSqlSession = new DbSqlSession(this, commandContext.getEntityCache());
        SQLException e;
        if (this.getDatabaseSchema() != null && this.getDatabaseSchema().length() > 0) {
            try {
                dbSqlSession.getSqlSession().getConnection().setSchema(this.getDatabaseSchema());
            } catch (SQLException var5) {
                e = var5;
                throw new ActivitiException("Could not set database schema on connection", e);
            }
        }
        if (this.getDatabaseCatalog() != null && this.getDatabaseCatalog().length() > 0) {
            try {
                dbSqlSession.getSqlSession().getConnection().setCatalog(this.getDatabaseCatalog());
            } catch (SQLException var4) {
                e = var4;
                throw new ActivitiException("Could not set database catalog on connection", e);
            }
        }
        return dbSqlSession;
    }
    public String getInsertStatement(Entity object) {
        return this.getStatement(object.getClass(), this.insertStatements, "insert");
    }
    public String getInsertStatement(Class<? extends Entity> clazz) {
        return this.getStatement(clazz, this.insertStatements, "insert");
    }
    public String getBulkInsertStatement(Class clazz) {
        return this.getStatement(clazz, this.bulkInsertStatements, "bulkInsert");
    }
    public String getUpdateStatement(Entity object) {
        return this.getStatement(object.getClass(), this.updateStatements, "update");
    }
    public String getDeleteStatement(Class<?> entityClass) {
        return this.getStatement(entityClass, this.deleteStatements, "delete");
    }
    public String getBulkDeleteStatement(Class<?> entityClass) {
        return this.getStatement(entityClass, this.bulkDeleteStatements, "bulkDelete");
    }
    public String getSelectStatement(Class<?> entityClass) {
        return this.getStatement(entityClass, this.selectStatements, "select");
    }
    private String getStatement(Class<?> entityClass, Map<Class<?>, String> cachedStatements, String prefix) {
        String statement = (String)cachedStatements.get(entityClass);
        if (statement != null) {
            return statement;
        } else {
            statement = prefix + entityClass.getSimpleName();
            if (statement.endsWith("Impl")) {
                statement = statement.substring(0, statement.length() - 10);
            } else {
                statement = statement.substring(0, statement.length() - 6);
            }
            cachedStatements.put(entityClass, statement);
            return statement;
        }
    }
    protected static void addDatabaseSpecificStatement(String databaseType, String activitiStatement, String ibatisStatement) {
        Map<String, String> specificStatements = (Map)databaseSpecificStatements.get(databaseType);
        if (specificStatements == null) {
            specificStatements = new HashMap();
            databaseSpecificStatements.put(databaseType, specificStatements);
        }
        ((Map)specificStatements).put(activitiStatement, ibatisStatement);
    }
    public String mapStatement(String statement) {
        if (this.statementMappings == null) {
            return statement;
        } else {
            String mappedStatement = (String)this.statementMappings.get(statement);
            return mappedStatement != null ? mappedStatement : statement;
        }
    }
    public void setDatabaseType(String databaseType) {
        this.databaseType = databaseType;
        this.statementMappings = (Map)databaseSpecificStatements.get(databaseType);
    }
    public void setBulkInsertEnabled(boolean isBulkInsertEnabled, String databaseType) {
        if (isBulkInsertEnabled) {
            this.initBulkInsertEnabledMap(databaseType);
        }
    }
    protected void initBulkInsertEnabledMap(String databaseType) {
        bulkInsertableMap = new HashMap();
        Iterator var2 = EntityDependencyOrder.INSERT_ORDER.iterator();
        while(var2.hasNext()) {
            Class<? extends Entity> clazz = (Class)var2.next();
            bulkInsertableMap.put(clazz, Boolean.TRUE);
        }
        if ("oracle".equals(databaseType) || "dm".equals(databaseType)) {
            bulkInsertableMap.put(EventLogEntryEntityImpl.class, Boolean.FALSE);
        }
    }
    public Boolean isBulkInsertable(Class<? extends Entity> entityClass) {
        return bulkInsertableMap != null && bulkInsertableMap.containsKey(entityClass) && (Boolean)bulkInsertableMap.get(entityClass);
    }
    public SqlSessionFactory getSqlSessionFactory() {
        return this.sqlSessionFactory;
    }
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;
    }
    public IdGenerator getIdGenerator() {
        return this.idGenerator;
    }
    public void setIdGenerator(IdGenerator idGenerator) {
        this.idGenerator = idGenerator;
    }
    public String getDatabaseType() {
        return this.databaseType;
    }
    public Map<String, String> getStatementMappings() {
        return this.statementMappings;
    }
    public void setStatementMappings(Map<String, String> statementMappings) {
        this.statementMappings = statementMappings;
    }
    public Map<Class<?>, String> getInsertStatements() {
        return this.insertStatements;
    }
    public void setInsertStatements(Map<Class<?>, String> insertStatements) {
        this.insertStatements = insertStatements;
    }
    public Map<Class<?>, String> getBulkInsertStatements() {
        return this.bulkInsertStatements;
    }
    public void setBulkInsertStatements(Map<Class<?>, String> bulkInsertStatements) {
        this.bulkInsertStatements = bulkInsertStatements;
    }
    public Map<Class<?>, String> getUpdateStatements() {
        return this.updateStatements;
    }
    public void setUpdateStatements(Map<Class<?>, String> updateStatements) {
        this.updateStatements = updateStatements;
    }
    public Map<Class<?>, String> getDeleteStatements() {
        return this.deleteStatements;
    }
    public void setDeleteStatements(Map<Class<?>, String> deleteStatements) {
        this.deleteStatements = deleteStatements;
    }
    public Map<Class<?>, String> getBulkDeleteStatements() {
        return this.bulkDeleteStatements;
    }
    public void setBulkDeleteStatements(Map<Class<?>, String> bulkDeleteStatements) {
        this.bulkDeleteStatements = bulkDeleteStatements;
    }
    public Map<Class<?>, String> getSelectStatements() {
        return this.selectStatements;
    }
    public void setSelectStatements(Map<Class<?>, String> selectStatements) {
        this.selectStatements = selectStatements;
    }
    public boolean isDbIdentityUsed() {
        return this.isDbIdentityUsed;
    }
    public void setDbIdentityUsed(boolean isDbIdentityUsed) {
        this.isDbIdentityUsed = isDbIdentityUsed;
    }
    public boolean isDbHistoryUsed() {
        return this.isDbHistoryUsed;
    }
    public void setDbHistoryUsed(boolean isDbHistoryUsed) {
        this.isDbHistoryUsed = isDbHistoryUsed;
    }
    public void setDatabaseTablePrefix(String databaseTablePrefix) {
        this.databaseTablePrefix = databaseTablePrefix;
    }
    public String getDatabaseTablePrefix() {
        return this.databaseTablePrefix;
    }
    public String getDatabaseCatalog() {
        return this.databaseCatalog;
    }
    public void setDatabaseCatalog(String databaseCatalog) {
        this.databaseCatalog = databaseCatalog;
    }
    public String getDatabaseSchema() {
        return this.databaseSchema;
    }
    public void setDatabaseSchema(String databaseSchema) {
        this.databaseSchema = databaseSchema;
    }
    public void setTablePrefixIsSchema(boolean tablePrefixIsSchema) {
        this.tablePrefixIsSchema = tablePrefixIsSchema;
    }
    public boolean isTablePrefixIsSchema() {
        return this.tablePrefixIsSchema;
    }
    public int getMaxNrOfStatementsInBulkInsert() {
        return this.maxNrOfStatementsInBulkInsert;
    }
    public void setMaxNrOfStatementsInBulkInsert(int maxNrOfStatementsInBulkInsert) {
        this.maxNrOfStatementsInBulkInsert = maxNrOfStatementsInBulkInsert;
    }
}
src/main/resources/application.yml
@@ -4,12 +4,16 @@
spring:
  application:
    name: lxzn-dev-admin
  jpa:   #国产化需要
    properties:
      hibernate:
        dialect: org.hibernate.dialect.Oracle10gDialect
      show-sql: ture
  datasource:
    url: ${MSSQL_URL:jdbc:sqlserver://192.168.0.116:1433;databaseName=lxzn_nc_admin_430}
    username: sa
    password: 123
    type: com.alibaba.druid.pool.DruidDataSource
    driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
    driver-class-name: dm.jdbc.driver.DmDriver
    url: jdbc:dm://LOCALHOST:5236?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&schema=LXZN_NC_ADMIN_430
    username: SYSDBA
    password: Lyh10225217
    initialSize: 5  #初始建立连接数量
    minIdle: 5  #最小连接数量
    maxActive: 20 #最大连接数量
@@ -31,7 +35,7 @@
    host: ${REDIS_HOST:127.0.0.1}
    port: ${REDIS_PORT:6379}
    timeout: 10000ms #连接超时 æ¯«ç§’
    password: ""
    password: "123456"
    jedis:
      pool:
        maxActive: 3
@@ -43,6 +47,7 @@
    database-schema-update: true
    db-history-used: true
    history-level: full
    async-executor-activate: false
  servlet:
    multipart:
      #默认支持文件上传.
@@ -57,8 +62,8 @@
      max-request-size: 10240MB
mybatis-plus:
  mapper-locations: classpath*:com.lxzn.ucenter.dao/*Mapper.xml,classpath*:com.lxzn.nc.dao/*Mapper.xml,classpath*:com.lxzn.base.dao/*Mapper.xml,classpath*:com.lxzn.activiti.dao/*Mapper.xml
  #configuration:
    #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  global-config:
    db-config:
      #logic-delete-field: delete_flag  #全局逻辑删除字段值 3.3.0开始支持,详情看下面。
@@ -72,7 +77,7 @@
  tokenValiditySeconds: 7200  #token存储到redis的过期时间
  clientId: XcWebApp
  clientSecret: XcWebApp
  cookieDomain: ${COOKIE_DOMAIN:127.0.0.1}
  cookieDomain: ${COOKIE_DOMAIN:localhost}
  cookieMaxAge: 7200
auth_server: http://${server.host}:${server.port}
#文件上传目录(注意Linux和Windows上的目录结构不同)
@@ -82,8 +87,8 @@
activiti:
  enable: true # true å¯ç”¨å®¡æ‰¹ false ä¸å¯ç”¨å®¡æ‰¹
securedoc:
  serverIp: 20.11.9.10
  serverPort: 8090
  serverIp: 127.0.0.1
  serverPort: 8199
  identifier: testUser
  binFileLabel: <secAttrib><secrecy>5</secrecy></secAttrib>
  editFileLabel: <secAttrib><secrecy>5</secrecy><status>2</status></secAttrib>
src/main/resources/logback-spring.xml
@@ -2,7 +2,7 @@
<configuration>
    <!--定义日志文件的存储地址,使用绝对路径-->
    <property name="LOG_HOME" value="E:/logs"/>
    <property name="LOG_HOME" value="D:/logs"/>
    <!-- Console è¾“出设置 -->
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">