From 3619f716ee6bc8d1d2ffba7b13a89dae6b74a04e Mon Sep 17 00:00:00 2001 From: Miciele Ghiorghis Date: Wed, 16 Jan 2013 17:58:08 +0100 Subject: [PATCH] Tim-connector: A manager that dynamically creates jobs and cron-triggers using spring quartz library An interface that SchedulerManager implements. Dynamically creates jobs and cron triggers. It associated the triggers with the jobs and add them to the scheduler. It also supports the rescheduling of jobs. --- .../importers/ISchedulerManager.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 libreplan-webapp/src/main/java/org/libreplan/importers/ISchedulerManager.java diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/ISchedulerManager.java b/libreplan-webapp/src/main/java/org/libreplan/importers/ISchedulerManager.java new file mode 100644 index 000000000..b02a75d44 --- /dev/null +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/ISchedulerManager.java @@ -0,0 +1,80 @@ +/* + * This file is part of LibrePlan + * + * Copyright (C) 2013 St. Antoniusziekenhuis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.libreplan.importers; + +import java.util.List; + +import org.libreplan.business.common.entities.JobSchedulerConfiguration; +import org.springframework.scheduling.quartz.CronTriggerBean; +import org.springframework.scheduling.quartz.JobDetailBean; + +/** + * A manager(client) that dynamically creates jobs and cron-triggers using + * spring quartz library. + *

+ * The start and destroy of the scheduler itself is managed by the Spring + * framework. The scheduler starts automatically when the application starts and + * destroyed when the application stops. The sole purpose of this manager is to + * create jobs {@link JobDetailBean} and cron-triggers {@link CronTriggerBean} + * when the scheduler is started. It links the triggers with the jobs and add + * them to the scheduler. + *

+ * It also supports the rescheduling of jobs. + *

+ * The SchedulerManager reads the jobs to be scheduled and the cron-triggers to + * fire the jobs form {@link JobSchedulerConfiguration}. Hence the + * {@link JobSchedulerConfiguration} must exist with predefined jobs and valid + * cron-triggers + * + * @author Miciele Ghiorghis + */ +public interface ISchedulerManager { + + /** + * Reads job configuration from the database and schedules the jobs + */ + void scheduleJobs(); + + /** + * Reschedule the job. + *

+ * Reads the job to be rescheduled from the specified parameter + * {@link JobSchedulerConfiguration} and reschedule the job + * + * @param jobSchedulerConfiguration + * the job scheduler configuration + */ + void rescheduleJob(JobSchedulerConfiguration jobSchedulerConfiguration); + + /** + * returns the scheduler info list. This is necessary for UI + * + * @return + */ + List getSchedulerInfos(); + + /** + * To manually execute the job specified by jobName + * + * @param jobName + * the name of the job to be executed + */ + void doManual(String jobName); +}