Camunda JavaDelegate另一種實現

洞玄巅峰發表於2024-05-10
  • lambada實現
@Configuration
public class CommonDelegate {


    @Bean("test")
    JavaDelegate testDelegate() {
        return execution -> {
            System.out.println("test>>>>>");
            Map<String,String> map = new HashMap<>();
            execution.setVariable("map",map);
            execution.setVariable("jname", UUID.randomUUID().toString());
            execution.setVariable("jage", System.nanoTime());
        };
    }


}

Expression的使用

${myBean.doWork(execution)}

@Component("myBean")
public class MyService {

    public void doWork(DelegateExecution execution) {
        System.out.println("myBean:doWork>>>>>>");
        Object jname = execution.getVariable("jname");
        execution.setVariable("jname", jname + "zzzzz");

    }
}

map,jname必須是variables裡的變數

相關文章