source: DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/tasks/AbstractJobRegistry.java @ 539

Revision 539, 1.4 KB checked in by wojtekp, 12 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package schedframe.scheduling.manager.tasks;
2
3
4import java.util.concurrent.ConcurrentHashMap;
5
6import org.apache.commons.logging.Log;
7import org.apache.commons.logging.LogFactory;
8
9import schedframe.scheduling.tasks.Job;
10import schedframe.scheduling.tasks.JobInterface;
11import schedframe.scheduling.tasks.Task;
12import schedframe.scheduling.tasks.TaskInterface;
13
14
15public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job>*/ implements JobRegistry, Cloneable{
16       
17        private static final long serialVersionUID = 8409060063583755824L;
18
19       
20        protected static final ConcurrentHashMap<String, JobInterface<?>> jobs = new ConcurrentHashMap<String, JobInterface<?>>();
21       
22        protected AbstractJobRegistry(){
23        }
24       
25        public boolean addJob(JobInterface<?> job) {
26                jobs.put(job.getId(),  job);
27                return true;
28        }
29
30        public boolean addTask(TaskInterface<?> task) {
31                if(jobs.containsKey(task.getJobId())){
32                        getJob(task.getJobId()).add((Task)task);
33                        return true;
34                } else {
35                        return false;
36                }
37        }
38
39        public JobInterface<?> getJobInfo(String jobId) {
40                return jobs.get(jobId);
41        }
42
43        public TaskInterface<?> getTaskInfo(String jobId, String taskId) {
44                Task task = null;
45                Job job = getJob(jobId);
46               
47                if(job == null)
48                        return null;
49               
50                try {
51                        task = job.getTask(taskId);
52                } catch (NoSuchFieldException e) {
53                }
54                return task;
55        }
56       
57        public Job getJob(String jobId){
58                return (Job)jobs.get(jobId);
59        }
60
61}
Note: See TracBrowser for help on using the repository browser.