1 18 package net.sf.mybatchfwk; 19 20 import java.util.Date ; 21 import java.util.Iterator ; 22 23 import net.sf.mybatchfwk.history.IExecutionHistory; 24 25 34 public class ExecutionReport { 35 36 39 protected Date beginDate; 40 41 44 protected Date endDate; 45 46 49 protected volatile long numberOfCompletedTasks; 50 51 54 protected volatile long numberOfFailedTasks; 55 56 59 protected IExecutionHistory history; 60 61 64 public ExecutionReport() { 65 } 66 67 public ExecutionReport(IExecutionHistory history) { 68 this.history = history; 69 } 70 71 75 public void reportCompletion(ITask task) { 76 numberOfCompletedTasks++; 77 } 78 79 84 public void reportFailure(ITask task, Throwable throwable) { 85 numberOfFailedTasks++; 86 } 87 88 93 public Iterator completedTasksIdIterator() throws BatchException { 94 if (history != null) { 95 return history.completedTasksIdIterator(); 96 } 97 return null; 98 } 99 100 105 public Iterator failedTasksIdIterator() throws BatchException { 106 if (history != null) { 107 return history.failedTasksIdIterator(); 108 } 109 return null; 110 } 111 112 @Override 113 public String toString() { 114 StringBuffer buffer = new StringBuffer ("[") 115 .append("beginDate='").append(beginDate) 116 .append("', endDate='").append(endDate) 117 .append("', numberOfCompletedTasks='").append(numberOfCompletedTasks) 118 .append("', numberOfFailedTasks='").append(numberOfFailedTasks) 119 .append("']"); 120 return buffer.toString(); 121 } 122 123 127 131 public Date getBeginDate() { 132 return beginDate; 133 } 134 135 139 public void setBeginDate(Date beginDate) { 140 this.beginDate = beginDate; 141 } 142 143 147 public Date getEndDate() { 148 return endDate; 149 } 150 151 155 public void setEndDate(Date endDate) { 156 this.endDate = endDate; 157 } 158 159 162 public long getNumberOfCompletedTasks() { 163 return numberOfCompletedTasks; 164 } 165 166 169 public long getNumberOfFailedTasks() { 170 return numberOfFailedTasks; 171 } 172 173 176 public IExecutionHistory getHistory() { 177 return history; 178 } 179 180 183 public void setHistory(IExecutionHistory history) { 184 this.history = history; 185 } 186 } 187 | Popular Tags |