BrightSide Workbench Full Report + Source Code
elephant/src/main/java/org/turro/queue/AbstractTask.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2015 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.queue;
20 
21 import java.util.Date;
22 
27 public abstract class AbstractTask implements Task {
28 
29  protected String label, image, message;
30  protected boolean reintent = false;
31  protected Date call, execution;
33 
34  @Override
35  public String getLabel() {
36  return label;
37  }
38 
39  public void setLabel(String label) {
40  this.label = label;
41  }
42 
43  @Override
44  public String getImage() {
45  return image;
46  }
47 
48  public void setImage(String image) {
49  this.image = image;
50  }
51 
52  @Override
53  public String getMessage() {
54  return message;
55  }
56 
57  public void setMessage(String message) {
58  this.message = message;
59  }
60 
61  @Override
62  public boolean isReintent() {
63  return reintent;
64  }
65 
66  public void setReintent(boolean reintent) {
67  this.reintent = reintent;
68  }
69 
70  @Override
71  public Date getCall() {
72  return call;
73  }
74 
75  @Override
76  public Date getExecution() {
77  return execution;
78  }
79 
80  @Override
81  public TaskStatus getStatus() {
82  return status;
83  }
84 
85  public void setStatus(TaskStatus status) {
86  this.status = status;
87  }
88 
89  @Override
90  public boolean isInterrupted() {
91  return Tasks.isInterrupted();
92  }
93 
94  public abstract boolean doExecute();
95 
96  @Override
97  public void execute() {
99  if(doExecute()) {
100  execution = new Date();
102  } else {
103  execution = new Date();
105  }
106  Tasks.execute();
107  }
108 
109 }
abstract boolean doExecute()