用于camunda的序列发生器

时间:2015-10-23 13:38:44

标签: camunda

如何通过processes.xml为camunda设置我自己的IdGenerator。 在切换到使用processes.xml之前,我使用了

  ProcessEngineConfiguration.setIdGenerator(IdGenerator);

使用oracle数据库的序列。

1 个答案:

答案 0 :(得分:1)

1)实施ProcessEnginePlugin

package com.example;

import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin;

public class IdGeneratorPlugin implements ProcessEnginePlugin {

  public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
    processEngineConfiguration.setIdGenerator(new CustomIdGenerator());
  }

  public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
  }

  public void postProcessEngineBuild(ProcessEngine processEngine) {
  }
}

2)在processes.xml

中注册插件
<?xml version="1.0" encoding="UTF-8"?>
<process-application
  xmlns="http://www.camunda.org/schema/1.0/ProcessApplication"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.camunda.org/schema/1.0/ProcessApplication http://www.camunda.org/schema/1.0/ProcessApplication ">

  <process-engine name="default">
    ...
    <properties>
      ...
    </properties>

    <plugins>
      <plugin>
        <class>com.example.IdGeneratorPlugin</class>
      </plugin>
    </plugins>
  </process-engine>

  <process-archive name="pa">
    <properties>
      ...
    </properties>
  </process-archive>
</process-application>

3)确保插件位于camunda-engine类路径或流程应用程序的类路径上

来源:https://docs.camunda.org/manual/7.3/api-references/deployment-descriptors/#descriptors-processesxml