Пример #1
0
 @Override
 public Schedule scheduleOnce(Task task, DateTime runAt, boolean durable) {
   Schedule schedule = scheduleFactory.newOnceSchedule(task, runAt, durable);
   dispatchForExecution(schedule);
   if (durable) {
     Schedules schedules =
         module.currentUnitOfWork().get(Schedules.class, getSchedulesIdentity(me));
     schedules.schedules().add(schedule);
   }
   return schedule;
 }
Пример #2
0
 @Override
 public Schedule scheduleCron(
     Task task, @CronExpression String cronExpression, DateTime start, boolean durable) {
   Schedule schedule = scheduleFactory.newCronSchedule(task, cronExpression, start, durable);
   if (durable) {
     Schedules schedules =
         module.currentUnitOfWork().get(Schedules.class, getSchedulesIdentity(me));
     schedules.schedules().add(schedule);
   }
   dispatchForExecution(schedule);
   return schedule;
 }
Пример #3
0
 @Override
 public Schedule scheduleCron(
     Task task, String cronExpression, long initialDelay, boolean durable) {
   DateTime start = new DateTime(System.currentTimeMillis() + initialDelay);
   Schedule schedule = scheduleFactory.newCronSchedule(task, cronExpression, start, durable);
   if (durable) {
     Schedules schedules =
         module.currentUnitOfWork().get(Schedules.class, getSchedulesIdentity(me));
     schedules.schedules().add(schedule);
   }
   dispatchForExecution(schedule);
   return schedule;
 }
Пример #4
0
 @Override
 public Schedule scheduleOnce(Task task, int initialSecondsDelay, boolean durable) {
   long now = System.currentTimeMillis();
   Schedule schedule =
       scheduleFactory.newOnceSchedule(
           task, new DateTime(now + initialSecondsDelay * 1000), durable);
   if (durable) {
     Schedules schedules =
         module.currentUnitOfWork().get(Schedules.class, getSchedulesIdentity(me));
     schedules.schedules().add(schedule);
   }
   dispatchForExecution(schedule);
   return schedule;
 }