22 |
} |
} |
23 |
|
|
24 |
protected volatile boolean abort = false;//mark volatile to make sure value isn't cached by threads |
protected volatile boolean abort = false;//mark volatile to make sure value isn't cached by threads |
25 |
protected TaskState state = TaskState.STATE_QUEUED; |
protected volatile TaskState state = TaskState.STATE_QUEUED; |
26 |
protected TaskManager manager; |
protected TaskManager manager; |
27 |
private String errorMsg; |
private String errorMsg; |
28 |
|
|
49 |
|
|
50 |
try { |
try { |
51 |
taskRun(); |
taskRun(); |
52 |
this.state = TaskState.STATE_DONE; |
|
53 |
|
if (this.state != TaskState.STATE_ABORTED) { //just to make sure we wasn't aborted |
54 |
|
this.state = TaskState.STATE_DONE; |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
} catch (Exception e) { |
} catch (Exception e) { |
59 |
this.errorMsg = e.getMessage(); |
this.errorMsg = e.getMessage(); |
60 |
e.printStackTrace(); |
e.printStackTrace(); |
96 |
this.abort = true; |
this.abort = true; |
97 |
} |
} |
98 |
|
|
99 |
|
public void doAbort(Exception e) { |
100 |
|
this.abort = true; |
101 |
|
this.errorMsg = e.getMessage(); |
102 |
|
} |
103 |
|
|
104 |
public TaskBean getTaskBean() { |
public TaskBean getTaskBean() { |
105 |
TaskBean bean = new TaskBean(); |
TaskBean bean = new TaskBean(); |
106 |
bean.id = this.getId(); |
bean.id = this.getId(); |
117 |
return this.errorMsg; |
return this.errorMsg; |
118 |
} |
} |
119 |
|
|
120 |
|
@Override |
121 |
|
public int hashCode() { |
122 |
|
return this.id; |
123 |
|
} |
124 |
|
|
125 |
|
@Override |
126 |
|
public boolean equals(Object o) { |
127 |
|
if (! (o instanceof Task)) |
128 |
|
return false; |
129 |
|
|
130 |
|
Task otherTask = (Task) o; |
131 |
|
|
132 |
|
return this.getId() == otherTask.getId(); |
133 |
|
} |
134 |
|
|
135 |
/** |
/** |
136 |
* @throws Exception |
* @throws Exception |
137 |
* |
* |