/* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.activiti.engine.impl.persistence.entity; import java.util.Date; import org.activiti.engine.impl.calendar.BusinessCalendar; import org.activiti.engine.impl.calendar.CycleBusinessCalendar; import org.activiti.engine.impl.context.Context; import org.activiti.engine.impl.interceptor.CommandContext; import org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author Tom Baeyens */ public class TimerEntity extends JobEntity { private static final long serialVersionUID = 1L; private static Logger log = LoggerFactory.getLogger(TimerEntity.class); protected String repeat; public TimerEntity() { } public TimerEntity(TimerDeclarationImpl timerDeclaration) { jobHandlerType = timerDeclaration.getJobHandlerType(); jobHandlerConfiguration = timerDeclaration.getJobHandlerConfiguration(); isExclusive = timerDeclaration.isExclusive(); repeat = timerDeclaration.getRepeat(); retries = timerDeclaration.getRetries(); } private TimerEntity(TimerEntity te) { jobHandlerConfiguration = te.jobHandlerConfiguration; jobHandlerType = te.jobHandlerType; isExclusive = te.isExclusive; repeat = te.repeat; retries = te.retries; executionId = te.executionId; processInstanceId = te.processInstanceId; } @Override public void execute(CommandContext commandContext) { super.execute(commandContext); if (repeat == null) { if (log.isDebugEnabled()) { log.debug("Timer {} fired. Deleting timer.", getId()); } delete(); } else { delete(); Date newTimer = calculateRepeat(); System.out.println(repeat); System.out.println(newTimer); if (newTimer != null) { TimerEntity te = new TimerEntity(this); te.setDuedate(newTimer); Context .getCommandContext() .getJobEntityManager() .schedule(te); } } } private Date calculateRepeat() { BusinessCalendar businessCalendar = Context .getProcessEngineConfiguration() .getBusinessCalendarManager() .getBusinessCalendar(CycleBusinessCalendar.NAME); return businessCalendar.resolveDuedate(repeat); } public String getRepeat() { return repeat; } public void setRepeat(String repeat) { this.repeat = repeat; } }
最近下载更多
dada2211 LV1
2022年7月18日
shiyujir LV7
2021年4月8日
lironggang LV38
2021年3月26日
mixiumissuuu LV1
2020年11月22日
caozhaoqi83 LV5
2020年10月21日
527732528 LV2
2020年8月6日
he752650052 LV1
2020年4月21日
gnocchi LV1
2020年4月14日
菜鸟真的是菜 LV8
2020年2月3日
limi LV9
2019年12月30日
最近浏览更多
wubz2008 LV5
4月22日
denglu123321 LV4
4月11日
dmy2008 LV6
1月2日
wang_d LV12
2023年12月9日
taoshen95 LV14
2023年8月7日
dapeng0011 LV13
2023年7月3日
xxx520520 LV6
2023年5月31日
felixsxf LV5
2023年1月31日
cooper1
2022年12月14日
暂无贡献等级
JavaPro_Allen LV9
2022年11月19日