1 package org.oddjob.scheduling; 2 3 import org.oddjob.framework.SimpleJob; 4 import org.oddjob.quartz.QuartzSchedulerJob; 5 import org.oddjob.util.OddjobConfigException; 6 7 35 public class ScheduleJob extends SimpleJob { 36 static final long serialVersionUID = 20050926; 37 38 43 private ScheduleInstruction[] schedules; 44 45 51 private OddjobScheduler scheduler; 52 53 58 public void setSchedules(ScheduleInstruction[] schedules) { 59 this.schedules = schedules; 60 } 61 62 67 public ScheduleInstruction[] getSchedules() { 68 return schedules; 69 } 70 71 75 protected int execute() throws Exception { 76 if (scheduler == null) { 77 throw new OddjobConfigException("No scheduler specified."); 78 } 79 if (schedules == null) { 80 logger().debug("Nothing to schedule."); 81 return 0; 82 } 83 for (int i = 0; i < schedules.length; ++i) { 84 scheduler.schedule(schedules[i]); 85 } 86 return 0; 87 } 88 89 92 public OddjobScheduler getScheduler() { 93 return scheduler; 94 } 95 98 public void setScheduler(OddjobScheduler scheduler) { 99 this.scheduler = scheduler; 100 } 101 } 102 103 | Popular Tags |