org.exolab.jms.lease
Class LeaseManager

java.lang.Object
  extended by org.exolab.jms.service.Service
      extended by org.exolab.jms.service.BasicService
          extended by org.exolab.jms.lease.LeaseManager
All Implemented Interfaces:
java.lang.Runnable, Serviceable

public class LeaseManager
extends BasicService

The LeaseManager is responsible for creating and managing the lease objects. The Leasemanager is a singleton. When a BaseLease object is created it is added to the queue according to the duration (i.e. leases with shorter durations are placed at the top of the queue.

When the lease expires the LeeaseManager calls the leasee's associated listener(s).

Version:
$Revision: 1.4 $ $Date: 2005/12/26 04:45:30 $
Author:
Jim Alateras

Constructor Summary
LeaseManager()
          Create a new sorted tree set using the lease comparator as the sorting functor.
 
Method Summary
 void addLease(BaseLease lease)
          Add a lease.
 void doStop()
          Stop the service.
protected  void expire()
          Expires active leases
 void removeAll()
          Remove all the leases from the queue.
 boolean removeLease(BaseLease lease)
          Remove a lease.
 BaseLease renewLease(BaseLease lease, long duration)
          Renew the lease on the specified object
 void run()
          The run method will search for expired leases, remove them from the list and notify listeners
 
Methods inherited from class org.exolab.jms.service.BasicService
doStart, toString
 
Methods inherited from class org.exolab.jms.service.Service
getName, isStarted, restart, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LeaseManager

public LeaseManager()
Create a new sorted tree set using the lease comparator as the sorting functor.

Method Detail

addLease

public void addLease(BaseLease lease)
Add a lease.

Parameters:
lease - the lease to add

removeLease

public boolean removeLease(BaseLease lease)
Remove a lease.

Parameters:
lease - lease to remove
Returns:
boolean true if successful; false otherwise

renewLease

public BaseLease renewLease(BaseLease lease,
                            long duration)
Renew the lease on the specified object

Parameters:
lease - the lease to renew
duration - the new duration of the lease in ms

removeAll

public void removeAll()
Remove all the leases from the queue. Do not expire any of them


run

public void run()
The run method will search for expired leases, remove them from the list and notify listeners


doStop

public void doStop()
            throws ServiceException
Stop the service.

Overrides:
doStop in class BasicService
Throws:
ServiceException - if the service fails to stop

expire

protected void expire()
Expires active leases



Copyright © 1999-2012 The OpenJMS Group. All Rights Reserved.