package com.qmth.distributed.print.config;

import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @Description: activiti 分布式id配置
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2021/7/14
 */
@Configuration
public class MyProcessEngineConfigurator {

    @Resource
    ActivitiConfig activitiIdGenerator;

    @Bean
    public ProcessEngineConfigurationImpl processEngineConfigurationImpl(ProcessEngineConfigurationImpl processEngineConfigurationImpl) {
        //设置ProcessEngineConfigurationImpl里的uuidGenerator
        processEngineConfigurationImpl.setIdGenerator(activitiIdGenerator);
        //设置DbSqlSessionFactory的uuidGenerator，否则流程id，任务id，实例id依然是用DbIdGenerator生成
        processEngineConfigurationImpl.getDbSqlSessionFactory().setIdGenerator(activitiIdGenerator);
        return processEngineConfigurationImpl;
    }
}
