Browse Source

-javadoc and break if the task executes cleanly

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@539329 13f79535-47bb-0310-9956-ffa450edef68
master
Kevin Jackson 18 years ago
parent
commit
c97b3c60d5
1 changed files with 18 additions and 4 deletions
  1. +18
    -4
      src/main/org/apache/tools/ant/taskdefs/Retry.java

+ 18
- 4
src/main/org/apache/tools/ant/taskdefs/Retry.java View File

@@ -17,9 +17,6 @@
*/
package org.apache.tools.ant.taskdefs;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
@@ -30,22 +27,39 @@ import org.apache.tools.ant.TaskContainer;
*/
public class Retry extends Task implements TaskContainer {
/**
* task to execute n times
*/
private Task nestedTask;
private int retryCount;
/**
* set retryCount to 1 by default
*/
private int retryCount = 1;
/**
* set the task
*/
public void addTask(Task t) {
nestedTask = t;
}
/**
* set the number of times to retry the task
* @param n
*/
public void setRetryCount(int n) {
retryCount = n;
}
/**
* perform the work
*/
public void execute() throws BuildException {
for(int i=0; i<=retryCount; i++) {
try {
nestedTask.perform();
break;
} catch (Exception e) {
if (i<retryCount) {
log("Attempt ["+i+"] error occured, retrying...", e, Project.MSG_INFO);


Loading…
Cancel
Save