1. 程式人生 > >flowable EngineConfiguration的作用和繼承關係(1)

flowable EngineConfiguration的作用和繼承關係(1)

EngineConfiguration 是flowable引擎的核心部件。
在 flowable 中,實現引擎配置的頂層類是 AbstractEngineConfiguration 這是一個抽象類。

一、作用

1、第一個作用是配置引擎使用的資料庫資訊。

protected String databaseType;
    protected String jdbcDriver = "org.h2.Driver";
    protected String jdbcUrl = "jdbc:h2:tcp://localhost/~/flowable";
    protected
String jdbcUsername = "sa"; protected String jdbcPassword = ""; protected String dataSourceJndiName; protected int jdbcMaxActiveConnections; protected int jdbcMaxIdleConnections; protected int jdbcMaxCheckoutTime; protected int jdbcMaxWaitTime; protected boolean jdbcPingEnabled; protected
String jdbcPingQuery; protected int jdbcPingConnectionNotUsedFor; protected int jdbcDefaultTransactionIsolationLevel; protected DataSource dataSource; protected DbSchemaManager dbSchemaManager;

2、第二個作用是提供 資料庫表結構初始化狀態的行為定義。

 public static final String DB_SCHEMA_UPDATE_FALSE = "false"
; public static final String DB_SCHEMA_UPDATE_CREATE = "create"; public static final String DB_SCHEMA_UPDATE_CREATE_DROP = "create-drop"; public static final String DB_SCHEMA_UPDATE_DROP_CREATE = "drop-create"; public static final String DB_SCHEMA_UPDATE_TRUE = "true";

3、第三個作用是對mybatis進行封裝,提供資料庫操作入口

 protected DbSqlSessionFactory dbSqlSessionFactory;
    protected SqlSessionFactory sqlSessionFactory;
    protected TransactionFactory transactionFactory;
    protected TransactionContextFactory transactionContextFactory;

    protected Set<Class<?>> customMybatisMappers;
    protected Set<String> customMybatisXMLMappers;

    protected Set<String> dependentEngineMyBatisXmlMappers;
    protected List<CustomMybatisTypeAliasConfig> dependentEngineMybatisTypeAliasConfigs;
    protected List<CustomMyBatisTypeHandlerConfig> dependentEngineMybatisTypeHandlerConfigs;

    protected List<SessionFactory> customSessionFactories;
    protected Map<Class<?>, SessionFactory> sessionFactories;

    protected boolean enableEventDispatcher = true;
    protected FlowableEventDispatcher eventDispatcher;
    protected List<FlowableEventListener> eventListeners;
    protected Map<String, List<FlowableEventListener>> typedEventListeners;
    protected List<EventDispatchAction> additionalEventDispatchActions;

    protected boolean transactionsExternallyManaged;

4、第四個作用 是提供sql執行上下文環境和執行佇列

 protected CommandExecutor commandExecutor;
    protected Collection<? extends CommandInterceptor> defaultCommandInterceptors;
    protected CommandConfig defaultCommandConfig;
    protected CommandConfig schemaCommandConfig;
    protected CommandContextFactory commandContextFactory;
    protected CommandInterceptor commandInvoker;

    protected List<CommandInterceptor> customPreCommandInterceptors;
    protected List<CommandInterceptor> customPostCommandInterceptors;
    protected List<CommandInterceptor> commandInterceptors;

5、第五個作用是完成引擎內部服務的配置和初始化,並構建引擎例項

通過呼叫相應的方法,獲得每個引擎。

formEngineConfiguration.buildFormEngine();
idmEngineConfiguration.buildIdmEngine();
dmnEngineConfiguration.buildDmnEngine();
contentEngineConfiguration.buildContentEngine();
processEngineConfiguration.buildProcessEngine();

當然,在呼叫這個方法之前,需要進行設定適當的引數。

二、繼承關係

這裡寫圖片描述

這裡寫圖片描述

三、分類

根據用途分為五類:

1、內容引擎配置

ContentEngineConfiguration

2、流程引擎配置

ProcessEngineConfiguration

3、身份引擎配置

IdmEngineConfiguration

4、決策引擎配置

DmnEngineConfiguration

5、表單引擎配置

FormEngineConfiguration

這裡寫圖片描述

除了流程引擎配置外,其他的引擎配置類都提供了兩種不同的配置,包括支援Spring的引擎配置類和獨立的引擎配置類。

獨立的引擎配置類又被擴充套件支援記憶體型別的引擎配置類。

這裡寫圖片描述

這些繼承了 AbstractEngineConfig 類的引擎配置類,定製不同的資料庫使用模式(單租戶、多租戶、單資料庫、多資料庫)、mybatis配置檔案、事務的處理、資源的獲取等。