/*
 * 
 * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * The contents of this file are subject to the Sun Community Source
 * License v3.0/Jini Technology Specific Attachment v 1.0 (the
 * "License"). You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 * http://wwws.sun.com/software/jini/licensing/SCSL3_JiniTSA1.html.
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 * 
 * The Reference Code is Jini Technology Core Platform code, v2.0. The
 * Developer of the Reference Code is Sun Microsystems, Inc.
 * 
 * Contributor(s): Sun Microsystems, Inc.
 * 
 * The contents of this file comply with the Jini Technology Core
 * Platform Compatibility Kit, v2.0A.
 * 
 * Tester(s): Sun Microsystems, Inc.
 * 
 * Test Platform(s):
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Solaris(TM)SPARC/x86
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Linux (Intel x86)
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Windows (Intel Platform)
 * 
 */

package net.jini.lease;

import java.util.EventListener;
import net.jini.core.lease.Lease;

/** 
 * The interface that receivers of <code>LeaseRenewalEvent</code>
 * instances must implement.
 * <p>
 * With respect to an entity that uses the
 * <code>LeaseRenewalManager</code> to manage leases granted to the
 * entity, this interface defines the mechanism through which an entity
 * receives notification that the <code>LeaseRenewalManager</code> has
 * failed to renew one of the leases the
 * <code>LeaseRenewalManager</code> is managing for the entity. Such
 * renewal failures typically occur because of one of the following
 * conditions is met:
 * <ul>
 *   <li> After successfully renewing a lease any number of times and
 *        experiencing no failures, the <code>LeaseRenewalManager</code>
 *        determines, prior to the next renewal attempt, that the actual
 *        expiration time of the lease has passed, implying that any
 *        further attempt to renew the lease would be fruitless.
 *   <li> An indefinite exception occurs during each attempt to renew a
 *        lease, from the point that the first such exception occurs
 *        until the point when the <code>LeaseRenewalManager</code>
 *        determines that lease's actual expiration time has passed.
 *   <li> A bad object, bad invocation, or <code>LeaseException</code>
 *        occurs during a lease renewal attempt (collectively referred
 *        to as definite exceptions).
 * </ul>
 * It is the responsibility of the entity to register with the
 * <code>LeaseRenewalManager</code>. The object that implements this
 * interface should define the actions to take upon receipt of such
 * notifications. Then, when one of the above conditions occurs, the
 * <code>LeaseRenewalManager</code> will send an instance of the
 * <code>LeaseRenewalEvent</code> class to that listener object. Note
 * that, prior to sending the event, the
 * <code>LeaseRenewalManager</code> will remove the affected lease from
 * its managed set of leases.
 *
 * @author Sun Microsystems, Inc.
 * @see Lease
 * @see LeaseRenewalManager
 * @see LeaseRenewalEvent
 */
public interface LeaseListener extends EventListener {
    /**
     * Called by the <code>LeaseRenewalManager</code> when it cannot
     * renew a lease that it is managing, and the lease's desired
     * expiration time has not yet been reached.
     * <p>
     * Note that, prior to invoking this method, the
     * <code>LeaseRenewalManager</code> removes the affected lease from
     * the managed set of leases. Note also that, because of the
     * reentrancy guarantee made by the
     * <code>LeaseRenewalManager</code>, new leases can be safely added
     * by this method.
     *
     * @param e instance of <code>LeaseRenewalEvent</code> containing
     *		information about the lease that the
     *		<code>LeaseRenewalManager</code> was unable to renew, as
     *		well as information about the condition that made the
     *		<code>LeaseRenewalManager</code> fail to renew the lease
     */
    void notify(LeaseRenewalEvent e);
}
