/** * Removes a previously registered custom {@link TaskCollector} instance. * * @param collector * The custom {@link TaskCollector} instance. */ public void removeTaskCollector(ITaskCollector collector) { lock (collectors) { collectors.Remove(collector); } }
/** * Adds a custom {@link TaskCollector} instance to the scheduler. The * supplied object, once added to the scheduler, will be query every minute * for its task list. The scheduler will execute any of the returned tasks * whose scheduling pattern matches the current system time. * * @param collector * The custom {@link TaskCollector} instance. */ public void addTaskCollector(ITaskCollector collector) { lock (collectors) { collectors.Add(collector); } }
/** * Builds the launcher. * * @param scheduler * The owner scheduler. * @param collectors * Task collectors, used to retrieve registered tasks. * @param referenceTimeInMillis * A reference time for task launching. */ public LauncherThread(Scheduler scheduler, ITaskCollector[] collectors, long referenceTimeInMillis) { this.scheduler = scheduler; this.collectors = collectors; this.referenceTimeInMillis = referenceTimeInMillis; // Thread name. string name = "cron4j::scheduler[" + scheduler.getGuid() + "]::launcher[" + guid + "]"; Thread = new Thread(new ThreadStart(Run)); Thread.Name = name; }
/** * Returns an array containing any custom {@link TaskCollector} instance * previously registered in the scheduler with the * {@link Scheduler#addTaskCollector(TaskCollector)} method. * * @return An array containing any custom {@link TaskCollector} instance * previously registered in the scheduler with the * {@link Scheduler#addTaskCollector(TaskCollector)} method. */ public ITaskCollector[] getTaskCollectors() { lock (collectors) { // Discard the first 2 elements in the list. int size = collectors.Count - 2; ITaskCollector[] ret = new ITaskCollector[size]; for (int i = 0; i < size; i++) { ret[i] = (ITaskCollector)collectors[i + 2]; } return(ret); } }
/** * Returns an array containing any custom {@link TaskCollector} instance * previously registered in the scheduler with the * {@link Scheduler#addTaskCollector(TaskCollector)} method. * * @return An array containing any custom {@link TaskCollector} instance * previously registered in the scheduler with the * {@link Scheduler#addTaskCollector(TaskCollector)} method. */ public ITaskCollector[] getTaskCollectors() { lock (collectors) { // Discard the first 2 elements in the list. int size = collectors.Count - 2; ITaskCollector[] ret = new ITaskCollector[size]; for (int i = 0; i < size; i++) { ret[i] = (ITaskCollector)collectors[i + 2]; } return ret; } }