1 4 package net.sf.mybatchfwk.test; 5 6 import net.sf.mybatchfwk.TaskExecutionException; 7 import net.sf.mybatchfwk.ITask; 8 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 12 13 public class MyTask implements ITask { 14 15 private static final Log log = LogFactory.getLog(MyTask.class); 16 17 private int id = 0; 18 19 public MyTask(int i) { 20 id = i; 21 } 22 23 public String getId() { 24 return Integer.toString(id); 25 } 26 27 public void run() { 28 log.info("[Task '" + getId() + "'] begin of execution"); 29 if (id == 3) { 30 throw new TaskExecutionException("error of execution"); 31 } 32 try { 33 Thread.sleep(2000); 34 } catch (InterruptedException e) { 35 throw new TaskExecutionException(e); 36 } 37 log.info("[Task '" + getId() + "'] execution done"); 38 } 39 } 40 | Popular Tags |