jrun.jms.core.messagemgr
Class MessageLeaseHelper

java.lang.Object
  |
  +--jrun.jms.core.messagemgr.MessageLeaseHelper
All Implemented Interfaces:
SchedulableEventListener

public class MessageLeaseHelper
extends java.lang.Object
implements SchedulableEventListener

This is a helper class for registering leases for messages with LeaseManager. The lease is based on the JMSExpiration property of the message.
When the lease expires, the listener's onLeaseExpired() method is invoked with a MessageHandle object passed as the argument.
If JMSExpiration is 0, the message never expires.

Version:
$Revision: 1.8 $ $Date: 2001/09/03 23:43:18 $
Author:
Tim Anderson
See Also:
org.exolab.jms.messagemgr.MessageHandle, org.exolab.jms.messagemgr.MessagePriorityCache, org.exolab.jms.messagemgr.PersistentPriorityCache, org.exolab.jms.lease.LeaseManager, org.exolab.jms.lease.LeaseEventListenerIfc

Constructor Summary
MessageLeaseHelper(DestinationCache listener)
          Construct a helper for the specified destination cache.
 
Method Summary
 void addLease(MessageHandle handle)
          Add a lease for the handle to notify listener when message expires.
 void addLease(MessageImpl message)
          Add a lease for message to notify listener when message expires.
 void clear()
          Clears all leases
protected  Logger getLogger()
          Return a reference to the logger
 void onSchedulableEvent(java.lang.Object handle, int type)
          Invoked when a lease has expired.
 void removeLease(MessageImpl message)
          Remove a lease for a message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageLeaseHelper

public MessageLeaseHelper(DestinationCache listener)
                   throws MessageLeaseHelperException
Construct a helper for the specified destination cache. It throws the MessageLeaseException if it fails to construct an instance.
Parameters:
listener - the object to notify when a lease expires
Throws:
MessageLeaseHelperException -  
Method Detail

addLease

public void addLease(MessageImpl message)
Add a lease for message to notify listener when message expires. The lease uses JMSExpiration property of the message. If this is unset or 0, then no lease is registered. If non-zero, a MessageHandle object is registered with LeaseManager, and the listener will be notified with this object when the lease expires.
Parameters:
message - the message to add a lease for

addLease

public void addLease(MessageHandle handle)
Add a lease for the handle to notify listener when message expires. The lease uses JMSExpiration property of the message. If this is unset or 0, then no lease is registered. If non-zero, a MessageHandle object is registered with LeaseManager, and the listener will be notified with this object when the lease expires.
Parameters:
handle - message handle to add

removeLease

public void removeLease(MessageImpl message)
Remove a lease for a message
Parameters:
message - the message to remove the lease for

clear

public void clear()
Clears all leases

onSchedulableEvent

public void onSchedulableEvent(java.lang.Object handle,
                               int type)
Invoked when a lease has expired.
It removes the local lease, and notifies the listener.
Specified by:
onSchedulableEvent in interface SchedulableEventListener
Parameters:
handle - An instance of MessageHandle

getLogger

protected Logger getLogger()
Return a reference to the logger
Returns:
Logger


Copyright � 2002 Macromedia Corporation. All Rights Reserved.