1 package org.sapia.taskman; 2 3 22 public abstract class RetryTask implements Abortable, Task { 23 private boolean _aborted; 24 private int _count = 0; 25 private int _maxRetries; 26 27 34 protected RetryTask(int maxRetries) { 35 _maxRetries = maxRetries; 36 } 37 38 41 public void exec(TaskContext ctx) { 42 doExec(ctx); 43 _count++; 44 } 45 46 49 public boolean isAborted() { 50 return _aborted || (_count > _maxRetries); 51 } 52 53 public int getRetryCount() { 54 return _count; 55 } 56 57 public int getMaxRetries() { 58 return _maxRetries; 59 } 60 61 protected void abort() { 62 _aborted = true; 63 } 64 65 74 protected abstract void doExec(TaskContext ctx); 75 } 76 | Popular Tags |