source: DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/AbstractJobRegistry.java @ 481

Revision 481, 1.4 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
RevLine 
[477]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
[481]15public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job>*/ implements JobRegistry, Cloneable{
[477]16       
17        private static final long serialVersionUID = 8409060063583755824L;
[481]18
[477]19       
[481]20        protected static final ConcurrentHashMap<String, JobInterface<?>> jobs = new ConcurrentHashMap<String, JobInterface<?>>();
[477]21       
22        protected AbstractJobRegistry(){
23        }
24       
25        public boolean addJob(JobInterface<?> job) {
[481]26                jobs.put(job.getId(),  job);
[477]27                return true;
28        }
29
30        public boolean addTask(TaskInterface<?> task) {
31                if(jobs.containsKey(task.getJobId())){
[481]32                        getJob(task.getJobId()).add((Task)task);
[477]33                        return true;
34                } else {
35                        return false;
36                }
37        }
38
[481]39        public JobInterface<?> getJobInfo(String jobId) {
[477]40                return jobs.get(jobId);
41        }
42
[481]43        public TaskInterface<?> getTaskInfo(String jobId, String taskId) {
[477]44                Task task = null;
[481]45                Job job = getJob(jobId);
[477]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       
[481]57        public Job getJob(String jobId){
58                return (Job)jobs.get(jobId);
[477]59        }
60
61}
Note: See TracBrowser for help on using the repository browser.