|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.exolab.core.service.Service | +--org.exolab.core.service.BasicService | +--org.exolab.jms.lease.LeaseManager
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).
We need to cater for persistence and non-persistent leases
Constructor Summary | |
protected |
LeaseManager()
Create a new sorted tree set using the lease comparator as the sorting functor. |
Method Summary | |
protected void |
addLease(BaseLease lease)
Add a lease |
BaseLease |
createLease(java.lang.Object object,
long duration,
LeaseEventListenerIfc listener)
Create a lease on any object for the specified duration. |
MessageLease |
createMessageLease(MessageHandle handle,
long duration,
LeaseEventListenerIfc listener)
Create a message lease with the specified duration and the nominated listener. |
protected void |
expire()
Expires active leases |
int |
getLeaseCount()
Returns the number of active leases |
static LeaseManager |
instance()
Return the singleton instance of the LeaseManager |
void |
removeAll()
Remove all the leases from the queue. |
boolean |
removeLease(BaseLease lease)
Remove the specified 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 |
void |
stop()
Stop the service. |
Methods inherited from class org.exolab.core.service.BasicService |
start, toString |
Methods inherited from class org.exolab.core.service.Service |
getName, getState, restart, setState |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected LeaseManager()
Method Detail |
public static LeaseManager instance()
public MessageLease createMessageLease(MessageHandle handle, long duration, LeaseEventListenerIfc listener)
The object must be non-null and the duration must be greater than zero.
handle
- message handleduration
- lease durationlistener
- object that implements the LeaseEvent-
ListenerIfcpublic BaseLease createLease(java.lang.Object object, long duration, LeaseEventListenerIfc listener)
The object must be non-null and the duration must be greater than zero.
object
- leased objectduration
- lease durationlistener
- object that implements the LeaseEvent-
ListenerIfcpublic boolean removeLease(BaseLease lease)
lease
- lease to removepublic BaseLease renewLease(BaseLease lease, long duration)
object
- object's whose lease we want to renewduration
- the new duration of the lease in mspublic void removeAll()
public int getLeaseCount()
public void run()
run
in class org.exolab.core.service.BasicService
public void stop() throws org.exolab.core.service.ServiceException
stop
in class org.exolab.core.service.BasicService
org.exolab.core.service.ServiceException
- if the service fails to stopprotected void expire()
protected void addLease(BaseLease lease)
lease
- the lease to add
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |