flowable ProcessEngine和ProcessEngineConfiguration

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/teamlet/article/details/76427718

ProcessEngine是流程引擎,ProcessEngineConfiguration与前面四个引擎配置有些不同。

ProcessEngineConfiguration增加了邮件服务和httpClient的封装。

一、实例化

ProcessEngineConfiguration 提供了7个公共的静态方法用于实例化。

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

    public static ProcessEngineConfiguration createStandaloneInMemProcessEngineConfiguration() {
        return new StandaloneInMemProcessEngineConfiguration();
    }

二、创建ProcessEngine

创建ProcessEngine的方法是在ProcessEngineConfiguration的子类 ProcessEngineConfigurationImpl中提供的。

@Override
    public ProcessEngine buildProcessEngine() {
        init();
        ProcessEngineImpl processEngine = new ProcessEngineImpl(this);
...

        return processEngine;
    }

三、初始化服务

创建引擎过程调用init()方法时,初始化服务。

public void init() {
...
initServices();
...
}

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);
        }
    }

这些服务定义在 ProcessEngineConfigurationImpl 中:

  protected RepositoryService repositoryService = new RepositoryServiceImpl();
    protected RuntimeService runtimeService = new RuntimeServiceImpl();
    protected HistoryService historyService = new HistoryServiceImpl(this);
    protected IdentityService identityService = new IdentityServiceImpl(this);
    protected TaskService taskService = new TaskServiceImpl(this);
    protected FormService formService = new FormServiceImpl();
    protected ManagementService managementService = new ManagementServiceImpl();
    protected DynamicBpmnService dynamicBpmnService = new DynamicBpmnServiceImpl(this);

初始化使AbstractEngineConfiguration的 CommandExecutor传递到这些服务的父类 ServiceImpl 中。

这些服务随着 processEngineConfigurationImpl实例传递给 processEngin实例。

这里写图片描述

猜你喜欢

转载自blog.csdn.net/teamlet/article/details/76427718
今日推荐