So, create an IOC service:

public interface Job implements Runnable {
   // implementors of this must be careful with synchronization
   public void updateJobConfig(JobConfig config);
}

public class JobServiceImpl implements JobService {
   @Inject
   private PeriodicExecutor executor;

   private Map<String, Job> jobsById = new HashMap<String, Job>();
   private Map<String, PeriodicJob> periodicJobsById = new HashMap<String,
String>();

   public synchronized PeriodicJob addJob(Schedule schedule, String jobId,
Job job) {
      PeriodicJob periodicJob = executor.addJob(schedule, jobId, job);
      jobsById.put(jobId, job);
      periodicJobsById.put(jobId, periodicJob);
      return periodicJob;
   }

   public synchronized void cancelJob(String jobId) {
      periodicJobsById.remove(jobId).cancel();
      jobsById.remove(jobId);
   }

   public synchronized void updateJob(String jobId, JobConfig config) {
      jobsById.get(jobId).updateJobConfig(config);
   }
}



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Configurable-scheduled-jobs-tp5717769p5717771.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to