public Date getTerminationTime() { return _terminationTimer.getScheduledTime(); }
public Date setTerminationTime(Date time) { // // case 1: null time, so we're cancelling the timer // if (time == null) _terminationTimer.cancel(); // // case 2: valid time, no previous time, we're scheduling // the timer for the first time // else if (_terminationTimer.getScheduledTime() == null) { TimerTask terminationTask = new DestroyTimerTask(getWsResource()); _terminationTimer.schedule(terminationTask, time); } // // case 3: valid time, previous time exists, we're rescheduling // else { TimerTask terminationTask = new DestroyTimerTask(getWsResource()); _terminationTimer.reschedule(terminationTask, time); } return time; }
/** * * Cancels the timer (if it is currently scheduled) and reschedules it * for the given time. * * @param task * The code to run when the timer is up. * * @param whenToFire * The new fire time for the timer. * */ public final void reschedule(TimerTask task, Date whenToFire) { if (task == null) throw new NullPointerException(_MESSAGES.get("NullTimerTask")); if (whenToFire == null) throw new NullPointerException(_MESSAGES.get("NullFireTime")); // // you can't reschedule a java.util.Timer, so we just kill it // and make a new one // cancel(); _timer = new java.util.Timer(); schedule(task, whenToFire); }
/** * * Executes the timer's task whether the timer is scheduled or not. The * implementation first tries to cancel the timer, then executes the * task directly (via TimerTask.run()). * */ public final void executeNow() { cancel(); _task.run(); }
public void shutdown() throws SoapFault { // // make sure we stop the timer so we don't get a concurrency error // by trying to terminate ourselves in the midst of termination // _terminationTimer.cancel(); super.shutdown(); }