net.jini.lookup.JoinManager
Class that is registered as a listener with this join manager's lease renewal manager. That lease renewal manager manages the lease granted to this join manager's associated service by the lookup service referenced in the proxy object associated with this class (ProxyReg
). If the lease expires in the lookup service before the lease renewal manager requests renewal of the lease, then upon sending that renewal request, the lease renewal manager will receive an UnknownLeaseException
from the lookup service. As a result, the lease renewal manager removes the expired lease so that no further renewal attempts are made for that lease, and then sends to this listener a LeaseRenewalEvent
, containing an UnknownLeaseException
. Alternatively, suppose that at the time the lease renewal manager is about to request the renewal of the lease, the lease renewal manager determines that the expiration time of the lease has actually passed. In this case, since there is no reason to send the renewal request, the lease renewal manager instead removes the expired lease (again, so that no further renewal attempts are made for that lease), and then sends a LeaseRenewalEvent
to this listener to indicate that the lease has expired. The difference between this case, and the case described previously is that in this case the LeaseRenewalEvent
contains no exception (that is, LeaseRenewalEvent.getException
returns null
). Both situations described above indicate that the lease referenced by the event received by this listener has expired. Thus, the normal course of action should be to attempt to re-register the service with the lookup service that originally granted the lease that has expired. Prior to re-registering the service, the joinSet is examined to determine if it contains a ProxyReg object that is equivalent to the ProxyReg object referencing the current instance of this listener class. That is, using equals
, it is determined whether the joinSet contains either ProxyReg.this, or a new instance of ProxyReg that is equal to ProxyReg.this. If the joinSet does not contain such a ProxyReg, then the lookup service must have been discarded and not yet re-discovered; in which case, there is no need to attempt to re-register with that lookup service, since it is unavailable. If it is determined that the joinSet does contain either ProxyReg.this or a new ProxyReg equivalent to ProxyReg.this, then re-registration should be attempted, but only if the lease associated with the ProxyReg in the joinSet is equal to the expired lease referenced in the event received by this listener. Equality of those leases is an indication that the lease on the service's current registration has expired; thus, an attempt to re-register the service should be made. If the lease associated with the ProxyReg from the joinSet does not equal the expired lease from the event, then re-registration should not be attempted. This is because the inequality of the leases is an indication that the lease renewal event received by this listener was the result of an UnknownLeaseException
that occurs when the ProxyReg in the joinSet is a new ProxyReg, different from ProxyReg.this, and the lease renewal manager requests the renewal of the (now invalid) lease associated with that old ProxyReg.this; not the valid lease associated with the new ProxyReg. A scenario such as that just described can occur when the lookup service is discarded, rediscovered, and the service is re-registered, resulting in a new ProxyReg (with new lease) being placed in the joinSet, replacing the previous ProxyReg (ProxyReg.this). But before the old, expired lease is removed from the lease renewal manager, an attempt to renew the old lease is made. Such an attempt can occur because the lease renewal manager may be in the process of requesting the renewal of that lease (or may have queued such a request) just prior to, or at the same time as, when the lease removal request is made during discard processing. When the request is made to renew the expired lease, an UnknownLeaseException
occurs and a lease renewal event is sent to this listener. If, upon receiving an event such as that just described, the service were to be re-registered, the current valid service registration would be replaced, a new lease would be granted, and the corresponding ProxyReg currently contained in the joinSet would be replaced with a new ProxyReg. Additionally, the now invalid lease corresponding to the ProxyReg that was just replaced would remain in the lease renewal manager. This means that an attempt to renew that lease will eventually be made and will fail, and the cycle just described will repeat indefinitely. Thus, for the reasons stated above, re-registration is attempted only if the lease associated with the ProxyReg contained in the joinSet is equal to the expired lease referenced in the lease renewal event received by this listener.