View Javadoc

1   package org.opensync.engine.server;
2   
3   import java.util.*;
4   import org.opensync.engine.server.Task;
5   
6   /***
7    * An event which indicates that a task event occurred.
8    * A TaskEvent object is passed to every TaskListener object which registered to receive
9    * the "interesting" task events using the component's addTaskListener method.
10   */
11  
12  public class TaskEvent extends EventObject {
13    /***
14     * The date when the task start
15     *
16     */
17    protected Date start;
18    /***
19     * The date when the task stop
20     *
21     */
22    protected Date stop;
23    /***
24     * The exception which cause failure
25     *
26     *
27     */
28    protected Exception exception;
29    /***
30     * The delay given by the task
31     *
32     */
33    protected long delay;
34  
35    /***
36     * Construct a TaskEvent when the task start
37     *
38     * @param	task the task who send this event
39     * @param	start the date when the task start
40     */
41    public TaskEvent(Task task,Date start) {
42      super(task);
43      this.start = start;
44    }
45    /***
46     * Construct a TaskEvent when the task stop
47     *
48     * @param	task the task who send this event
49     * @param	stop the date when the task stop
50     * @param	delay the delay used by the task
51     */
52    public TaskEvent(Task task,Date stop,long delay) {
53      super(task);
54      this.stop = stop;
55      this.delay = delay;
56    }
57    /***
58     * Construct a TaskEvent when the task fail
59     *
60     * @param	task the task who send this event
61     * @param	stop stop the date when the task stop
62     * @param	exception the exception which cause failure
63     */
64    public TaskEvent(Task task,Date stop,Exception exception) {
65      super(task);
66      this.stop = stop;
67      this.exception = exception;
68    }
69    /***
70     * Get the delay used by the task
71     *
72     */
73    public long getDelay() {
74      return delay;
75    }
76    /***
77     * Get the time when the start start
78     *
79     */
80    public Date getStart() {
81      return start;
82    }
83    /***
84     * Get the time when the start stop
85     *
86     */
87    public Date getStop() {
88      return stop;
89    }
90    /***
91     * Get the exception which cause failure
92     *
93     */
94    public Exception getException() {
95      return exception;
96    }
97    /***
98     * Get the task who send this event
99     *
100    */
101   public Task getTask(){
102     return (Task)getSource();
103   }
104 }