source: xssim/src/test/rewolucja/scheduling/AbstractJobRegistry.java @ 104

Revision 104, 1.7 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package test.rewolucja.scheduling;
2
3
4import java.util.List;
5import java.util.concurrent.ConcurrentHashMap;
6
7import org.apache.commons.logging.Log;
8import org.apache.commons.logging.LogFactory;
9
10import schedframe.scheduling.Job;
11import schedframe.scheduling.JobInterface;
12import schedframe.scheduling.Task;
13import schedframe.scheduling.TaskInterface;
14
15public abstract class AbstractJobRegistry extends ConcurrentHashMap<String, Job> implements JobRegistryInterface {
16
17        private static final long serialVersionUID = 8409060063583755824L;
18       
19        private static Log log = LogFactory.getLog(AbstractJobRegistry.class);
20       
21        protected AbstractJobRegistry(){
22                //log.warn("Methods from JobRegistry interface are not implemented.");
23        }
24       
25        public boolean addJob(JobInterface<?> job) {
26                try {
27                        super.put(job.getId(), (Job) job);
28                } catch (NoSuchFieldException e) {
29                        log.error(e.getMessage());
30                        return false;
31                }
32                return true;
33        }
34
35        public boolean addTask(TaskInterface<?> task) {
36                if(super.containsKey(task.getJobId())){
37                        super.get(task.getJobId()).add((Task)task);
38                        return true;
39                } else {
40                        return false;
41                }
42        }
43
44        public JobInterface<?> getJobInfo(String jobID) {
45                return super.get(jobID);
46        }
47
48        public TaskInterface<?> getTaskInfo(String jobID, String taskId) {
49                Task task = null;
50                Job job = super.get(jobID);
51               
52                if(job == null)
53                        return null;
54               
55                try {
56                        task = job.getTask(taskId);
57                } catch (NoSuchFieldException e) {
58                        log.error(e.getMessage());
59                }
60                return task;
61        }
62       
63        /*public List<JobInterface<?>> getActiveJobs() {
64                log.error("getActiveJobs() not implemented.");
65                return null;
66        }
67
68        public List<TaskInterface<?>> getActiveTasks() {
69                log.error("getActiveTasks() not implemented.");
70                return null;
71        }*/
72
73
74}
Note: See TracBrowser for help on using the repository browser.