Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/LookupLocatorDiscovery.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/LookupLocatorDiscovery.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/LookupLocatorDiscovery.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/LookupLocatorDiscovery.java Sun Oct 26 13:17:28 2014 @@ -1,331 +1,337 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.jini.discovery; - -import java.util.logging.Logger; -import net.jini.config.Configuration; -import net.jini.config.ConfigurationException; -import net.jini.core.discovery.LookupLocator; - -/** - * This class encapsulates the functionality required of an entity that - * wishes to employ the unicast discovery protocol to discover a lookup - * service. This utility provides an implementation that makes the process - * of finding specific lookup services much simpler for both services and - * clients. - * <p> - * Because this class participates in only the unicast discovery protocol, - * and because the unicast discovery protocol imposes no restriction on the - * physical location of the entity relative to a lookup service, this utility - * can be used to discover lookup services running on hosts that are located - * far from, or near to, the host on which the entity is running. This lack - * of a restriction on location brings with it a requirement that the - * discovering entity supply this class with specific information about the - * desired lookup services; namely, the location of the device(s) hosting - * each lookup service. This information is supplied through an instance - * of the {@link net.jini.core.discovery.LookupLocator LookupLocator} class, - * or its subclass {@link net.jini.discovery.ConstrainableLookupLocator - * ConstrainableLookupLocator}. - * - * @com.sun.jini.impl <!-- Implementation Specifics --> - * - * The following implementation-specific items are discussed below: - * <ul><li> <a href="#lldConfigEntries">Configuring LookupLocatorDiscovery</a> - * <li> <a href="#lldLogging">Logging</a> - * </ul> - * - * <a name="lldConfigEntries"> - * <p> - * <b><font size="+1">Configuring LookupLocatorDiscovery</font></b> - * <p> - * </a> - * - * This implementation of <code>LookupLocatorDiscovery</code> supports the - * following configuration entries; where each configuration entry name - * is associated with the component name - * <code>net.jini.discovery.LookupLocatorDiscovery</code>. Note that the - * configuration entries specified here are specific to this implementation - * of <codeLookupLocatorDiscovery</code>. Unless otherwise stated, each - * entry is retrieved from the configuration only once per instance of - * this utility, where each such retrieval is performed in the constructor. - * - * <a name="initialUnicastDelayRange"> - * <table summary="Describes the initialUnicastDelayRange - * configuration entry" border="0" cellpadding="2"> - * <tr valign="top"> - * <th scope="col" summary="layout"> <font size="+1">•</font> - * <th scope="col" align="left" colspan="2"> <font size="+1"> - * <code>initialUnicastDelayRange</code></font> - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Type: <td> <code>long</code> - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Default: <td> <code>0 milliseconds</code> - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Description: - * <td> With respect to when this utility is started, this entry controls - * how long to wait before attempting unicast discovery. - * If the value is positive, initial unicast discovery requests - * will be delayed by a random value between <code>0</code> and - * <code>initialUnicastDelayRange</code> milliseconds. Once the wait - * period is up, the <code>LookupLocator</code>s specified at construction - * time are used for initiating unicast discovery requests, unless the - * managed <code>LookupLocator</code>s have been changed in the interim; - * in which case, no delayed unicast discovery requests are performed. - * Note that this entry only has effect when this utility is initialized. - * It does not delay discovery requests that are initiated if the managed - * <code>LookupLocator</code>s are subsequently changed. - * </table> - * <a name="registrarPreparer"> - * <table summary="Describes the registrarPreparer configuration entry" - * border="0" cellpadding="2"> - * <tr valign="top"> - * <th scope="col" summary="layout"> <font size="+1">•</font> - * <th scope="col" align="left" colspan="2"> <font size="+1"> - * <code>registrarPreparer</code></font> - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Type: <td> {@link net.jini.security.ProxyPreparer} - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Default: <td> <code>new {@link net.jini.security.BasicProxyPreparer}() - * </code> - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Description: - * <td> Preparer for the proxies to the lookup services that are - * discovered and used by this utility. - * <p> - * This preparer should perform all operations required to use a - * newly received proxy to a lookup service, which may including - * verifying trust in the proxy, granting permissions, and setting - * constraints. - * <p> - * Currently, none of the methods on the - * {@link net.jini.core.lookup.ServiceRegistrar ServiceRegistrar} - * returned by this preparer are invoked by this implementation of - * <code>LookupLocatorDiscovery</code>. - * </table> - * - * <a name="taskManager"> - * <table summary="Describes the taskManager configuration entry" - * border="0" cellpadding="2"> - * <tr valign="top"> - * <th scope="col" summary="layout"> <font size="+1">•</font> - * <th scope="col" align="left" colspan="2"> <font size="+1"> - * <code>taskManager</code></font> - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Type: <td> {@link com.sun.jini.thread.TaskManager} - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Default: <td> <code>new - * {@link com.sun.jini.thread.TaskManager#TaskManager() - * TaskManager}(15, (15*1000), 1.0f)</code> - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Description: - * <td> The object that pools and manages the various threads - * executed by this utility. The default manager creates a - * maximum of 15 threads, waits 15 seconds before removing - * idle threads, and uses a load factor of 1.0 when - * determining whether to create a new thread. This object - * should not be shared with other components in the - * application that employs this utility. - * </table> - * - * <a name="wakeupManager"> - * <table summary="Describes the wakeupManager configuration entry" - * border="0" cellpadding="2"> - * <tr valign="top"> - * <th scope="col" summary="layout"> <font size="+1">•</font> - * <th scope="col" align="left" colspan="2"> <font size="+1"> - * <code>wakeupManager</code></font> - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Type: <td> {@link com.sun.jini.thread.WakeupManager} - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Default: <td> <code>new - * {@link com.sun.jini.thread.WakeupManager#WakeupManager( - * com.sun.jini.thread.WakeupManager.ThreadDesc) - * WakeupManager}(new - * {@link com.sun.jini.thread.WakeupManager.ThreadDesc}(null,true))</code> - * - * <tr valign="top"> <td>   <th scope="row" align="right"> - * Description: - * <td> Object that pools and manages the various tasks that are - * initially executed by the object corresponding to the - * <a href="#taskManager"><code>taskManager</code></a> entry - * of this component, but which fail during that initial execution. - * This object schedules the re-execution of such a failed task - - * in the <a href="#taskManager"><code>taskManager</code></a> - * object - at various times in the future, (employing a - * "backoff strategy"). The re-execution of the failed task will - * continue to be scheduled by this object until the task finally - * succeeds. This object should not be shared with other components - * in the application that employs this utility. - * </table> - * - * <a name="lldLogging"> - * <p> - * <b><font size="+1">Logging</font></b> - * <p> - * </a> - * - * This implementation of <code>LookupLocatorDiscovery</code> uses the - * {@link Logger} named <code>net.jini.discovery.LookupLocatorDiscovery</code> - * to log information at the following logging levels: <p> - * - * <table border="1" cellpadding="5" - * summary="Describes the information logged by LookupLocatorDiscovery, - * and the levels at which that information is logged"> - * - * <caption halign="center" valign="top"> - * <b><code>net.jini.discovery.LookupLocatorDiscovery</code></b> - * </caption> - * - * <tr> <th scope="col"> Level</th> - * <th scope="col"> Description</th> - * </tr> - * - * <tr> - * <td>{@link java.util.logging.Level#INFO INFO}</td> - * <td> - * when any exception occurs in a task or thread, while attempting unicast - * discovery of a given locator - * </td> - * </tr> - * <tr> - * <td>{@link java.util.logging.Level#INFO INFO}</td> - * <td>when any exception occurs while attempting to prepare a proxy</td> - * </tr> - * <tr> - * <td>{@link com.sun.jini.logging.Levels#HANDLED HANDLED}</td> - * <td> - * when an exception is handled during unicast discovery. - * </td> - * </tr> - * <tr> - * <td>{@link java.util.logging.Level#FINEST FINEST}</td> - * <td>whenever any thread or task is started</td> - * </tr> - * - * <tr> - * <td>{@link java.util.logging.Level#FINEST FINEST}</td> - * <td> - * whenever any thread (except the <code>Notifier</code> thread) or task - * completes successfully - * </td> - * </tr> - * - * <tr> - * <td>{@link java.util.logging.Level#FINEST FINEST}</td> - * <td>whenever a discovered or discarded event is sent</td> - * </tr> - * - * <tr> - * <td>{@link java.util.logging.Level#FINEST FINEST}</td> - * <td>whenever a proxy is prepared</td> - * </tr> - * - * <tr> - * <td>{@link java.util.logging.Level#FINEST FINEST}</td> - * <td> - * when an <code>IOException</code> occurs upon attempting to close the - * socket after a unicast discovery attempt has either completed - * successfully or failed - * </td> - * </tr> - * </table> - * <p> - * - * This implementation of <code>LookupLocatorDiscovery</code> determines - * the constraints (if any) to apply to unicast discovery for a given - * {@link net.jini.core.discovery.LookupLocator LookupLocator} instance - * by calling the - * {@link net.jini.core.constraint.RemoteMethodControl#getConstraints - * getConstraints} method of that instance, if it implements the - * {@link net.jini.core.constraint.RemoteMethodControl RemoteMethodControl} - * interface. If the {@link net.jini.core.discovery.LookupLocator - * LookupLocator} instance does not implement - * {@link net.jini.core.constraint.RemoteMethodControl RemoteMethodControl}, - * then no constraints are applied to unicast discovery for that instance. - * <p> - * For more information on constraining unicast discovery, refer to the - * documentation for the {@link net.jini.discovery.ConstrainableLookupLocator - * ConstrainableLookupLocator} class. - * - * @author Sun Microsystems, Inc. - * - * @see net.jini.core.discovery.LookupLocator - */ -public class LookupLocatorDiscovery extends AbstractLookupLocatorDiscovery - implements DiscoveryManagement, - DiscoveryLocatorManagement -{ - /** - * Creates an instance of this class (<code>LookupLocatorDiscovery</code>), - * with an initial array of <code>LookupLocator</code>s to be managed. - * For each managed <code>LookupLocator</code>, unicast discovery is - * performed to obtain a <code>ServiceRegistrar</code> proxy for that - * lookup service. - * - * @param locators the locators to discover - * - * @throws java.lang.NullPointerException input array contains at least - * one <code>null</code> element - */ - public LookupLocatorDiscovery(LookupLocator[] locators) { - super(); - super.beginDiscovery(locators); - }//end constructor - - /** - * Constructs a new lookup locator discovery object, set to discover the - * given set of locators, and having the given <code>Configuration</code>. - * <p> - * For each managed <code>LookupLocator</code>, unicast discovery is - * performed to obtain a <code>ServiceRegistrar</code> proxy for that - * lookup service. - * - * @param locators the locators to discover - * - * @param config an instance of <code>Configuration</code>, used to - * obtain the objects needed to configure the current - * instance of this class - * - * @throws net.jini.config.ConfigurationException indicates an exception - * occurred while retrieving an item from the given - * <code>Configuration</code> - * - * @throws java.lang.NullPointerException input array contains at least - * one <code>null</code> element or <code>null</code> is input - * for the configuration - */ - public LookupLocatorDiscovery(LookupLocator[] locators, - Configuration config) - throws ConfigurationException - { - super(config); - super.beginDiscovery(locators); - }//end constructor - -}//end class LookupLocatorDiscovery +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.jini.discovery; + +import java.util.logging.Logger; +import net.jini.config.Configuration; +import net.jini.config.ConfigurationException; +import net.jini.core.discovery.LookupLocator; +import org.apache.river.impl.thread.NamedThreadFactory; + +/** + * This class encapsulates the functionality required of an entity that + * wishes to employ the unicast discovery protocol to discover a lookup + * service. This utility provides an implementation that makes the process + * of finding specific lookup services much simpler for both services and + * clients. + * <p> + * Because this class participates in only the unicast discovery protocol, + * and because the unicast discovery protocol imposes no restriction on the + * physical location of the entity relative to a lookup service, this utility + * can be used to discover lookup services running on hosts that are located + * far from, or near to, the host on which the entity is running. This lack + * of a restriction on location brings with it a requirement that the + * discovering entity supply this class with specific information about the + * desired lookup services; namely, the location of the device(s) hosting + * each lookup service. This information is supplied through an instance + * of the {@link net.jini.core.discovery.LookupLocator LookupLocator} class, + * or its subclass {@link net.jini.discovery.ConstrainableLookupLocator + * ConstrainableLookupLocator}. + * + * @com.sun.jini.impl <!-- Implementation Specifics --> + * + * The following implementation-specific items are discussed below: + * <ul><li> <a href="#lldConfigEntries">Configuring LookupLocatorDiscovery</a> + * <li> <a href="#lldLogging">Logging</a> + * </ul> + * + * <a name="lldConfigEntries"> + * <p> + * <b><font size="+1">Configuring LookupLocatorDiscovery</font></b> + * <p> + * </a> + * + * This implementation of <code>LookupLocatorDiscovery</code> supports the + * following configuration entries; where each configuration entry name + * is associated with the component name + * <code>net.jini.discovery.LookupLocatorDiscovery</code>. Note that the + * configuration entries specified here are specific to this implementation + * of <code>LookupLocatorDiscovery</code>. Unless otherwise stated, each + * entry is retrieved from the configuration only once per instance of + * this utility, where each such retrieval is performed in the constructor. + * + * <a name="initialUnicastDelayRange"> + * <table summary="Describes the initialUnicastDelayRange + * configuration entry" border="0" cellpadding="2"> + * <tr valign="top"> + * <th scope="col" summary="layout"> <font size="+1">•</font> + * <th scope="col" align="left" colspan="2"> <font size="+1"> + * <code>initialUnicastDelayRange</code></font> + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Type: <td> <code>long</code> + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Default: <td> <code>0 milliseconds</code> + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Description: + * <td> With respect to when this utility is started, this entry controls + * how long to wait before attempting unicast discovery. + * If the value is positive, initial unicast discovery requests + * will be delayed by a random value between <code>0</code> and + * <code>initialUnicastDelayRange</code> milliseconds. Once the wait + * period is up, the <code>LookupLocator</code>s specified at construction + * time are used for initiating unicast discovery requests, unless the + * managed <code>LookupLocator</code>s have been changed in the interim; + * in which case, no delayed unicast discovery requests are performed. + * Note that this entry only has effect when this utility is initialized. + * It does not delay discovery requests that are initiated if the managed + * <code>LookupLocator</code>s are subsequently changed. + * </table> + * </a> + * <a name="registrarPreparer"> + * <table summary="Describes the registrarPreparer configuration entry" + * border="0" cellpadding="2"> + * <tr valign="top"> + * <th scope="col" summary="layout"> <font size="+1">•</font> + * <th scope="col" align="left" colspan="2"> <font size="+1"> + * <code>registrarPreparer</code></font> + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Type: <td> {@link net.jini.security.ProxyPreparer} + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Default: <td> <code>new {@link net.jini.security.BasicProxyPreparer}() + * </code> + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Description: + * <td> Preparer for the proxies to the lookup services that are + * discovered and used by this utility. + * <p> + * This preparer should perform all operations required to use a + * newly received proxy to a lookup service, which may including + * verifying trust in the proxy, granting permissions, and setting + * constraints. + * <p> + * Currently, none of the methods on the + * {@link net.jini.core.lookup.ServiceRegistrar ServiceRegistrar} + * returned by this preparer are invoked by this implementation of + * <code>LookupLocatorDiscovery</code>. + * </table> + * </a> + * <a name="executorService"> + * <table summary="Describes the executorService configuration entry" + * border="0" cellpadding="2"> + * <tr valign="top"> + * <th scope="col" summary="layout"> <font size="+1">•</font> + * <th scope="col" align="left" colspan="2"> <font size="+1"> + * <code>executorService</code></font> + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Type: <td> {@link java.util.concurrent/ExecutorService ExecutorService} + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Default: <td> <code>new + * {@link java.util.concurrent/ThreadPoolExecutor + * ThreadPoolExecutor}( + * 15, + * 15, + * 15, + * TimeUnit.SECONDS, + * new {@link java.util.concurrent/LinkedBlockingQueue LinkedBlockingQueue}(), + * new {@link NamedThreadFactory}("LookupLocatorDiscovery", false) + * )</code> + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Description: + * <td> The object that pools and manages the various threads + * executed by this utility. This object + * should not be shared with other components in the + * application that employs this utility. + * </table> + * </a> + * <a name="wakeupManager"> + * <table summary="Describes the wakeupManager configuration entry" + * border="0" cellpadding="2"> + * <tr valign="top"> + * <th scope="col" summary="layout"> <font size="+1">•</font> + * <th scope="col" align="left" colspan="2"> <font size="+1"> + * <code>wakeupManager</code></font> + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Type: <td> {@link com.sun.jini.thread.WakeupManager} + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Default: <td> <code>new + * {@link com.sun.jini.thread.WakeupManager#WakeupManager( + * com.sun.jini.thread.WakeupManager.ThreadDesc) + * WakeupManager}(new + * {@link com.sun.jini.thread.WakeupManager.ThreadDesc}(null,true))</code> + * + * <tr valign="top"> <td>   <th scope="row" align="right"> + * Description: + * <td> Object that pools and manages the various tasks that are + * initially executed by the object corresponding to the + * <a href="#executorService"><code>executorService</code></a> entry + * of this component, but which fail during that initial execution. + * This object schedules the re-execution of such a failed task - + * in the <a href="#executorService"><code>executorService</code></a> + * object - at various times in the future, (employing a + * "backoff strategy"). The re-execution of the failed task will + * continue to be scheduled by this object until the task finally + * succeeds. This object should not be shared with other components + * in the application that employs this utility. + * </table> + * </a> + * <a name="lldLogging"> + * <p> + * <b><font size="+1">Logging</font></b> + * <p> + * </a> + * + * This implementation of <code>LookupLocatorDiscovery</code> uses the + * {@link Logger} named <code>net.jini.discovery.LookupLocatorDiscovery</code> + * to log information at the following logging levels: <p> + * + * <table border="1" cellpadding="5" + * summary="Describes the information logged by LookupLocatorDiscovery, + * and the levels at which that information is logged"> + * + * <caption halign="center" valign="top"> + * <b><code>net.jini.discovery.LookupLocatorDiscovery</code></b> + * </caption> + * + * <tr> <th scope="col"> Level</th> + * <th scope="col"> Description</th> + * </tr> + * + * <tr> + * <td>{@link java.util.logging.Level#INFO INFO}</td> + * <td> + * when any exception occurs in a task or thread, while attempting unicast + * discovery of a given locator + * </td> + * </tr> + * <tr> + * <td>{@link java.util.logging.Level#INFO INFO}</td> + * <td>when any exception occurs while attempting to prepare a proxy</td> + * </tr> + * <tr> + * <td>{@link com.sun.jini.logging.Levels#HANDLED HANDLED}</td> + * <td> + * when an exception is handled during unicast discovery. + * </td> + * </tr> + * <tr> + * <td>{@link java.util.logging.Level#FINEST FINEST}</td> + * <td>whenever any thread or task is started</td> + * </tr> + * + * <tr> + * <td>{@link java.util.logging.Level#FINEST FINEST}</td> + * <td> + * whenever any thread (except the <code>Notifier</code> thread) or task + * completes successfully + * </td> + * </tr> + * + * <tr> + * <td>{@link java.util.logging.Level#FINEST FINEST}</td> + * <td>whenever a discovered or discarded event is sent</td> + * </tr> + * + * <tr> + * <td>{@link java.util.logging.Level#FINEST FINEST}</td> + * <td>whenever a proxy is prepared</td> + * </tr> + * + * <tr> + * <td>{@link java.util.logging.Level#FINEST FINEST}</td> + * <td> + * when an <code>IOException</code> occurs upon attempting to close the + * socket after a unicast discovery attempt has either completed + * successfully or failed + * </td> + * </tr> + * </table> + * <p> + * + * This implementation of <code>LookupLocatorDiscovery</code> determines + * the constraints (if any) to apply to unicast discovery for a given + * {@link net.jini.core.discovery.LookupLocator LookupLocator} instance + * by calling the + * {@link net.jini.core.constraint.RemoteMethodControl#getConstraints + * getConstraints} method of that instance, if it implements the + * {@link net.jini.core.constraint.RemoteMethodControl RemoteMethodControl} + * interface. If the {@link net.jini.core.discovery.LookupLocator + * LookupLocator} instance does not implement + * {@link net.jini.core.constraint.RemoteMethodControl RemoteMethodControl}, + * then no constraints are applied to unicast discovery for that instance. + * <p> + * For more information on constraining unicast discovery, refer to the + * documentation for the {@link net.jini.discovery.ConstrainableLookupLocator + * ConstrainableLookupLocator} class. + * + * @author Sun Microsystems, Inc. + * + * @see net.jini.core.discovery.LookupLocator + */ +public class LookupLocatorDiscovery extends AbstractLookupLocatorDiscovery + implements DiscoveryManagement, + DiscoveryLocatorManagement +{ + /** + * Creates an instance of this class (<code>LookupLocatorDiscovery</code>), + * with an initial array of <code>LookupLocator</code>s to be managed. + * For each managed <code>LookupLocator</code>, unicast discovery is + * performed to obtain a <code>ServiceRegistrar</code> proxy for that + * lookup service. + * + * @param locators the locators to discover + * + * @throws java.lang.NullPointerException input array contains at least + * one <code>null</code> element + */ + public LookupLocatorDiscovery(LookupLocator[] locators) { + super(); + super.beginDiscovery(locators); + }//end constructor + + /** + * Constructs a new lookup locator discovery object, set to discover the + * given set of locators, and having the given <code>Configuration</code>. + * <p> + * For each managed <code>LookupLocator</code>, unicast discovery is + * performed to obtain a <code>ServiceRegistrar</code> proxy for that + * lookup service. + * + * @param locators the locators to discover + * + * @param config an instance of <code>Configuration</code>, used to + * obtain the objects needed to configure the current + * instance of this class + * + * @throws net.jini.config.ConfigurationException indicates an exception + * occurred while retrieving an item from the given + * <code>Configuration</code> + * + * @throws java.lang.NullPointerException input array contains at least + * one <code>null</code> element or <code>null</code> is input + * for the configuration + */ + public LookupLocatorDiscovery(LookupLocator[] locators, + Configuration config) + throws ConfigurationException + { + super(config); + super.beginDiscovery(locators); + }//end constructor + +}//end class LookupLocatorDiscovery
Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lease/LeaseRenewalManager.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lease/LeaseRenewalManager.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lease/LeaseRenewalManager.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lease/LeaseRenewalManager.java Sun Oct 26 13:17:28 2014 @@ -32,7 +32,6 @@ import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; import java.util.concurrent.ExecutorService; -import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy; @@ -197,10 +196,7 @@ import org.apache.river.impl.thread.Name * involved with renewing leases and sending notifications. The * value must not be <code>null</code>. The default value creates * a maximum of 11 threads for performing operations, waits 15 - * seconds before removing idle threads, and uses a load factor of - * 1.0 when determining whether to create a new thread. Note that - * the implementation of the renewal algorithm includes an assumption - * that the <code>ExecutorService</code> uses a load factor of 1.0. + * seconds before removing idle threads. * </table> * * <a name="logging"> @@ -450,6 +446,7 @@ public class LeaseRenewalManager { } } + @Override public void run() { if (noRenewals) { // Just notify @@ -609,6 +606,7 @@ public class LeaseRenewalManager { } /** Sort by decreasing renew time, secondary sort by decreasing id */ + @Override public int compareTo(Object obj) { if (this == obj) return 0; @@ -1407,9 +1405,8 @@ public class LeaseRenewalManager { e.lease); } else { logger.log(Levels.FAILED, - "Lease {0} expired before reaching " - + "desired expiration of " - + e.expiration); + "Lease '{'0'}' expired before reaching desired expiration of {0}", + e.expiration); } } Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/JoinManager.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/JoinManager.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/JoinManager.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/JoinManager.java Sun Oct 26 13:17:28 2014 @@ -151,7 +151,7 @@ import org.apache.river.impl.thread.Name * not be shared with other components in the application that * employs this utility. * </table> - * + * </a> * <a name="leaseManager"> * <table summary="Describes the leaseManager configuration entry" * border="0" cellpadding="2"> @@ -176,7 +176,7 @@ import org.apache.river.impl.thread.Name * be retrieved from the configuration only if no lease * renewal manager is specified in the constructor. * </table> - * + * </a> * <a name="maxLeaseDuration"> * <table summary="Describes the maxLeaseDuration * configuration entry" border="0" cellpadding="2"> @@ -201,7 +201,7 @@ import org.apache.river.impl.thread.Name * while the service is up, and lease expiration will occur sooner * when the service goes down. * </table> - * + * </a> * <a name="registrarPreparer"> * <table summary="Describes the registrarPreparer configuration entry" * border="0" cellpadding="2"> @@ -228,7 +228,7 @@ import org.apache.river.impl.thread.Name * <li>{@link net.jini.core.lookup.ServiceRegistrar#register register} * </ul> * </table> - * + * </a> * <a name="registrationPreparer"> * <table summary="Describes the registrationPreparer configuration entry" * border="0" cellpadding="2"> @@ -265,7 +265,7 @@ import org.apache.river.impl.thread.Name * setAttributes} * </ul> * </table> - * + * </a> * <a name="serviceLeasePreparer"> * <table summary="Describes the serviceLeasePreparer configuration entry" * border="0" cellpadding="2"> @@ -290,34 +290,36 @@ import org.apache.river.impl.thread.Name * Currently, none of the methods on the service lease returned * by this preparer are invoked by this implementation of the utility. * </table> - * - * <a name="taskManager"> - * <table summary="Describes the taskManager configuration entry" + * </a> + * <a name="executorService"> + * <table summary="Describes the executorService configuration entry" * border="0" cellpadding="2"> * <tr valign="top"> * <th scope="col" summary="layout"> <font size="+1">•</font> * <th scope="col" align="left" colspan="2"> <font size="+1"> - * <code>taskManager</code></font> + * <code>executorService</code></font> * * <tr valign="top"> <td>   <th scope="row" align="right"> - * Type: <td> {@link com.sun.jini.thread.TaskManager} + * Type: <td> {@link java.util.concurrent/ExecutorService ExecutorService} * * <tr valign="top"> <td>   <th scope="row" align="right"> * Default: <td> <code>new - * {@link com.sun.jini.thread.TaskManager#TaskManager() - * TaskManager}(15, (15*1000), 1.0f)</code> + * {@link java.util.concurrent/ThreadPoolExecutor ThreadPoolExecutor}( + * 15, + * 15, + * 15, + * TimeUnit.SECONDS, + * new {@link java.util.concurrent/LinkedBlockingQueue LinkedBlockingQueue}(), + * new {@link org.apache.river.impl.thread.NamedThreadFactory NamedThreadFactory}("JoinManager executor thread", false))</code> * * <tr valign="top"> <td>   <th scope="row" align="right"> * Description: * <td> The object that pools and manages the various threads - * executed by this utility. The default manager creates a - * maximum of 15 threads, waits 15 seconds before removing - * idle threads, and uses a load factor of 1.0 when - * determining whether to create a new thread. This object + * executed by this utility. This object * should not be shared with other components in the * application that employs this utility. * </table> - * + * </a> * <a name="wakeupManager"> * <table summary="Describes the wakeupManager configuration entry" * border="0" cellpadding="2"> @@ -340,10 +342,10 @@ import org.apache.river.impl.thread.Name * Description: * <td> Object that pools and manages the various tasks that are * initially executed by the object corresponding to the - * <a href="#taskManager"><code>taskManager</code></a> entry + * <a href="#executorService"><code>executorService</code></a> entry * of this component, but which fail during that initial execution. * This object schedules the re-execution of such a failed task - - * in the <a href="#taskManager"><code>taskManager</code></a> + * in the <a href="#executorService"><code>executorService</code></a> * object - at various times in the future, until either the * task succeeds or the task has been executed the maximum * number of allowable times, corresponding to the @@ -352,7 +354,7 @@ import org.apache.river.impl.thread.Name * with other components in the application that employs this * utility. * </table> - * + * </a> * <a name="wakeupRetries"> * <table summary="Describes the wakeupRetries * configuration entry" border="0" cellpadding="2"> @@ -374,7 +376,7 @@ import org.apache.river.impl.thread.Name * <a href="#wakeupManager"><code>wakeupManager</code></a> * entry of this component. * </table> - * + * </a> * <a name="jmLogging"> * <p> * <b><font size="+1">Logging</font></b> @@ -585,7 +587,7 @@ public class JoinManager { /** Basic constructor; simply stores the input parameters */ ProxyRegTask(ProxyReg proxyReg, int seqN) { - super(JoinManager.this.taskMgr,JoinManager.this.wakeupMgr); + super(JoinManager.this.executor,JoinManager.this.wakeupMgr); this.proxyReg = proxyReg; this.seqN = seqN; }//end constructor @@ -1508,7 +1510,7 @@ public class JoinManager { /* Logger used by this utility. */ private static final Logger logger = Logger.getLogger(COMPONENT_NAME); /** Maximum number of concurrent tasks that can be run in any default - * task manager created by this class. + * ExecutorService created by this class. */ private static final int MAX_N_TASKS = 15; /** Whenever a task is created in this join manager, it is assigned a @@ -1521,14 +1523,14 @@ public class JoinManager { private int taskSeqN = 0; // access sync on taskList /** Task manager for the various tasks executed by this join manager. * On the first attempt to execute any task is managed by this - * <code>TaskManager</code> so that the number of concurrent threads + * <code>ExecutorService</code> so that the number of concurrent threads * can be bounded. If one or more of those attempts fails, a * <code>WakeupManager</code> is used (through the use of a * <code>RetryTask</code>) to schedule - at a later time (employing a * "backoff strategy") - the re-execution of each failed task in this - * <code>TaskManager</code>. + * <code>ExecutorService</code>. */ - private final ExecutorService taskMgr; + private final ExecutorService executor; private final ProxyRegTaskQueue proxyRegTaskQueue; /** Maximum number of times a failed task is allowed to be re-executed. */ private final int maxNRetries; @@ -2517,7 +2519,7 @@ public class JoinManager { ProxyPreparer registrarPreparer; ProxyPreparer registrationPreparer; ProxyPreparer serviceLeasePreparer; - ExecutorService taskManager; + ExecutorService executorService; WakeupManager wakeupManager; Integer maxNretrys; LeaseRenewalManager leaseRenewalManager; @@ -2539,7 +2541,7 @@ public class JoinManager { this.registrarPreparer = registrarPreparer; this.registrationPreparer = registrationPreparer; this.serviceLeasePreparer = serviceLeasePreparer; - this.taskManager = taskManager; + this.executorService = taskManager; this.wakeupManager = wakeupManager; this.maxNretrys = maxNretrys; this.leaseRenewalManager = leaseRenewalManager; @@ -2704,7 +2706,7 @@ public class JoinManager { registrarPreparer = conf.registrarPreparer; registrationPreparer = conf.registrationPreparer; serviceLeasePreparer = conf.serviceLeasePreparer; - taskMgr = new ExtensibleExecutorService(conf.taskManager, + executor = new ExtensibleExecutorService(conf.executorService, new RunnableFutureFactory(){ @Override @@ -2720,7 +2722,7 @@ public class JoinManager { } }); - proxyRegTaskQueue = new ProxyRegTaskQueue(taskMgr); + proxyRegTaskQueue = new ProxyRegTaskQueue(executor); wakeupMgr = conf.wakeupManager; maxNRetries = conf.maxNretrys; leaseRenewalMgr = conf.leaseRenewalManager; @@ -2759,7 +2761,7 @@ public class JoinManager { */ private void removeTasks(ProxyReg proxyReg) { if(proxyReg == null) return; - if(taskMgr == null) return; + if(executor == null) return; synchronized(proxyReg.taskList) { if(proxyReg.proxyRegTask != null) { proxyReg.proxyRegTask.cancel(false); @@ -2782,7 +2784,7 @@ public class JoinManager { wakeupMgr.stop();//stop execution of the wakeup manager } /* Interrupt all active tasks, prepare taskMgr for GC. */ - taskMgr.shutdownNow(); + executor.shutdownNow(); }//end terminateTaskMgr /** Examines the elements of the input set and, upon finding at least one Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryEvent.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryEvent.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryEvent.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryEvent.java Sun Oct 26 13:17:28 2014 @@ -100,13 +100,32 @@ public class ServiceDiscoveryEvent exten * <code>preEventItem </code>and the * <code>postEventItem</code> parameters. */ - public ServiceDiscoveryEvent(Object source, ServiceItem preEventItem, - ServiceItem postEventItem) { - super(source); - if((preEventItem == null && postEventItem == null) - || source == null) + public ServiceDiscoveryEvent( + Object source, + ServiceItem preEventItem, + ServiceItem postEventItem) + { + this(source, preEventItem, postEventItem, + nullCheck(source, preEventItem, postEventItem)); + } + + private static boolean nullCheck( //Prevent finalizer attack. + Object source, + ServiceItem preEventItem, + ServiceItem postEventItem) throws NullPointerException + { + if((preEventItem == null && postEventItem == null)|| source == null) throw new NullPointerException(); - + return true; + } + + private ServiceDiscoveryEvent( + Object source, + ServiceItem preEventItem, + ServiceItem postEventItem, + boolean check) + { + super(source); if(preEventItem != null) this.preEventItem = new ServiceItem(preEventItem.serviceID, preEventItem.service, @@ -117,7 +136,6 @@ public class ServiceDiscoveryEvent exten postEventItem.service, postEventItem.attributeSets); else this.postEventItem = null; - } /** @@ -146,7 +164,8 @@ public class ServiceDiscoveryEvent exten * @return ServiceItem containing the service reference corresponding * to the given event. */ - public ServiceItem getPreEventServiceItem() { + public ServiceItem getPreEventServiceItem() + { return preEventItem; } @@ -175,7 +194,8 @@ public class ServiceDiscoveryEvent exten * @return ServiceItem containing the service reference corresponding * to the given event. */ - public ServiceItem getPostEventServiceItem() { + public ServiceItem getPostEventServiceItem() + { return postEventItem; } Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryListener.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryListener.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryListener.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryListener.java Sun Oct 26 13:17:28 2014 @@ -17,8 +17,6 @@ */ package net.jini.lookup; - -import net.jini.core.lookup.ServiceItem; /** * The <code>ServiceDiscoveryListener</code> interface defines the * methods used by objects such as a {@link net.jini.lookup.LookupCache
