package test.rewolucja.scheduling; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import schedframe.scheduling.Job; import schedframe.scheduling.JobInterface; import schedframe.scheduling.Task; import schedframe.scheduling.TaskInterface; public abstract class AbstractJobRegistry extends ConcurrentHashMap implements JobRegistryInterface { private static final long serialVersionUID = 8409060063583755824L; private static Log log = LogFactory.getLog(AbstractJobRegistry.class); protected AbstractJobRegistry(){ //log.warn("Methods from JobRegistry interface are not implemented."); } public boolean addJob(JobInterface job) { try { super.put(job.getId(), (Job) job); } catch (NoSuchFieldException e) { log.error(e.getMessage()); return false; } return true; } public boolean addTask(TaskInterface task) { if(super.containsKey(task.getJobId())){ super.get(task.getJobId()).add((Task)task); return true; } else { return false; } } public JobInterface getJobInfo(String jobID) { return super.get(jobID); } public TaskInterface getTaskInfo(String jobID, String taskId) { Task task = null; Job job = super.get(jobID); if(job == null) return null; try { task = job.getTask(taskId); } catch (NoSuchFieldException e) { log.error(e.getMessage()); } return task; } /*public List> getActiveJobs() { log.error("getActiveJobs() not implemented."); return null; } public List> getActiveTasks() { log.error("getActiveTasks() not implemented."); return null; }*/ }