flowableのID生成器
1. ID生成器
- DbIdGenerator
- StrongUuidGenerator
- 自定义生成器
2. 在流程配置类ProcessEngineConfigurationImpl中初始化生成
@Override public void initIdGenerator() { if (idGenerator == null) { DbIdGenerator dbIdGenerator = new DbIdGenerator(); dbIdGenerator.setIdBlockSize(idBlockSize); idGenerator = dbIdGenerator; } if (idGenerator instanceof DbIdGenerator) { DbIdGenerator dbIdGenerator = (DbIdGenerator) idGenerator; if (dbIdGenerator.getIdBlockSize() == 0) { dbIdGenerator.setIdBlockSize(idBlockSize); } if (dbIdGenerator.getCommandExecutor() == null) { dbIdGenerator.setCommandExecutor(getCommandExecutor()); } if (dbIdGenerator.getCommandConfig() == null) { dbIdGenerator.setCommandConfig(getDefaultCommandConfig().transactionRequiresNew()); } } }
3. 自定义ID生成器实现IdGenerator
import org.flowable.common.engine.impl.cfg.IdGenerator; import java.util.UUID; public class McmUuidGenerator implements IdGenerator { @Override public String getNextId() { return "mcm_"+UUID.randomUUID().toString(); } }
4. 在配置类中设置
@Configuration public class FlowableConfig implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> { @Override public void configure(SpringProcessEngineConfiguration engineConfiguration) { engineConfiguration.setActivityFontName("宋体"); engineConfiguration.setLabelFontName("宋体"); engineConfiguration.setAnnotationFontName("宋体"); engineConfiguration.setIdGenerator(new McmUuidGenerator());//自定义id生成器 } }