/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/tasks/Task.java
ViewVC logotype

Diff of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/tasks/Task.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2903 by torben, Wed Feb 3 18:45:33 2016 UTC revision 2918 by torben, Thu Feb 4 14:40:36 2016 UTC
# Line 21  public abstract class Task implements Ru Line 21  public abstract class Task implements Ru
21                  public String state;                  public String state;
22          }          }
23                    
24          protected boolean abort = false;          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                    
# Line 49  public abstract class Task implements Ru Line 49  public abstract class Task implements Ru
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();
# Line 91  public abstract class Task implements Ru Line 96  public abstract class Task implements Ru
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();
# Line 107  public abstract class Task implements Ru Line 117  public abstract class Task implements Ru
117                  return this.errorMsg;                  return this.errorMsg;
118          }          }
119                    
120            @Override
121            public final boolean equals(Object o) {
122                    Task otherTask = (Task) o;
123                    
124                    return this.getId() == otherTask.getId();
125            }
126            
127          /**          /**
128           * @throws Exception           * @throws Exception
129           *           *

Legend:
Removed from v.2903  
changed lines
  Added in v.2918

  ViewVC Help
Powered by ViewVC 1.1.20