FileDocCategorySizeDatePackage
InstanceTimer.javaAPI DocGlassfish v2 API3633Fri May 04 22:24:32 BST 2007com.sun.enterprise.admin.servermgmt.pe

InstanceTimer

public final class InstanceTimer extends Object implements Runnable

Fields Summary
private final int
timeOutSeconds
private final TimerCallback
callBack
private final int
startAfterSeconds
private boolean
timeOutReached
private long
startTime
Constructors Summary
public InstanceTimer(int timeOutSeconds, int startAfterSeconds, TimerCallback callBack)

        this.timeOutSeconds     = timeOutSeconds;
        this.startAfterSeconds  = startAfterSeconds;
        this.callBack           = callBack;
        this.timeOutReached     = false;
    
Methods Summary
private voidcomputeTimeOut()

        long currentTime = System.currentTimeMillis();
        timeOutReached =
            ((currentTime - startTime) >= (timeOutSeconds * 1000));
    
public voidrun()

        startTime = System.currentTimeMillis();
        try
        {
            Thread.currentThread().sleep(startAfterSeconds * 1000);
            while (!timeOutReached() && !callBack.check())
            {
                try
                {
                    Thread.currentThread().sleep(1000);
                    computeTimeOut();
                }
                catch (InterruptedException ie)
                {
                    //sLogger.warning(ie.toString());
                    timeOutReached = true;
                }
            }
        }
        catch (Exception e)
        {
            //sLogger.warning(e.toString());
            timeOutReached = true;
        }
    
private booleantimeOutReached()

        return timeOutReached;