flowable DmnEngine和DmnEngineConfiguration

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

一、DmnEngineConfiguration创建实例

DmnEngineConfiguration 提供了7个公共的静态方法,用于创建自身实例。

其中5个是使用spring的机制加载配置文件。
另外2个是Standalone形式的,代码如下:

    public static DmnEngineConfiguration createStandaloneDmnEngineConfiguration() {
        return new StandaloneDmnEngineConfiguration();
    }

    public static DmnEngineConfiguration createStandaloneInMemDmnEngineConfiguration() {
        return new StandaloneInMemDmnEngineConfiguration();
    }

根据前面的分析,StandaloneDmnEngineConfiguration没有添加任何的代码,完全等同与父类;

而StandaloneInMemDmnEngineConfiguration只是修改了父类的jdbc url的参数,设置为h2数据库的配置。

二、DmnEngine构建

DmnEngineConfiguration实例创建后,调用buildDmnEngine(),获得DmnEngine的实例。

    public DmnEngine buildDmnEngine() {
        init();
        return new DmnEngineImpl(this);
    }

三、服务初始化

在init()方法里面做了很多初始化的工作。这里只说和DmnEngine相关的。

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

 protected void initServices() {
        initService(dmnManagementService);
        initService(dmnRepositoryService);
        initService(ruleService);
        initService(dmnHistoryService);
    }

    protected void initService(Object service) {
        if (service instanceof ServiceImpl) {
            ((ServiceImpl) service).setCommandExecutor(commandExecutor);
        }
    }

上面代码将DmnEngineConfiguration的 commandExecutor属性赋值给这四个服务。实际上,commandExecutor是DmnEngineConfiguration父类 AbstractEngineConfiguration的属性。

这四个服务的代码如下:

protected DmnManagementService dmnManagementService = new DmnManagementServiceImpl();
    protected DmnRepositoryService dmnRepositoryService = new DmnRepositoryServiceImpl();
    protected DmnRuleService ruleService = new DmnRuleServiceImpl();
    protected DmnHistoryService dmnHistoryService = new DmnHistoryServiceImpl();

这四个服务有相同的父类: ServiceImpl

ServiceImpl包含一个CommandExecutor属性。这四个服务的方法都是通过CommandExecutor实现代理模式来完成的。

这里写图片描述

猜你喜欢

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