KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > scheduling > ScheduleInstruction


1 /*
2  * (c) Rob Gordon 2005
3  */

4 package org.oddjob.scheduling;
5
6 import java.io.Serializable JavaDoc;
7
8 import org.apache.log4j.Logger;
9 import org.oddjob.arooa.registry.ComponentRegistry;
10 import org.oddjob.framework.Exportable;
11 import org.oddjob.framework.Transportable;
12
13 /**
14  * Base class for schedule information that goes accross the network.
15  *
16  * @author Rob Gordon.
17  */

18 abstract public class ScheduleInstruction
19 implements Transportable, Exportable, Serializable JavaDoc, Cloneable JavaDoc {
20     private static final long serialVersionUID = 20051128;
21     private static final Logger logger = Logger.getLogger(ScheduleInstruction.class);
22
23     /** The name of the schedule. */
24     private String JavaDoc name;
25     
26     /** The schedule id. */
27     private String JavaDoc id;
28     
29     /**
30      * @oddjob.property
31      * @oddjob.description The job who's execution
32      * to schedule.
33      * @oddjob.required Yes.
34      */

35     private Object JavaDoc job;
36
37     public Transportable exportTransportable() {
38         if (job == null) {
39             return null;
40         }
41         if (! (job instanceof Exportable)) {
42             logger.debug("A remote server can not schedule a local job.");
43             return null;
44         }
45         ScheduleInstruction out;
46         try {
47             out = (ScheduleInstruction) clone();
48         } catch (CloneNotSupportedException JavaDoc e) {
49                 throw new IllegalStateException JavaDoc("This should never happen " + e.getMessage());
50         }
51         out.job = ((Exportable) job).exportTransportable();
52         return out;
53     }
54     
55     public Object JavaDoc importResolve(ComponentRegistry componentRegistry) {
56         job = ((Transportable) job).importResolve(componentRegistry);
57         return this;
58     }
59
60     public Object JavaDoc getJob() {
61         return job;
62     }
63
64     public void setJob(Object JavaDoc job) {
65         this.job = job;
66     }
67
68     public String JavaDoc getName() {
69         return name;
70     }
71
72     public void setName(String JavaDoc name) {
73         this.name = name;
74     }
75
76     public String JavaDoc getId() {
77         return id;
78     }
79
80     public void setId(String JavaDoc id) {
81         this.id = id;
82     }
83 }
84
Popular Tags