Flowable源码注释(三)流程引擎配置类

Flowable源码地址:https://github.com/flowable/flowable-engine

ProcessEnginConfiguration流程引擎配置类

  • 用于构建流程引擎的配置信息

  • 最常见的是基于默认配置文件创建流程引擎:

ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault().buildProcessEngine();
  • 要在没有配置文件的情况下通过编程创建流程引擎,第一个选项是{@link#createStandaloneProcessEngineConfiguration()}
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration().buildProcessEngine();
  • 在独立模式下,将创建一个包含连接到远程h2数据库的所有默认设置(jdbc:h2:tcp://localhost/flowable)的新流程引擎。独立模式意味着流程引擎将管理它创建的JDBC连接上的事务。每个服务方法一个事务。有关如何编写配置文件的说明,请参阅《用户指南》。

  • 第二个选项非常适合测试:{@link#createStandaloneInMemProcessEngineConfiguration()}

ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration().buildProcessEngine();
  • 在创建流程引擎的所有形式中,在调用{@link#buildProcessEngine()}方法之前,可以先自定义配置,方法如下:
ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault().setMailServerHost("gmail.com").setJdbcUsername("mickey").setJdbcPassword("mouse")
          .buildProcessEngine();
public abstract class ProcessEngineConfiguration extends AbstractEngineConfiguration {
   

    protected String processEngineName = ProcessEngines.NAME_DEFAULT;
    protected int idBlockSize = 2500;
    protected String history = HistoryLevel.AUDIT.getKey();
    protected boolean asyncExecutorActivate;
    protected boolean asyncHistoryExecutorActivate;

    protected String mailServerHost = "localhost";
    protected String mailServerUsername; // 默认情况下,不提供任何名称和密码
    protected String mailServerPassword; // 意味着邮件服务器没有身份验证
    protected int mailServerPort = 25;
    protected int mailServerSSLPort = 465;
    protected boolean useSSL;
    protected boolean useTLS;
    protected String mailServerDefaultFrom = "flowable@localhost";
    protected String mailServerForceTo;
    protected Charset mailServerDefaultCharset;
    protected String mailSessionJndi;
    protected Map<String, MailServerInfo> mailServers = new HashMap<>();
    protected Map<String, String> mailSessionsJndi = new HashMap<>();

    // 设置Http客户端配置默认值
    protected HttpClientConfig httpClientConfig = new HttpClientConfig();

    protected HistoryLevel historyLevel;
    protected boolean enableProcessDefinitionHistoryLevel;

    protected String jpaPersistenceUnitName;
    protected Object jpaEntityManagerFactory;
    protected boolean jpaHandleTransaction;
    protected boolean jpaCloseEntityManager;

    protected AsyncExecutor asyncExecutor;
    protected AsyncTaskExecutor asyncTaskExecutor;
    protected boolean shutdownAsyncTaskExecutor;
    protected AsyncTaskInvoker asyncTaskInvoker;

    protected AsyncExecutor asyncHistoryExecutor;
    protected AsyncTaskExecutor asyncHistoryTaskExecutor;
    protected boolean shutdownAsyncHistoryTaskExecutor;

    /** 定义失败作业的默认等待时间(秒) */
    protected int defaultFailedJobWaitTime = 10;
    /** 定义失败异步作业的默认等待时间(秒) */
    protected int asyncFailedJobWaitTime = 10;

    /**
     * 流程图生成器。默认值为DefaultProcessDiagramGenerator
     */
    protected ProcessDiagramGenerator processDiagramGenerator;

    protected boolean isCreateDiagramOnDeploy = true;

    protected boolean alwaysUseArraysForDmnMultiHitPolicies = true;
    
    /**
     *  如果没有标签DI,请包含顺序流名称, 
     */
    protected boolean drawSequenceFlowNameWithNoLabelDI = false;
    
    protected String defaultCamelContext = "camelContext";

    protected String activityFontName = "Arial";
    protected String labelFontName = "Arial";
    protected String annotationFontName = "Arial";

    protected boolean enableProcessDefinitionInfoCache;

    // 清除历史
    protected boolean enableHistoryCleaning = false;
    protected String historyCleaningTimeCycleConfig = "0 0 1 * * ?";
    protected Duration cleanInstancesEndedAfter = Duration.ofDays(365);
    protected int cleanInstancesBatchSize = 100;
    protected boolean cleanInstancesSequentially = false;
    protected HistoryCleaningManager historyCleaningManager;


    /** 任务生成器的后处理器 */
    protected TaskPostProcessor taskPostProcessor = null;

    /** 使用一个静态创建方法static createXxxx替代 */
    protected ProcessEngineConfiguration() {
   
    }

    public abstract ProcessEngine buildProcessEngine();

    public static ProcessEngineConfiguration createProcessEngineConfigurationFromResourceDefault() {
   
        return createProcessEngineConfigurationFromResource("flowable.cfg.xml", "processEngineConfiguration");
    }

    public static ProcessEngineConfiguration createProcessEngineConfigurationFromResource(String resource) {
   
        return createProcessEngineConfigurationFromResource(resource, "processEngineConfiguration");
    }

    public static ProcessEngineConfiguration createProcessEngineConfigurationFromResource(String resource, String beanName) {
   
        return (ProcessEngineConfiguration) BeansConfigurationHelper.parseEngineConfigurationFromResource(resource, beanName);
    }

    public static ProcessEngineConfiguration createProcessEngineConfigurationFromInputStream(InputStream inputStream) {
   
        return createProcessEngineConfigurationFromInputStream(inputStream, "processEngineConfiguration");
    }

    public static ProcessEngineConfiguration createProcessEngineConfigurationFromInputStream(InputStream inputStream, String beanName) {
   
        return (ProcessEngineConfiguration) BeansConfigurationHelper.parseEngineConfigurationFromInputStream(inputStream, beanName);
    }

    public static ProcessEngineConfiguration createStandaloneProcessEngineConfiguration() {
   
        return new StandaloneProcessEngineConfiguration();
    }

    public static ProcessEngineConfiguration createStandaloneInMemProcessEngineConfiguration
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值