Class FarragoTimerAllocation

  extended by net.sf.farrago.util.FarragoTimerAllocation
All Implemented Interfaces:
FarragoAllocation, ClosableAllocation

public class FarragoTimerAllocation
extends Object
implements FarragoAllocation

FarragoTimerAllocation takes care of cancelling a Timer when it is closed. Cancellation is implemented synchronously and without any delay, making it easy to avoid shutdown races.

NOTE jvs 13-Aug-2007: The shutdown mechanism requires that cancellation not happen via any other means. If it does, the shutdown could result in an IllegalStateException or a hang. Use FarragoTimerTask to avoid the implicit cancellation which can occur when a timer task throws an exception.

$Id: //open/dev/farrago/src/net/sf/farrago/util/ $
John V. Sichi

Nested Class Summary
private  class FarragoTimerAllocation.CancelTask
          Helper class implementing synchronous cancellation.
Field Summary
private  Object shutdownSynch
private  Timer timer
Constructor Summary
FarragoTimerAllocation(FarragoAllocationOwner owner, Timer timer)
          Creates a new FarragoTimerAllocation.
Method Summary
 void closeAllocation()
          Closes this object.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


private Timer timer


private final Object shutdownSynch
Constructor Detail


public FarragoTimerAllocation(FarragoAllocationOwner owner,
                              Timer timer)
Creates a new FarragoTimerAllocation.

owner - the owner for the timer
timer - the timer to be cancelled when this allocation is closed
Method Detail


public void closeAllocation()
Description copied from interface: ClosableAllocation
Closes this object.

Specified by:
closeAllocation in interface ClosableAllocation