/*
 * 
 * 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.discovery;

import net.jini.discovery.DiscoveryListener;
import net.jini.core.lookup.ServiceRegistrar;

/**
 * This interface defines methods related to the discovery event mechanism
 * and discovery process termination. Through this interface an entity can
 * register or un-register for discovery events, discard a lookup service,
 * or terminate the discovery process.
 *
 * @author Sun Microsystems, Inc.
 */
public interface DiscoveryManagement {

    /**
     * Adds an instance of <code>DiscoveryListener</code> to the set of
     * objects listening for discovery events. Once the listener is
     * registered, it will be notified of all lookup services discovered
     * to date, and will then be notified as new lookup services are
     * discovered or existing lookup services are discarded.
     * <p>
     * If <code>null</code> is input, this method takes no action. If the
     * listener input to this method duplicates (using the <code>equals</code>
     * method) another element in the current set of listeners, no action
     * is taken.
     *
     * @param listener an instance of <code>DiscoveryListener</code> 
     *                 corresponding to the listener to add to the set of
     *                 listeners.
     * @see #removeDiscoveryListener
     * @see net.jini.discovery.DiscoveryListener
     */
    public void addDiscoveryListener(DiscoveryListener listener);

    /**
     * Removes a listener from the set of objects listening for discovery
     * events. If the listener object input to this method does not exist
     * in the set of listeners, then this method will take no action.
     *
     * @param listener an instance of <code>DiscoveryListener</code>
     *                 corresponding to the listener to remove from the set
     *                 of listeners.
     *
     * @see #addDiscoveryListener
     * @see net.jini.discovery.DiscoveryListener
     */
    public void removeDiscoveryListener(DiscoveryListener listener);

    /**
     * Returns an array of instances of <code>ServiceRegistrar</code>, each
     * corresponding to a proxy to one of the currently discovered lookup
     * services. For each invocation of this method, a new array is returned.
     *
     * @return array of instances of <code>ServiceRegistrar</code>, each
     *         corresponding to a proxy to one of the currently discovered
     *         lookup services
     *
     * @see net.jini.core.lookup.ServiceRegistrar
     */
    public ServiceRegistrar[] getRegistrars();

    /**
     * Removes an instance of <code>ServiceRegistrar</code> from the
     * managed set of lookup services, making the corresponding lookup
     * service eligible for re-discovery. This method takes no action if
     * the parameter input to this method is <code>null</code>, or if it
     * does not match (using <code>equals</code>) any of the elements in
     * the managed set.
     *
     * @param proxy the instance of <code>ServiceRegistrar</code> to remove
     *              from the managed set of lookup services
     *
     * @see net.jini.core.lookup.ServiceRegistrar
     */
   public void discard(ServiceRegistrar proxy);

    /**
     * Ends all discovery processing being performed by the current
     * implementation of this interface. After this method is invoked,
     * no new lookup services will be discovered, and the effect of any
     * new operations performed on the current implementation object are
     * undefined. Any additional termination semantics must be defined
     * by the implementation class itself.
     */
    public void terminate();
}
