JBPM定时器(Timer)之Repeat属性不能使用变量

                        

我曾经想如下配置JBPM的Timer:
<on event="timeout">
      <timer duedate="#{duedate}" repeat="#{repeat}"/>
          <event-listener   class="...wfms.demo.timer.TimerListner" />
 </on>

 

结果发现:

1.duedate是可以使用流程变量的,当创建org.jbpm.pvm.internal.job.TimerImpl的实例时,其会找到相应变量的值来初始化duedate属性如下:

 public void setDueDateDescription(String dueDateDescription) {
    ScriptManager scriptManager = ScriptManager.getScriptManager();
    dueDateDescription = (String) scriptManager.evaluateExpression(dueDateDescription, null);
    Date now = Clock.getCurrentTime();
    BusinessCalendar businessCalendar = EnvironmentImpl.getFromCurrent(BusinessCalendar.class);
    duedate = businessCalendar.add(now, dueDateDescription);
  }

 

2.repeat就不能使用流程变量了,而只可以使用一个持续时间表达式常量。原因是其只是把配置的变量赋值给TimerImpl实例的repeat属性而不做任何处理:

public void setRepeat(String repeat) {
    this.repeat = repeat;
 }

 当然了要解决这个问题办法倒是有一个,那就是覆写上面这个方法:

public void setRepeat(String repeat) {
  ScriptManager scriptManager = ScriptManager.getScriptManager();
        this.repeat = (String) scriptManager.evaluateExpression(repeat, null);
  }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值