Skip to content
Permalink
Browse files
GERONIMO-5152 fix usage of timer tasks
  • Loading branch information
djencks committed Feb 22, 2010
1 parent a05b1a4 commit 1282d80a0b43ec5bae700029e177217a9b59a6a7
Showing 4 changed files with 19 additions and 5 deletions.
@@ -38,7 +38,7 @@
/**
* @version $Rev$ $Date$
*/
public class CommitTask extends TimerTask {
public class CommitTask implements Runnable {
private static final Logger log = LoggerFactory.getLogger(CommitTask.class);
private final Xid xid;
private final List<TransactionBranch> rms;
@@ -32,8 +32,22 @@ public class ExponentialtIntervalRetryScheduler implements RetryScheduler{

private final int base = 2;

public void retry(TimerTask task, int count) {
public void retry(Runnable task, int count) {
long interval = Math.round(Math.pow(base, count)) * 1000;
timer.schedule(task, interval);
timer.schedule(new TaskWrapper(task), interval);
}

private static class TaskWrapper extends TimerTask {

private final Runnable delegate;

private TaskWrapper(Runnable delegate) {
this.delegate = delegate;
}

@Override
public void run() {
delegate.run();
}
}
}
@@ -28,7 +28,7 @@
/**
* @version $Rev$ $Date$
*/
public class RecoverTask extends TimerTask {
public class RecoverTask implements Runnable {

private final RetryScheduler retryScheduler;
private final NamedXAResourceFactory namedXAResourceFactory;
@@ -27,5 +27,5 @@
*/
public interface RetryScheduler {

void retry(TimerTask task, int count);
void retry(Runnable task, int count);
}

0 comments on commit 1282d80

Please sign in to comment.