public class LeaseRegistry extends java.lang.Object implements IOperation, ILeaseRegistry
Modifier and Type | Field and Description |
---|---|
static int |
EVENT_LEASE_EXPIRED
This event is fired whenever the lease that is observed by a
listener is expired.
|
static long |
PERIOD_DEFAULT
The default timeout period.
|
static long |
PERIOD_GRACE
This is the grace period that is automatically added to the timeout
period whenever lease is registered for the first time.
|
static long |
PERIOD_MAXIMUM
The maximum timeout period.
|
static long |
PERIOD_MINIMUM
The minimum timeout period.
|
static long |
PERIOD_REFRESH
The estimated period required to perform a refresh call.
|
static long |
PERIOD_WAIT
This is the time that lies between two calls to a system when
the first call produced an invocation exception.
|
REGISTRY_ID
Modifier and Type | Method and Description |
---|---|
Lease |
create(IListener listener)
Creates a new local lease with the default timeout period.
|
Lease |
create(IListener listener,
long timeout)
Creates a new local lease with the specified timeout period.
|
static LeaseRegistry |
getInstance()
Creates, registers and returns the local instance of the lease
registry.
|
void |
hook(Lease lease,
IListener listener)
Hooks up a listener to the specified lease that maintains
the lease.
|
void |
perform(IMonitor monitor)
This operation checks whether locally created leases are no
longer of interest to any remote system.
|
boolean |
remove(Lease lease)
Removes a specified lease that has been created locally and informs
all remote listeners about the removal.
|
boolean |
remove(Lease lease,
boolean notify)
Removes a specified lease that has been created locally.
|
void |
remove(SystemID system,
Lease lease)
Called by a remote lease registry to signal that a certain lease created
by this registry has been removed due to a call to the remove method.
|
boolean |
unhook(Lease lease,
IListener listener)
Unhooks a previously registered listener for a specified lease
from the registry.
|
boolean |
unhook(Lease lease,
IListener listener,
boolean notify)
Unhooks a previously registered listener for a specified lease
from the registry.
|
void |
unhook(SystemID system,
Lease lease)
Called by a remote lease registry whenever the remote system is no
longer interested in a local lease.
|
java.util.Vector |
update(SystemID system,
java.util.Vector leases)
Called by a remote system that is interested on a number of leases
created by this lease registry.
|
public static final long PERIOD_MINIMUM
public static final long PERIOD_DEFAULT
public static final long PERIOD_MAXIMUM
public static final long PERIOD_GRACE
public static final long PERIOD_REFRESH
public static final long PERIOD_WAIT
public static final int EVENT_LEASE_EXPIRED
public static LeaseRegistry getInstance()
public Lease create(IListener listener)
listener
- The listener that is notified whenever the
lease is expired. The listener must not be null.public Lease create(IListener listener, long timeout)
listener
- The listener that is called whenever the lease
is expired. The listener must not be null.timeout
- The timeout of the lease.public boolean remove(Lease lease)
lease
- The lease that should be removed. The lease must not
be null.public boolean remove(Lease lease, boolean notify)
lease
- The lease that should be removed. The lease must
not be null.notify
- True to indicate that all remote listeners should
be notified, false to indicate that the lease should be
removed silently for remote listeners.public void hook(Lease lease, IListener listener)
lease
- The lease that should be registered. The lease
must not be null.listener
- The listener that will listen to lease
expiration events. The listener must not be null.public boolean unhook(Lease lease, IListener listener)
lease
- The lease for which the listener has been created.
The lease must not be null.listener
- The listener that should be removed. The listener
must not be null.public boolean unhook(Lease lease, IListener listener, boolean notify)
lease
- The lease for which the listener has been created.
The lease must not be null.listener
- The listener that should be removed. The listener
must not be null.notify
- A flag that indicates whether the remote system
that hosts the lease should be notified of the removal. If the
flag is set to true, it will be notified if the lease is removed
completely, otherwise the lease will be removed silently.public void perform(IMonitor monitor) throws java.lang.Exception
perform
in interface IOperation
monitor
- The monitor used to stop the operation.java.lang.Exception
- Should never be thrown.public void unhook(SystemID system, Lease lease)
unhook
in interface ILeaseRegistry
system
- The remote system that is no longer observing a certain
lease.lease
- The lease that is no longer observed.public java.util.Vector update(SystemID system, java.util.Vector leases)
update
in interface ILeaseRegistry
system
- The system that is interested in the local leases.leases
- The leases of interest stored in a vector.public void remove(SystemID system, Lease lease)
remove
in interface ILeaseRegistry
system
- The system that has removed a lease.lease
- The lease that has been removed.