river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r1634322 [37/41] - in /river/jtsk/skunk/qa_refactor/trunk: qa/src/com/sun/jini/qa/harness/ qa/src/com/sun/jini/test/impl/end2end/e2etest/ qa/src/com/sun/jini/test/impl/joinmanager/ qa/src/com/sun/jini/test/impl/mahalo/ qa/src/com/sun/jini/t...
Date Sun, 26 Oct 2014 13:17:31 GMT
Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/resource/Service.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/resource/Service.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/resource/Service.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/resource/Service.java Sun Oct 26 13:17:28 2014
@@ -1,418 +1,417 @@
-/*
- * 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 com.sun.jini.resource;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.LinkedHashSet;
-import java.util.logging.Logger;
-import net.jini.loader.ClassLoading;
-import net.jini.loader.LoadClass;
-
-
-/**
- * A simple service-provider lookup mechanism.  A <i>service</i> is a
- * well-known set of interfaces and (usually abstract) classes.  A <i>service
- * provider</i> is a specific implementation of a service.  The classes in a
- * provider typically implement the interfaces and subclass the classes defined
- * in the service itself.  Service providers may be installed in an
- * implementation of the Java(TM) platform in the form of extensions, that is,
- * JAR files placed into any of the usual extension directories.  Providers may
- * also be made available by adding them to the applet or application class
- * path or by some other platform-specific means.
- *
- * <p> In this lookup mechanism a service is represented by an interface or an
- * abstract class.  (A concrete class may be used, but this is not
- * recommended.)  A provider of a given service contains one or more concrete
- * classes that extend this <i>service class</i> with data and code specific to
- * the provider.  This <i>provider class</i> will typically not be the entire
- * provider itself but rather a proxy that contains enough information to
- * decide whether the provider is able to satisfy a particular request together
- * with code that can create the actual provider on demand.  The details of
- * provider classes tend to be highly service-specific; no single class or
- * interface could possibly unify them, so no such class has been defined.  The
- * only requirement enforced here is that provider classes must have a
- * zero-argument constructor so that they may be instantiated during lookup.
- *
- * <p> A service provider identifies itself by placing a provider-configuration
- * file in the resource directory <tt>META-INF/services</tt>.  The file's name
- * should consist of the fully-qualified name of the abstract service class.
- * The file should contain a list of fully-qualified concrete provider-class
- * names, one per line.  Space and tab characters surrounding each name, as
- * well as blank lines, are ignored.  The comment character is <tt>'#'</tt>
- * (<tt>0x23</tt>); on each line all characters following the first comment
- * character are ignored.  The file must be encoded in UTF-8.
- *
- * <p> If a particular concrete provider class is named in more than one
- * configuration file, or is named in the same configuration file more than
- * once, then the duplicates will be ignored.  The configuration file naming a
- * particular provider need not be in the same JAR file or other distribution
- * unit as the provider itself.  The provider must be accessible from the same
- * class loader that was initially queried to locate the configuration file;
- * note that this is not necessarily the class loader that found the file.
- *
- * <p> <b>Example:</b> Suppose we have a service class named
- * <tt>java.io.spi.CharCodec</tt>.  It has two abstract methods:
- *
- * <pre>
- *   public abstract CharEncoder getEncoder(String encodingName);
- *   public abstract CharDecoder getDecoder(String encodingName);
- * </pre>
- *
- * Each method returns an appropriate object or <tt>null</tt> if it cannot
- * translate the given encoding.  Typical <tt>CharCodec</tt> providers will
- * support more than one encoding.
- *
- * <p> If <tt>sun.io.StandardCodec</tt> is a provider of the <tt>CharCodec</tt>
- * service then its JAR file would contain the file
- * <tt>META-INF/services/java.io.spi.CharCodec</tt>.  This file would contain
- * the single line:
- *
- * <pre>
- *   sun.io.StandardCodec    # Standard codecs for the platform
- * </pre>
- *
- * To locate an encoder for a given encoding name, the internal I/O code would
- * do something like this:
- *
- * <pre>
- *   CharEncoder getEncoder(String encodingName) {
- *       Iterator ps = Service.providers(CharCodec.class);
- *       while (ps.hasNext()) {
- *           CharCodec cc = (CharCodec)ps.next();
- *           CharEncoder ce = cc.getEncoder(encodingName);
- *           if (ce != null)
- *               return ce;
- *       }
- *       return null;
- *   }
- * </pre>
- *
- * The provider-lookup mechanism always executes in the security context of the
- * caller.  Trusted system code should typically invoke the methods in this
- * class from within a privileged security context.
- *
- * @author Sun Microsystems, Inc.
- * 
- * @since 2.0
- */
-
-public final class Service {
-
-	private static final Logger log=
-		Logger.getLogger(Service.class.getName());
-
-    private static final String prefix = "META-INF/services/";
-
-    private Service() { }
-
-    private static void fail(Class service, String msg)
-	throws ServiceConfigurationError
-    {
-	throw new ServiceConfigurationError(service.getName() + ": " + msg);
-    }
-
-    private static void fail(Class service, URL u, int line, String msg)
-	throws ServiceConfigurationError
-    {
-	fail(service, u + ":" + line + ": " + msg);
-    }
-
-    /**
-     * Parse a single line from the given configuration file, adding the name
-     * on the line to both the names list and the returned set iff the name is
-     * not already a member of the returned set.
-     */
-    private static int parseLine(Class service, URL u, BufferedReader r, int lc,
-				 List names, Set returned)
-	throws IOException, ServiceConfigurationError
-    {
-	String ln = r.readLine();
-	if (ln == null) {
-	    return -1;
-	}
-	int ci = ln.indexOf('#');
-	if (ci >= 0) ln = ln.substring(0, ci);
-	ln = ln.trim();
-	int n = ln.length();
-	if (n != 0) {
-	    if ((ln.indexOf(' ') >= 0) || (ln.indexOf('\t') >= 0))
-		fail(service, u, lc, "Illegal configuration-file syntax");
-	    if (!Character.isJavaIdentifierStart(ln.charAt(0)))
-		fail(service, u, lc, "Illegal provider-class name: " + ln);
-	    for (int i = 1; i < n; i++) {
-		char c = ln.charAt(i);
-		if (!Character.isJavaIdentifierPart(c) && (c != '.'))
-		    fail(service, u, lc, "Illegal provider-class name: " + ln);
-	    }
-	    if (!returned.contains(ln)) {
-		names.add(ln);
-		returned.add(ln);
-	    }
-	}
-	return lc + 1;
-    }
-
-    /**
-     * Parse the content of the given URL as a provider-configuration file.
-     *
-     * @param  service
-     *         The service class for which providers are being sought;
-     *         used to construct error detail strings
-     *
-     * @param  u
-     *         The URL naming the configuration file to be parsed
-     *
-     * @param  returned
-     *         A Set containing the names of provider classes that have already
-     *         been returned.  This set will be updated to contain the names
-     *         that will be yielded from the returned <tt>Iterator</tt>.
-     *
-     * @return A (possibly empty) <tt>Iterator</tt> that will yield the
-     *         provider-class names in the given configuration file that are
-     *         not yet members of the returned set
-     *
-     * @throws ServiceConfigurationError
-     *         If an I/O error occurs while reading from the given URL, or
-     *         if a configuration-file format error is detected
-     */
-    private static Iterator parse(Class service, URL u, Set returned)
-	throws ServiceConfigurationError
-    {
-	InputStream in = null;
-	BufferedReader r = null;
-	ArrayList names = new ArrayList();
-	try {
-	    in = u.openStream();
-	    r = new BufferedReader(new InputStreamReader(in, "utf-8"));
-	    int lc = 1;
-	    while ((lc = parseLine(service, u, r, lc, names, returned)) >= 0);
-	} catch (IOException x) {
-	    fail(service, ": " + x);
-	} finally {
-	    try {
-		if (r != null) r.close();
-		if (in != null) in.close();
-	    } catch (IOException y) {
-		fail(service, ": " + y);
-	    }
-	}
-	return names.iterator();
-    }
-
-
-    /**
-     * Private inner class implementing fully-lazy provider lookup
-     */
-    private static class LazyIterator implements Iterator {
-
-	Class service;
-	ClassLoader loader;
-	Enumeration configs = null;
-	Iterator pending = null;
-	Set returned = new LinkedHashSet();
-	String nextName = null;
-
-	private LazyIterator(Class service, ClassLoader loader) {
-	    this.service = service;
-	    this.loader = loader;
-	}
-
-	public boolean hasNext() throws ServiceConfigurationError {
-	    if (nextName != null) {
-		return true;
-	    }
-	    if (configs == null) {
-		try {
-		    String fullName = prefix + service.getName();
-		    if (loader == null)
-			configs = ClassLoader.getSystemResources(fullName);
-		    else
-			configs = loader.getResources(fullName);
-		} catch (IOException x) {
-		    fail(service, ": " + x);
-		}
-	    }
-	    while ((pending == null) || !pending.hasNext()) {
-		if (!configs.hasMoreElements()) {
-		    return false;
-		}
-		pending = parse(service, (URL)configs.nextElement(), returned);
-	    }
-	    nextName = (String)pending.next();
-	    return true;
-	}
-
-	public Object next() throws ServiceConfigurationError {
-	    if (!hasNext()) {
-		throw new NoSuchElementException();
-	    }
-	    String cn = nextName;
-	    nextName = null;
-	    try {
-		Class c = LoadClass.forName(cn, true, loader);
-		if (!service.isAssignableFrom(c)) {
-			log.severe("service classloader is "
-					  + service.getClass().getClassLoader()
-					  + ", provider loader is " + loader);
-		    fail(service, "Provider " + cn + " is of incorrect type");
-		}
-		return c.newInstance();
-	    } catch (ClassNotFoundException x) {
-		fail(service,
-		     "Provider " + cn + " not found");
-	    } catch (Exception x) {
-		fail(service,
-		     "Provider " + cn + " could not be instantiated: " + x);
-	    }
-	    return null;	/* This cannot happen */
-	}
-
-	public void remove() {
-	    throw new UnsupportedOperationException();
-	}
-
-    }
-
-
-    /**
-     * Locates and incrementally instantiates the available providers of a
-     * given service using the given class loader.
-     *
-     * <p> This method transforms the name of the given service class into a
-     * provider-configuration filename as described above and then uses the
-     * <tt>getResources</tt> method of the given class loader to find all
-     * available files with that name.  These files are then read and parsed to
-     * produce a list of provider-class names.  The iterator that is returned
-     * uses the given class loader to lookup and then instantiate each element
-     * of the list.
-     *
-     * <p> Because it is possible for extensions to be installed into a running
-     * virtual machine, this method may return different results each time
-     * it is invoked. <p>
-     *
-     * @param  service
-     *         The service's abstract service class
-     *
-     * @param  loader
-     *         The class loader to be used to load provider-configuration files
-     *         and instantiate provider classes, or <tt>null</tt> if the system
-     *         class loader (or, failing that the bootstrap class loader) is to
-     *         be used
-     * 
-     * @return An <tt>Iterator</tt> that yields provider objects for the given
-     *         service, in instantiation order.  The iterator will throw a
-     *         <tt>ServiceConfigurationError</tt> if a provider-configuration
-     *         file violates the specified format or if a provider class cannot
-     *         be found and instantiated.
-     *
-     * @throws ServiceConfigurationError
-     *         If a provider-configuration file violates the specified format
-     *         or names a provider class that cannot be found and instantiated
-     *
-     * @see #providers(java.lang.Class)
-     * @see #installedProviders(java.lang.Class)
-     */
-    public static Iterator providers(Class service, ClassLoader loader)
-	throws ServiceConfigurationError
-    {
-	return new LazyIterator(service, loader);
-    }
-
-
-    /**
-     * Locates and incrementally instantiates the available providers of a
-     * given service using the context class loader.  This convenience method
-     * is equivalent to
-     *
-     * <pre>
-     *   ClassLoader cl = Thread.currentThread().getContextClassLoader();
-     *   return Service.providers(service, cl);
-     * </pre>
-     *
-     * @param  service
-     *         The service's abstract service class
-     *
-     * @return An <tt>Iterator</tt> that yields provider objects for the given
-     *         service, in some arbitrary order.  The iterator will throw a
-     *         <tt>ServiceConfigurationError</tt> if a provider-configuration
-     *         file violates the specified format or if a provider class cannot
-     *         be found and instantiated.
-     *
-     * @throws ServiceConfigurationError
-     *         If a provider-configuration file violates the specified format
-     *         or names a provider class that cannot be found and instantiated
-     *
-     * @see #providers(java.lang.Class, java.lang.ClassLoader)
-     */
-    public static Iterator providers(Class service)
-	throws ServiceConfigurationError
-    {
-	ClassLoader cl = Thread.currentThread().getContextClassLoader();
-	return Service.providers(service, cl);
-    }
-
-
-    /**
-     * Locates and incrementally instantiates the available providers of a
-     * given service using the extension class loader.  This convenience method
-     * simply locates the extension class loader, call it
-     * <tt>extClassLoader</tt>, and then does
-     *
-     * <pre>
-     *   return Service.providers(service, extClassLoader);
-     * </pre>
-     *
-     * If the extension class loader cannot be found then the system class
-     * loader is used; if there is no system class loader then the bootstrap
-     * class loader is used.
-     *
-     * @param  service
-     *         The service's abstract service class
-     *
-     * @return An <tt>Iterator</tt> that yields provider objects for the given
-     *         service, in some arbitrary order.  The iterator will throw a
-     *         <tt>ServiceConfigurationError</tt> if a provider-configuration
-     *         file violates the specified format or if a provider class cannot
-     *         be found and instantiated.
-     *
-     * @throws ServiceConfigurationError
-     *         If a provider-configuration file violates the specified format
-     *         or names a provider class that cannot be found and instantiated
-     *
-     * @see #providers(java.lang.Class, java.lang.ClassLoader)
-     */
-    public static Iterator installedProviders(Class service)
-	throws ServiceConfigurationError
-    {
-	ClassLoader cl = ClassLoader.getSystemClassLoader();
-	if (cl != null) cl = cl.getParent();
-	return Service.providers(service, cl);
-    }
-
-}
+/*
+ * 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 com.sun.jini.resource;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.LinkedHashSet;
+import java.util.logging.Logger;
+import net.jini.loader.LoadClass;
+
+
+/**
+ * A simple service-provider lookup mechanism.  A <i>service</i> is a
+ * well-known set of interfaces and (usually abstract) classes.  A <i>service
+ * provider</i> is a specific implementation of a service.  The classes in a
+ * provider typically implement the interfaces and subclass the classes defined
+ * in the service itself.  Service providers may be installed in an
+ * implementation of the Java(TM) platform in the form of extensions, that is,
+ * JAR files placed into any of the usual extension directories.  Providers may
+ * also be made available by adding them to the applet or application class
+ * path or by some other platform-specific means.
+ *
+ * <p> In this lookup mechanism a service is represented by an interface or an
+ * abstract class.  (A concrete class may be used, but this is not
+ * recommended.)  A provider of a given service contains one or more concrete
+ * classes that extend this <i>service class</i> with data and code specific to
+ * the provider.  This <i>provider class</i> will typically not be the entire
+ * provider itself but rather a proxy that contains enough information to
+ * decide whether the provider is able to satisfy a particular request together
+ * with code that can create the actual provider on demand.  The details of
+ * provider classes tend to be highly service-specific; no single class or
+ * interface could possibly unify them, so no such class has been defined.  The
+ * only requirement enforced here is that provider classes must have a
+ * zero-argument constructor so that they may be instantiated during lookup.
+ *
+ * <p> A service provider identifies itself by placing a provider-configuration
+ * file in the resource directory <tt>META-INF/services</tt>.  The file's name
+ * should consist of the fully-qualified name of the abstract service class.
+ * The file should contain a list of fully-qualified concrete provider-class
+ * names, one per line.  Space and tab characters surrounding each name, as
+ * well as blank lines, are ignored.  The comment character is <tt>'#'</tt>
+ * (<tt>0x23</tt>); on each line all characters following the first comment
+ * character are ignored.  The file must be encoded in UTF-8.
+ *
+ * <p> If a particular concrete provider class is named in more than one
+ * configuration file, or is named in the same configuration file more than
+ * once, then the duplicates will be ignored.  The configuration file naming a
+ * particular provider need not be in the same JAR file or other distribution
+ * unit as the provider itself.  The provider must be accessible from the same
+ * class loader that was initially queried to locate the configuration file;
+ * note that this is not necessarily the class loader that found the file.
+ *
+ * <p> <b>Example:</b> Suppose we have a service class named
+ * <tt>java.io.spi.CharCodec</tt>.  It has two abstract methods:
+ *
+ * <pre>
+ *   public abstract CharEncoder getEncoder(String encodingName);
+ *   public abstract CharDecoder getDecoder(String encodingName);
+ * </pre>
+ *
+ * Each method returns an appropriate object or <tt>null</tt> if it cannot
+ * translate the given encoding.  Typical <tt>CharCodec</tt> providers will
+ * support more than one encoding.
+ *
+ * <p> If <tt>sun.io.StandardCodec</tt> is a provider of the <tt>CharCodec</tt>
+ * service then its JAR file would contain the file
+ * <tt>META-INF/services/java.io.spi.CharCodec</tt>.  This file would contain
+ * the single line:
+ *
+ * <pre>
+ *   sun.io.StandardCodec    # Standard codecs for the platform
+ * </pre>
+ *
+ * To locate an encoder for a given encoding name, the internal I/O code would
+ * do something like this:
+ *
+ * <pre>
+ *   CharEncoder getEncoder(String encodingName) {
+ *       Iterator ps = Service.providers(CharCodec.class);
+ *       while (ps.hasNext()) {
+ *           CharCodec cc = (CharCodec)ps.next();
+ *           CharEncoder ce = cc.getEncoder(encodingName);
+ *           if (ce != null)
+ *               return ce;
+ *       }
+ *       return null;
+ *   }
+ * </pre>
+ *
+ * The provider-lookup mechanism always executes in the security context of the
+ * caller.  Trusted system code should typically invoke the methods in this
+ * class from within a privileged security context.
+ *
+ * @author Sun Microsystems, Inc.
+ * 
+ * @since 2.0
+ */
+
+public final class Service {
+
+	private static final Logger log=
+		Logger.getLogger(Service.class.getName());
+
+    private static final String prefix = "META-INF/services/";
+
+    private Service() { }
+
+    private static void fail(Class service, String msg)
+	throws ServiceConfigurationError
+    {
+	throw new ServiceConfigurationError(service.getName() + ": " + msg);
+    }
+
+    private static void fail(Class service, URL u, int line, String msg)
+	throws ServiceConfigurationError
+    {
+	fail(service, u + ":" + line + ": " + msg);
+    }
+
+    /**
+     * Parse a single line from the given configuration file, adding the name
+     * on the line to both the names list and the returned set iff the name is
+     * not already a member of the returned set.
+     */
+    private static int parseLine(Class service, URL u, BufferedReader r, int lc,
+				 List names, Set returned)
+	throws IOException, ServiceConfigurationError
+    {
+	String ln = r.readLine();
+	if (ln == null) {
+	    return -1;
+	}
+	int ci = ln.indexOf('#');
+	if (ci >= 0) ln = ln.substring(0, ci);
+	ln = ln.trim();
+	int n = ln.length();
+	if (n != 0) {
+	    if ((ln.indexOf(' ') >= 0) || (ln.indexOf('\t') >= 0))
+		fail(service, u, lc, "Illegal configuration-file syntax");
+	    if (!Character.isJavaIdentifierStart(ln.charAt(0)))
+		fail(service, u, lc, "Illegal provider-class name: " + ln);
+	    for (int i = 1; i < n; i++) {
+		char c = ln.charAt(i);
+		if (!Character.isJavaIdentifierPart(c) && (c != '.'))
+		    fail(service, u, lc, "Illegal provider-class name: " + ln);
+	    }
+	    if (!returned.contains(ln)) {
+		names.add(ln);
+		returned.add(ln);
+	    }
+	}
+	return lc + 1;
+    }
+
+    /**
+     * Parse the content of the given URL as a provider-configuration file.
+     *
+     * @param  service
+     *         The service class for which providers are being sought;
+     *         used to construct error detail strings
+     *
+     * @param  u
+     *         The URL naming the configuration file to be parsed
+     *
+     * @param  returned
+     *         A Set containing the names of provider classes that have already
+     *         been returned.  This set will be updated to contain the names
+     *         that will be yielded from the returned <tt>Iterator</tt>.
+     *
+     * @return A (possibly empty) <tt>Iterator</tt> that will yield the
+     *         provider-class names in the given configuration file that are
+     *         not yet members of the returned set
+     *
+     * @throws ServiceConfigurationError
+     *         If an I/O error occurs while reading from the given URL, or
+     *         if a configuration-file format error is detected
+     */
+    private static Iterator parse(Class service, URL u, Set returned)
+	throws ServiceConfigurationError
+    {
+	InputStream in = null;
+	BufferedReader r = null;
+	ArrayList names = new ArrayList();
+	try {
+	    in = u.openStream();
+	    r = new BufferedReader(new InputStreamReader(in, "utf-8"));
+	    int lc = 1;
+	    while ((lc = parseLine(service, u, r, lc, names, returned)) >= 0);
+	} catch (IOException x) {
+	    fail(service, ": " + x);
+	} finally {
+	    try {
+		if (r != null) r.close();
+		if (in != null) in.close();
+	    } catch (IOException y) {
+		fail(service, ": " + y);
+	    }
+	}
+	return names.iterator();
+    }
+
+
+    /**
+     * Private inner class implementing fully-lazy provider lookup
+     */
+    private static class LazyIterator implements Iterator {
+
+	Class service;
+	ClassLoader loader;
+	Enumeration configs = null;
+	Iterator pending = null;
+	Set returned = new LinkedHashSet();
+	String nextName = null;
+
+	private LazyIterator(Class service, ClassLoader loader) {
+	    this.service = service;
+	    this.loader = loader;
+	}
+
+	public boolean hasNext() throws ServiceConfigurationError {
+	    if (nextName != null) {
+		return true;
+	    }
+	    if (configs == null) {
+		try {
+		    String fullName = prefix + service.getName();
+		    if (loader == null)
+			configs = ClassLoader.getSystemResources(fullName);
+		    else
+			configs = loader.getResources(fullName);
+		} catch (IOException x) {
+		    fail(service, ": " + x);
+		}
+	    }
+	    while ((pending == null) || !pending.hasNext()) {
+		if (!configs.hasMoreElements()) {
+		    return false;
+		}
+		pending = parse(service, (URL)configs.nextElement(), returned);
+	    }
+	    nextName = (String)pending.next();
+	    return true;
+	}
+
+	public Object next() throws ServiceConfigurationError {
+	    if (!hasNext()) {
+		throw new NoSuchElementException();
+	    }
+	    String cn = nextName;
+	    nextName = null;
+	    try {
+		Class c = LoadClass.forName(cn, true, loader);
+		if (!service.isAssignableFrom(c)) {
+			log.severe("service classloader is "
+					  + service.getClass().getClassLoader()
+					  + ", provider loader is " + loader);
+		    fail(service, "Provider " + cn + " is of incorrect type");
+		}
+		return c.newInstance();
+	    } catch (ClassNotFoundException x) {
+		fail(service,
+		     "Provider " + cn + " not found");
+	    } catch (Exception x) {
+		fail(service,
+		     "Provider " + cn + " could not be instantiated: " + x);
+	    }
+	    return null;	/* This cannot happen */
+	}
+
+	public void remove() {
+	    throw new UnsupportedOperationException();
+	}
+
+    }
+
+
+    /**
+     * Locates and incrementally instantiates the available providers of a
+     * given service using the given class loader.
+     *
+     * <p> This method transforms the name of the given service class into a
+     * provider-configuration filename as described above and then uses the
+     * <tt>getResources</tt> method of the given class loader to find all
+     * available files with that name.  These files are then read and parsed to
+     * produce a list of provider-class names.  The iterator that is returned
+     * uses the given class loader to lookup and then instantiate each element
+     * of the list.
+     *
+     * <p> Because it is possible for extensions to be installed into a running
+     * virtual machine, this method may return different results each time
+     * it is invoked. <p>
+     *
+     * @param  service
+     *         The service's abstract service class
+     *
+     * @param  loader
+     *         The class loader to be used to load provider-configuration files
+     *         and instantiate provider classes, or <tt>null</tt> if the system
+     *         class loader (or, failing that the bootstrap class loader) is to
+     *         be used
+     * 
+     * @return An <tt>Iterator</tt> that yields provider objects for the given
+     *         service, in instantiation order.  The iterator will throw a
+     *         <tt>ServiceConfigurationError</tt> if a provider-configuration
+     *         file violates the specified format or if a provider class cannot
+     *         be found and instantiated.
+     *
+     * @throws ServiceConfigurationError
+     *         If a provider-configuration file violates the specified format
+     *         or names a provider class that cannot be found and instantiated
+     *
+     * @see #providers(java.lang.Class)
+     * @see #installedProviders(java.lang.Class)
+     */
+    public static Iterator providers(Class service, ClassLoader loader)
+	throws ServiceConfigurationError
+    {
+	return new LazyIterator(service, loader);
+    }
+
+
+    /**
+     * Locates and incrementally instantiates the available providers of a
+     * given service using the context class loader.  This convenience method
+     * is equivalent to
+     *
+     * <pre>
+     *   ClassLoader cl = Thread.currentThread().getContextClassLoader();
+     *   return Service.providers(service, cl);
+     * </pre>
+     *
+     * @param  service
+     *         The service's abstract service class
+     *
+     * @return An <tt>Iterator</tt> that yields provider objects for the given
+     *         service, in some arbitrary order.  The iterator will throw a
+     *         <tt>ServiceConfigurationError</tt> if a provider-configuration
+     *         file violates the specified format or if a provider class cannot
+     *         be found and instantiated.
+     *
+     * @throws ServiceConfigurationError
+     *         If a provider-configuration file violates the specified format
+     *         or names a provider class that cannot be found and instantiated
+     *
+     * @see #providers(java.lang.Class, java.lang.ClassLoader)
+     */
+    public static Iterator providers(Class service)
+	throws ServiceConfigurationError
+    {
+	ClassLoader cl = Thread.currentThread().getContextClassLoader();
+	return Service.providers(service, cl);
+    }
+
+
+    /**
+     * Locates and incrementally instantiates the available providers of a
+     * given service using the extension class loader.  This convenience method
+     * simply locates the extension class loader, call it
+     * <tt>extClassLoader</tt>, and then does
+     *
+     * <pre>
+     *   return Service.providers(service, extClassLoader);
+     * </pre>
+     *
+     * If the extension class loader cannot be found then the system class
+     * loader is used; if there is no system class loader then the bootstrap
+     * class loader is used.
+     *
+     * @param  service
+     *         The service's abstract service class
+     *
+     * @return An <tt>Iterator</tt> that yields provider objects for the given
+     *         service, in some arbitrary order.  The iterator will throw a
+     *         <tt>ServiceConfigurationError</tt> if a provider-configuration
+     *         file violates the specified format or if a provider class cannot
+     *         be found and instantiated.
+     *
+     * @throws ServiceConfigurationError
+     *         If a provider-configuration file violates the specified format
+     *         or names a provider class that cannot be found and instantiated
+     *
+     * @see #providers(java.lang.Class, java.lang.ClassLoader)
+     */
+    public static Iterator installedProviders(Class service)
+	throws ServiceConfigurationError
+    {
+	ClassLoader cl = ClassLoader.getSystemClassLoader();
+	if (cl != null) cl = cl.getParent();
+	return Service.providers(service, cl);
+    }
+
+}

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/Executor.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/Executor.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/Executor.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/Executor.java Sun Oct 26 13:17:28 2014
@@ -1,54 +1,57 @@
-/*
- * 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 com.sun.jini.thread;
-
-/**
- * Executor is an abstraction for a thread factory or thread pool for
- * executing actions asynchronously.
- *
- * @author	Sun Microsystems, Inc.
- * 
- */
-public interface Executor {
-
-    /**
-     * Executes the given Runnable action asynchronously in some thread.
-     *
-     * The implementation may create a new thread to execute the action,
-     * or it may execute the action in an existing thread.
-     *
-     * The execution of a given action must not be delayed indefinitely
-     * in order to complete execution of a different action passed to a
-     * different invocation of this method.  In other words, the
-     * implementation must assume that there may be arbitrary dependencies
-     * between actions passed to this method, so it needs to be careful
-     * to avoid potential deadlock by delaying execution of one action
-     * indefinitely until another completes.
-     *
-     * Also, this method itself must not block, because it may be invoked
-     * by code that is serially processing data to produce multiple such
-     * arbitrarily-dependent actions that need to be executed.
-     *
-     * @param	runnable the Runnable action to execute
-     *
-     * @param	name string to include in the name of the thread used
-     * to execute the action
-     */
-    void execute(Runnable runnable, String name);
-}
+/*
+ * 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 com.sun.jini.thread;
+
+import java.util.concurrent.RejectedExecutionException;
+
+/**
+ * Executor is an abstraction for a thread factory or thread pool for
+ * executing actions asynchronously.
+ *
+ * @author	Sun Microsystems, Inc.
+ * 
+ */
+public interface Executor {
+
+    /**
+     * Executes the given Runnable action asynchronously in some thread.
+     *
+     * The implementation may create a new thread to execute the action,
+     * or it may execute the action in an existing thread.
+     *
+     * The execution of a given action must not be delayed indefinitely
+     * in order to complete execution of a different action passed to a
+     * different invocation of this method.  In other words, the
+     * implementation must assume that there may be arbitrary dependencies
+     * between actions passed to this method, so it needs to be careful
+     * to avoid potential deadlock by delaying execution of one action
+     * indefinitely until another completes.
+     *
+     * Also, this method itself must not block, because it may be invoked
+     * by code that is serially processing data to produce multiple such
+     * arbitrarily-dependent actions that need to be executed.
+     *
+     * @param	runnable the Runnable action to execute
+     *
+     * @param	name string to include in the name of the thread used
+     * to execute the action
+     * @throws RejectedExecutionException 
+     */
+    void execute(Runnable runnable, String name) throws RejectedExecutionException;
+}

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/TaskManager.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/TaskManager.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/TaskManager.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/TaskManager.java Sun Oct 26 13:17:28 2014
@@ -52,7 +52,7 @@ import java.util.logging.Logger;
  * </table>
  *
  * @author Sun Microsystems, Inc.
- * @deprecated will be removed from River 2.4.0 onward
+ * @deprecated will be removed from a future release soon.
  */
 @Deprecated
 public class TaskManager {

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/ThreadPool.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/ThreadPool.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/ThreadPool.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/ThreadPool.java Sun Oct 26 13:17:28 2014
@@ -165,7 +165,7 @@ final class ThreadPool implements Execut
 
     // This method must not block - Executor
     @Override
-    public void execute(Runnable runnable, String name) {
+    public void execute(Runnable runnable, String name) throws RejectedExecutionException {
         if (runnable == null) return;
         if (shutdown) throw new RejectedExecutionException("ThreadPool shutdown");
 	Runnable task = new Task(runnable, name);

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/ClassDep.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/ClassDep.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/ClassDep.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/ClassDep.java Sun Oct 26 13:17:28 2014
@@ -883,9 +883,9 @@ public class ClassDep {
         Map classDependencyRelationMap = null;
         try{
             classDependencyRelationMap = cd.getDependencyRelationshipMap(classes, true); // get the reference to Collection<Class>
-        }catch (ClassNotFoundException e){
+        } catch (ClassNotFoundException e){
             e.printStackTrace();
-        }catch (IOException e) {
+        } catch (IOException e) {
             e.printStackTrace();
         }
          
@@ -1328,8 +1328,8 @@ public class ClassDep {
             //boolean files = false;
             dep.setupOptions(args);
             String[] vals = dep.compute();
-
-            for (int i = 0; i < vals.length; i++) {
+            int l = vals.length;
+            for (int i = 0; i < l; i++) {
                 if (dep.getFiles()) {
                     System.out.println(vals[i].replace('.', File.separatorChar) + ".class");
                 } else {
@@ -1337,6 +1337,7 @@ public class ClassDep {
                 }
             }
         } finally {
+            System.out.flush();
             System.out.close();
         }
     }

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/envcheck/plugins/CheckPersistence.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/envcheck/plugins/CheckPersistence.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/envcheck/plugins/CheckPersistence.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/envcheck/plugins/CheckPersistence.java Sun Oct 26 13:17:28 2014
@@ -1,244 +1,246 @@
-/*
- * 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 com.sun.jini.tool.envcheck.plugins;
-
-import com.sun.jini.start.ServiceDescriptor;
-import com.sun.jini.start.SharedActivatableServiceDescriptor;
-import com.sun.jini.start.SharedActivationGroupDescriptor;
-import com.sun.jini.tool.envcheck.AbstractPlugin;
-import com.sun.jini.tool.envcheck.EnvCheck;
-import com.sun.jini.tool.envcheck.Reporter;
-import com.sun.jini.tool.envcheck.Reporter.Message;
-import com.sun.jini.tool.envcheck.SubVMTask;
-import com.sun.jini.tool.envcheck.Util;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.ResourceBundle;
-import java.util.Set;
-import net.jini.config.Configuration;
-import net.jini.config.ConfigurationException;
-import net.jini.config.ConfigurationFile;
-import net.jini.config.ConfigurationProvider;
-import org.apache.river.api.security.CombinerSecurityManager;
-
-/**
- * Check that the persistence directory supplied by any
- * <code>SharedActivatableServiceDescriptor</code>s are either non-existant or
- * empty. Check is performed in a subtask VM started identically to how the
- * activation system would have started it. The first entry in the service
- * configuration named <code>persistenceDirectory</code> is checked. Doesn't
- * work correctly if multiple services share a configuration. Don't know how to
- * handle this.
- */
-public class CheckPersistence extends AbstractPlugin {
-
-    EnvCheck envCheck;
-
-    /**
-     * Check the persistence directory for every
-     * <code>SharedActivatableServiceDescriptor</code> in the starter
-     * configuration.
-     *
-     * @param envCheck the plugin container
-     */
-    public void run(EnvCheck envCheck) {
-        this.envCheck = envCheck;
-	ServiceDescriptor[] d = envCheck.getDescriptors();
-	for (int i = 0; i < d.length; i++) {
-	    if (d[i] instanceof SharedActivatableServiceDescriptor) {
-		SharedActivatableServiceDescriptor sd = 
-		    (SharedActivatableServiceDescriptor) d[i];
-		checkDirectory(sd);
-	    }
-	}
-    }
-
-    /** 
-     * Launch a subtask for the given descriptor to obtain all the
-     * <code>persistenceDirectory</code> entries. Check each
-     * entry found for validity.
-     *
-     * @param d the descriptor to check, which must be a
-     *        <code>SharedActivatableServiceDescriptor</code
-     */
-    private void checkDirectory(SharedActivatableServiceDescriptor d) {
-	SharedActivationGroupDescriptor gd = envCheck.getGroupDescriptor();
-	String source = getString("descfor", d.getImplClassName());
-	Object o = envCheck.launch(d, gd, taskName("GetEntriesTask"));
-	if (o instanceof String[]) {
-	    checkEntries((String[]) o, d, source);
-	} else if (o instanceof String) {
-	    Message message = new Message(Reporter.WARNING,
-					  (String) o,
-					  getString("dirExp"));
-	    Reporter.print(message, source);
-	} else {
-	    handleUnexpectedSubtaskReturn(o, source);
-	}
-    }
-
-    /** 
-     * Check <code>entries</code> for validity. <code>entries</code> 
-     * contains a collection of pairs, the first being the fully
-     * qualified name of the <code>persistenceDirectory</code> entry,
-     * and the second being its value.
-     *
-     * @param entries the array of entry/value pairs
-     * @param d the descriptor
-     * @param source the source descriptive text
-     */
-    private void checkEntries(String[] entries, 
-			      SharedActivatableServiceDescriptor d,
-			      String source) 
-    {
-	if (entries.length == 0) {
-	    Message message = new Message(Reporter.WARNING,
-					  getString("noentry"),
-					  getString("dirExp"));
-	    Reporter.print(message, source);
-	}
-	for (int i = 0; i < entries.length; i += 2) {
-	    String name = entries[i];
-	    String dir = entries[i + 1];
-	    String loopSource = source + ": " + name + "=" + dir;
-	    Object lobj = checkDir(dir, d);
-	    Message message;
-	    if (lobj == null) {
-		message = new Message(Reporter.INFO,
-				      getString("dirOK"),
-				      getString("dirExp"));
-		Reporter.print(message, loopSource);
-	    } else if (lobj instanceof String) {
-		message = new Message(Reporter.ERROR,
-				      (String) lobj,
-				      getString("dirExp"));
-		Reporter.print(message, loopSource);
-	    } else {
-		handleUnexpectedSubtaskReturn(lobj, loopSource);
-	    }
-	}
-    }
-
-    /**
-     * Perform a check on the given persistence directory. 
-     *
-     * @param dir the name of the directory to check
-     * @param d the service descriptor
-     * @return <code>null</code> if the specified directory is empty
-     *         or non-existant (i.e. OK). Otherwise returns an error message
-     *         or <code>Throwable</code> returned by the subtask.
-     */
-    private Object checkDir(String dir, SharedActivatableServiceDescriptor d) {
-	if (dir == null) {
-	    return getString("nulldir");
-	}
-	String taskName = taskName("CheckDirTask");
-	String[] args = new String[]{dir};
-	SharedActivationGroupDescriptor g =  envCheck.getGroupDescriptor();
-	return envCheck.launch(d, g, taskName, args);
-    }
-
-    /**
-     * Perform directory check with an active security policy in place.
-     */
-    public static class CheckDirTask implements SubVMTask {
-
-	private ResourceBundle bundle = 
-	    Util.getResourceBundle(CheckPersistence.class);
-
-	public Object run(String[] args) {
-	    System.setSecurityManager(new CombinerSecurityManager());
-	    String dir = args[0];
-	    File dirFile = new File(dir);
-	    if (!dirFile.exists()) {
-		return null; // the OK value
-	    }
-	    if (!dirFile.isDirectory()) {
-		return Util.getString("notadir", bundle, dir);
-	    }
-	    File[] contents = dirFile.listFiles();
-	    if (contents == null) { // should never happen
-		return Util.getString("emptylist", bundle, dir);
-	    }
-	    if (contents.length > 0) {
-		return Util.getString("dirnotempty", bundle, dir);
-	    }
-	    return null; // directory exists but is empty
-	}
-    }
-
-    /**
-     * The subtask which obtains the list of persistence directory entries. The
-     * arg list is cleaned up, the configuration in obtained, and a String array
-     * of pairs of all entries named  <code>persistenceDirectory</code> and
-     * their associated value is returned.
-     */
-    public static class GetEntriesTask implements SubVMTask {
-
-	private ResourceBundle bundle = 
-	    Util.getResourceBundle(CheckPersistence.class);
-
-	public Object run(String[] args) {
-	    try {
-		Configuration config = 
-		    ConfigurationProvider.getInstance(args);
-		return getEntries(config);
-	    } catch (ConfigurationException e) {
-		return Util.getString("configproblem", bundle, e.getMessage());
-	    } catch (Exception e) {
-		return e;
-	    }
-	}
-
-	/**
-	 * Obtain all of the <code>persistenceDirectory</code> entries in the
-	 * configuration and return them as pairs in a <code>String</code>
-	 * array.
-	 *
-	 * @param conf the configuration to examine
-	 * @return the array of entry/value pairs
-	 */
-	private Object getEntries(Configuration conf) {
-	    ConfigurationFile cf = (ConfigurationFile) conf;
-	    ArrayList<String> list = new ArrayList<String>();
-	    Set<String> names = cf.getEntryNames();
-	    Iterator<String> it = names.iterator();
-	    String s = "";
-	    while (it.hasNext()) {
-		String name = it.next();
-		s += name + "\n";
-		int lastDot = name.lastIndexOf(".persistenceDirectory");
-		if (lastDot > 0) {
-		    String component = name.substring(0, lastDot);
-		    try {
-			String dir = conf.getEntry(component, 
-						   "persistenceDirectory",
-						   String.class,
-						   null);
-			list.add(name);
-			list.add(dir);
-		    } catch (ConfigurationException e) {
-			return e;
-		    }
-		}
-	    }
-	    return list.toArray(new String[list.size()]);
-	}
-    }
-}
+/*
+ * 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 com.sun.jini.tool.envcheck.plugins;
+
+import com.sun.jini.start.ServiceDescriptor;
+import com.sun.jini.start.SharedActivatableServiceDescriptor;
+import com.sun.jini.start.SharedActivationGroupDescriptor;
+import com.sun.jini.tool.envcheck.AbstractPlugin;
+import com.sun.jini.tool.envcheck.EnvCheck;
+import com.sun.jini.tool.envcheck.Reporter;
+import com.sun.jini.tool.envcheck.Reporter.Message;
+import com.sun.jini.tool.envcheck.SubVMTask;
+import com.sun.jini.tool.envcheck.Util;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.ResourceBundle;
+import java.util.Set;
+import net.jini.config.Configuration;
+import net.jini.config.ConfigurationException;
+import net.jini.config.ConfigurationFile;
+import net.jini.config.ConfigurationProvider;
+import org.apache.river.api.security.CombinerSecurityManager;
+
+/**
+ * Check that the persistence directory supplied by any
+ * <code>SharedActivatableServiceDescriptor</code>s are either non-existant or
+ * empty. Check is performed in a subtask VM started identically to how the
+ * activation system would have started it. The first entry in the service
+ * configuration named <code>persistenceDirectory</code> is checked. Doesn't
+ * work correctly if multiple services share a configuration. Don't know how to
+ * handle this.
+ */
+public class CheckPersistence extends AbstractPlugin {
+
+    EnvCheck envCheck;
+
+    /**
+     * Check the persistence directory for every
+     * <code>SharedActivatableServiceDescriptor</code> in the starter
+     * configuration.
+     *
+     * @param envCheck the plugin container
+     */
+    public void run(EnvCheck envCheck) {
+        this.envCheck = envCheck;
+	ServiceDescriptor[] d = envCheck.getDescriptors();
+	for (int i = 0; i < d.length; i++) {
+	    if (d[i] instanceof SharedActivatableServiceDescriptor) {
+		SharedActivatableServiceDescriptor sd = 
+		    (SharedActivatableServiceDescriptor) d[i];
+		checkDirectory(sd);
+	    }
+	}
+    }
+
+    /** 
+     * Launch a subtask for the given descriptor to obtain all the
+     * <code>persistenceDirectory</code> entries. Check each
+     * entry found for validity.
+     *
+     * @param d the descriptor to check, which must be a
+     *        <code>SharedActivatableServiceDescriptor</code
+     */
+    private void checkDirectory(SharedActivatableServiceDescriptor d) {
+	SharedActivationGroupDescriptor gd = envCheck.getGroupDescriptor();
+	String source = getString("descfor", d.getImplClassName());
+	Object o = envCheck.launch(d, gd, taskName("GetEntriesTask"));
+	if (o instanceof String[]) {
+	    checkEntries((String[]) o, d, source);
+	} else if (o instanceof String) {
+	    Message message = new Message(Reporter.WARNING,
+					  (String) o,
+					  getString("dirExp"));
+	    Reporter.print(message, source);
+	} else {
+	    handleUnexpectedSubtaskReturn(o, source);
+	}
+    }
+
+    /** 
+     * Check <code>entries</code> for validity. <code>entries</code> 
+     * contains a collection of pairs, the first being the fully
+     * qualified name of the <code>persistenceDirectory</code> entry,
+     * and the second being its value.
+     *
+     * @param entries the array of entry/value pairs
+     * @param d the descriptor
+     * @param source the source descriptive text
+     */
+    private void checkEntries(String[] entries, 
+			      SharedActivatableServiceDescriptor d,
+			      String source) 
+    {
+	if (entries.length == 0) {
+	    Message message = new Message(Reporter.WARNING,
+					  getString("noentry"),
+					  getString("dirExp"));
+	    Reporter.print(message, source);
+	}
+	for (int i = 0; i < entries.length; i += 2) {
+	    String name = entries[i];
+	    String dir = entries[i + 1];
+	    String loopSource = source + ": " + name + "=" + dir;
+	    Object lobj = checkDir(dir, d);
+	    Message message;
+	    if (lobj == null) {
+		message = new Message(Reporter.INFO,
+				      getString("dirOK"),
+				      getString("dirExp"));
+		Reporter.print(message, loopSource);
+	    } else if (lobj instanceof String) {
+		message = new Message(Reporter.ERROR,
+				      (String) lobj,
+				      getString("dirExp"));
+		Reporter.print(message, loopSource);
+	    } else {
+		handleUnexpectedSubtaskReturn(lobj, loopSource);
+	    }
+	}
+    }
+
+    /**
+     * Perform a check on the given persistence directory. 
+     *
+     * @param dir the name of the directory to check
+     * @param d the service descriptor
+     * @return <code>null</code> if the specified directory is empty
+     *         or non-existant (i.e. OK). Otherwise returns an error message
+     *         or <code>Throwable</code> returned by the subtask.
+     */
+    private Object checkDir(String dir, SharedActivatableServiceDescriptor d) {
+	if (dir == null) {
+	    return getString("nulldir");
+	}
+	String taskName = taskName("CheckDirTask");
+	String[] args = new String[]{dir};
+	SharedActivationGroupDescriptor g =  envCheck.getGroupDescriptor();
+	return envCheck.launch(d, g, taskName, args);
+    }
+
+    /**
+     * Perform directory check with an active security policy in place.
+     */
+    public static class CheckDirTask implements SubVMTask {
+
+	private ResourceBundle bundle = 
+	    Util.getResourceBundle(CheckPersistence.class);
+
+	public Object run(String[] args) {
+            if (System.getSecurityManager() == null) {
+	    System.setSecurityManager(new CombinerSecurityManager());
+            }
+	    String dir = args[0];
+	    File dirFile = new File(dir);
+	    if (!dirFile.exists()) {
+		return null; // the OK value
+	    }
+	    if (!dirFile.isDirectory()) {
+		return Util.getString("notadir", bundle, dir);
+	    }
+	    File[] contents = dirFile.listFiles();
+	    if (contents == null) { // should never happen
+		return Util.getString("emptylist", bundle, dir);
+	    }
+	    if (contents.length > 0) {
+		return Util.getString("dirnotempty", bundle, dir);
+	    }
+	    return null; // directory exists but is empty
+	}
+    }
+
+    /**
+     * The subtask which obtains the list of persistence directory entries. The
+     * arg list is cleaned up, the configuration in obtained, and a String array
+     * of pairs of all entries named  <code>persistenceDirectory</code> and
+     * their associated value is returned.
+     */
+    public static class GetEntriesTask implements SubVMTask {
+
+	private ResourceBundle bundle = 
+	    Util.getResourceBundle(CheckPersistence.class);
+
+	public Object run(String[] args) {
+	    try {
+		Configuration config = 
+		    ConfigurationProvider.getInstance(args);
+		return getEntries(config);
+	    } catch (ConfigurationException e) {
+		return Util.getString("configproblem", bundle, e.getMessage());
+	    } catch (Exception e) {
+		return e;
+	    }
+	}
+
+	/**
+	 * Obtain all of the <code>persistenceDirectory</code> entries in the
+	 * configuration and return them as pairs in a <code>String</code>
+	 * array.
+	 *
+	 * @param conf the configuration to examine
+	 * @return the array of entry/value pairs
+	 */
+	private Object getEntries(Configuration conf) {
+	    ConfigurationFile cf = (ConfigurationFile) conf;
+	    ArrayList<String> list = new ArrayList<String>();
+	    Set<String> names = cf.getEntryNames();
+	    Iterator<String> it = names.iterator();
+	    String s = "";
+	    while (it.hasNext()) {
+		String name = it.next();
+		s += name + "\n";
+		int lastDot = name.lastIndexOf(".persistenceDirectory");
+		if (lastDot > 0) {
+		    String component = name.substring(0, lastDot);
+		    try {
+			String dir = conf.getEntry(component, 
+						   "persistenceDirectory",
+						   String.class,
+						   null);
+			list.add(name);
+			list.add(dir);
+		    } catch (ConfigurationException e) {
+			return e;
+		    }
+		}
+	    }
+	    return list.toArray(new String[list.size()]);
+	}
+    }
+}

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/envcheck/plugins/FileAccessCheckTask.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/envcheck/plugins/FileAccessCheckTask.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/envcheck/plugins/FileAccessCheckTask.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/envcheck/plugins/FileAccessCheckTask.java Sun Oct 26 13:17:28 2014
@@ -1,47 +1,49 @@
-/*
- * 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 com.sun.jini.tool.envcheck.plugins;
-
-import com.sun.jini.tool.envcheck.SubVMTask;
-import com.sun.jini.tool.envcheck.Util;
-import org.apache.river.api.security.CombinerSecurityManager;
-
-/**
- * A subtask which checks for the accessibility of a file identified
- * by a system property.
- */
-public class FileAccessCheckTask implements SubVMTask {
-    
-    /**
-     * Check for the accessibility of a file identified by a
-     * system property. Returns <code>null</code> if the file exists
-     * and is readable. Any non-<code>null</code> return will either
-     * be a <code>String</code> containing an error message, or a
-     * <code>Throwable</code> that was thrown in the course of the check.
-     * <code>args[0]</code> must contain the name of the system property. <code>args[1]</code>
-     * must contain a localized description of the file being accessed.
-     *
-     * @param args the command line args
-     * @return the result of the check
-     */
-    public Object run(String[] args) {
-	System.setSecurityManager(new CombinerSecurityManager());
-	return Util.checkSystemPropertyFile(args[0], args[1]);
-    }
-}	
-
+/*
+ * 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 com.sun.jini.tool.envcheck.plugins;
+
+import com.sun.jini.tool.envcheck.SubVMTask;
+import com.sun.jini.tool.envcheck.Util;
+import org.apache.river.api.security.CombinerSecurityManager;
+
+/**
+ * A subtask which checks for the accessibility of a file identified
+ * by a system property.
+ */
+public class FileAccessCheckTask implements SubVMTask {
+    
+    /**
+     * Check for the accessibility of a file identified by a
+     * system property. Returns <code>null</code> if the file exists
+     * and is readable. Any non-<code>null</code> return will either
+     * be a <code>String</code> containing an error message, or a
+     * <code>Throwable</code> that was thrown in the course of the check.
+     * <code>args[0]</code> must contain the name of the system property. <code>args[1]</code>
+     * must contain a localized description of the file being accessed.
+     *
+     * @param args the command line args
+     * @return the result of the check
+     */
+    public Object run(String[] args) {
+        if (System.getSecurityManager() == null) {
+	System.setSecurityManager(new CombinerSecurityManager());
+        }
+	return Util.checkSystemPropertyFile(args[0], args[1]);
+    }
+}	
+

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/discovery/LookupLocator.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/discovery/LookupLocator.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/discovery/LookupLocator.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/discovery/LookupLocator.java Sun Oct 26 13:17:28 2014
@@ -19,20 +19,20 @@ package net.jini.core.discovery;
 
 import com.sun.jini.discovery.Discovery;
 import com.sun.jini.discovery.DiscoveryConstraints;
+import com.sun.jini.discovery.DiscoveryProtocolVersion;
 import com.sun.jini.discovery.UnicastResponse;
 import com.sun.jini.discovery.UnicastSocketTimeout;
 import com.sun.jini.discovery.internal.MultiIPDiscovery;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.Serializable;
+import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.Socket;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collection;
 import net.jini.core.constraint.InvocationConstraints;
 import net.jini.core.lookup.ServiceRegistrar;
 import net.jini.discovery.ConstrainableLookupLocator;
@@ -41,7 +41,8 @@ import org.apache.river.api.net.Uri;
 /**
  * LookupLocator supports unicast discovery, using either Discovery V1 or V2.
  * 
- * Version 1 of the unicast discovery protocol is deprecated.  
+ * Version 1 of the unicast discovery protocol is deprecated.  By default
+ * Discovery V2 is a preferred constraint.
  * <p>
  * It's main purpose now is to contain a host name and port number, it is now
  * immutable, since River 2.2.1, this may break overriding classes.
@@ -59,16 +60,12 @@ import org.apache.river.api.net.Uri;
  */
 public class LookupLocator implements Serializable {
     private static final long serialVersionUID = 1448769379829432795L;
-
+    
     /**
      * The port for both unicast and multicast boot requests.
      */
     private static final short discoveryPort = 4160;
-    /**
-     * The current version of the unicast discovery protocol.
-     */
-    private static final int protoVersion = 1;
-
+    
     /**
      * The name of the host at which to perform discovery.
      *
@@ -86,7 +83,7 @@ public class LookupLocator implements Se
      * The timeout after which we give up waiting for a response from
      * the lookup service.
      */
-    static final int defaultTimeout =
+    private static final int defaultTimeout =
 	AccessController.doPrivileged(new PrivilegedAction<Integer>() {
             @Override
 	    public Integer run() {
@@ -312,13 +309,31 @@ public class LookupLocator implements Se
     public ServiceRegistrar getRegistrar(int timeout)
 	throws IOException, ClassNotFoundException
     {
-	InvocationConstraints ic = InvocationConstraints.EMPTY;
-	Collection reqs = new ArrayList(ic.requirements());
-	reqs.add(new UnicastSocketTimeout(timeout));
-	return getRegistrar(new InvocationConstraints(reqs, ic.preferences()));
+	return getRegistrar(
+                new InvocationConstraints(
+                        new UnicastSocketTimeout(timeout), 
+                        DiscoveryProtocolVersion.TWO 
+                )
+        );
     }
 
-    private ServiceRegistrar getRegistrar(InvocationConstraints constraints)
+    /**
+     * Perform unicast discovery and return the ServiceRegistrar
+     * object for the given lookup service, with the given constraints.
+     * 
+     * Unicast discovery is performed anew each time this method is called.
+     * <code>LookupLocator</code> implements this method to use the values
+     * of the <code>host</code> and <code>port</code> field in determining
+     * the host and port to connect to.
+     * @param constraints
+     * @return lookup service proxy
+     * @throws IOException
+     * @throws net.jini.io.UnsupportedConstraintException if the
+     * discovery-related constraints contain conflicts, or otherwise cannot be
+     * processed
+     * @throws ClassNotFoundException
+     */
+    protected final ServiceRegistrar getRegistrar(InvocationConstraints constraints)
             throws IOException, ClassNotFoundException {
         UnicastResponse resp = new MultiIPDiscovery() {
             @Override

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/event/RemoteEvent.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/event/RemoteEvent.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/event/RemoteEvent.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/event/RemoteEvent.java Sun Oct 26 13:17:28 2014
@@ -142,6 +142,7 @@ public class RemoteEvent extends java.ut
      *
      * @return   The object on which the RemoteEvent initially occurred.
      */
+    @Override
     public Object getSource(){
         return source;
     }

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/lookup/ServiceEvent.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/lookup/ServiceEvent.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/lookup/ServiceEvent.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/lookup/ServiceEvent.java Sun Oct 26 13:17:28 2014
@@ -94,8 +94,9 @@ public abstract class ServiceEvent exten
      * <code>ServiceEvent</code>.
      * @return a <code>String</code> representation of this object
      */
+    @Override
     public String toString() {
-	StringBuffer sBuffer = new StringBuffer();
+	StringBuilder sBuffer = new StringBuilder(256);
 	sBuffer.append(getClass().getName()).append(
 	       "[serviceID=").append(getServiceID()).append(
 	       ", transition=");
@@ -127,5 +128,15 @@ public abstract class ServiceEvent exten
      * @return a <tt>ServiceItem</tt> object representing the service item value
      */
     public abstract ServiceItem getServiceItem();
+    
+    /**
+     * Serialization evolution support
+     * @serialData 
+     */
+    private void readObject(java.io.ObjectInputStream stream)
+	throws java.io.IOException, ClassNotFoundException
+    {
+	stream.defaultReadObject();
+    }
 }
 

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/lookup/ServiceItem.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/lookup/ServiceItem.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/lookup/ServiceItem.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/lookup/ServiceItem.java Sun Oct 26 13:17:28 2014
@@ -17,6 +17,9 @@
  */
 package net.jini.core.lookup;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamField;
 import net.jini.core.entry.Entry;
 
 /**
@@ -27,27 +30,24 @@ import net.jini.core.entry.Entry;
  *
  * @since 1.0
  */
-public class ServiceItem implements java.io.Serializable {
+public class ServiceItem implements java.io.Serializable, Cloneable {
 
     private static final long serialVersionUID = 717395451032330758L;
+    private static final ObjectStreamField[] serialPersistentFields = 
+    { 
+        /** @serialField serviceID ServiceID Universally unique identifier for services */
+        new ObjectStreamField("serviceID", ServiceID.class),
+        /** @serialField service Object A service proxy */
+        new ObjectStreamField("service", Object.class),
+        /** @serialField attributeSets Entry[] Attribute sets */
+        new ObjectStreamField("attributeSets", Entry[].class)
+    };
 
-    /**
-     * A service ID, or null if registering for the first time.
-     *
-     * @serial
-     */
+    /** A service ID, or null if registering for the first time. */
     public ServiceID serviceID;
-    /**
-     * A service object.
-     *
-     * @serial
-     */
+    /** A service object. */
     public Object service;
-    /**
-     * Attribute sets.
-     *
-     * @serial
-     */
+    /** Attribute sets. */
     public Entry[] attributeSets;
 
     /**
@@ -70,8 +70,9 @@ public class ServiceItem implements java
      * @return <code>String</code> representation of this 
      * <code>ServiceItem</code>
      */
-    public String toString() {
-	StringBuffer sBuffer = new StringBuffer();
+    public String toString() 
+    {
+	StringBuilder sBuffer = new StringBuilder(256);
 	sBuffer.append(
 	       getClass().getName()).append(
 	       "[serviceID=").append(serviceID).append(
@@ -90,4 +91,35 @@ public class ServiceItem implements java
 	}
 	return sBuffer.append("]").toString();
     }
+    
+    /**
+     * Clone has been implemented to allow utilities such as
+     * {@link net.jini.lookup.ServiceDiscoveryManager} to avoid sharing 
+     * internally stored instances with client code.
+     * 
+     * @return a clone of the original ServiceItem
+     */
+    @Override
+    public ServiceItem clone() 
+    {
+        try {
+            ServiceItem clone = (ServiceItem) super.clone();
+            clone.attributeSets = clone.attributeSets.clone();
+            return clone;
+        } catch (CloneNotSupportedException ex) {
+            throw new AssertionError();
+        }
+    }
+    
+    /**
+     * @serialData 
+     * @param in
+     * @throws IOException
+     * @throws ClassNotFoundException 
+     */
+    private void readObject(ObjectInputStream in)
+	throws IOException, ClassNotFoundException
+    {
+	in.defaultReadObject();
+    }
 }

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/AbstractLookupDiscovery.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/AbstractLookupDiscovery.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/AbstractLookupDiscovery.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/AbstractLookupDiscovery.java Sun Oct 26 13:17:28 2014
@@ -111,7 +111,7 @@ abstract class AbstractLookupDiscovery i
     /** Maximum number of concurrent tasks that can be run in any executor
      * created by this class.
      */
-    private static final int MAX_N_TASKS = 15;
+    private static final int MAX_N_TASKS = 5;
     /** Default maximum size of multicast packets to send and receive. */
     private static final int DEFAULT_MAX_PACKET_SIZE = 512;
     /** Default time to live value to use for sending multicast packets. */

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/AbstractLookupLocatorDiscovery.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/AbstractLookupLocatorDiscovery.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/AbstractLookupLocatorDiscovery.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/AbstractLookupLocatorDiscovery.java Sun Oct 26 13:17:28 2014
@@ -39,7 +39,6 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.WeakHashMap;
 import java.util.concurrent.BlockingDeque;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
@@ -270,6 +269,7 @@ abstract class AbstractLookupLocatorDisc
 	    throws IOException, ClassNotFoundException
         {
 	    UnicastResponse resp = new MultiIPDiscovery() {
+                @Override
 		protected UnicastResponse performDiscovery(
 							Discovery disco,
 							DiscoveryConstraints dc,
@@ -285,6 +285,7 @@ abstract class AbstractLookupLocatorDisc
 		    
 		}
 		
+                @Override
 		protected void socketCloseException(IOException e) {
 		   logger.log(Level.FINEST,
 		       "IOException on socket close upon "
@@ -292,6 +293,7 @@ abstract class AbstractLookupLocatorDisc
 		       e);	
 		}
 		
+                @Override
 		protected void singleResponseException(Exception e,
 						       InetAddress addr,
 						       int port)

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/ConstrainableLookupLocator.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/ConstrainableLookupLocator.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/ConstrainableLookupLocator.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/ConstrainableLookupLocator.java Sun Oct 26 13:17:28 2014
@@ -95,7 +95,6 @@ public final class ConstrainableLookupLo
 {
     private static final long serialVersionUID = 7061417093114347317L;
 
-    private static final int DEFAULT_TIMEOUT = 60 * 1000;
     private static final Method getRegistrarMethod;
     private static final Method getRegistrarTimeoutMethod;
     static {
@@ -206,10 +205,13 @@ public final class ConstrainableLookupLo
      * <code>ConstrainableLookupLocator</code> implements this method to use the
      * values of the <code>host</code> and <code>port</code> field in
      * determining the host and port to connect to.
+     * @return lookup service proxy
      * @throws net.jini.io.UnsupportedConstraintException if the
      * discovery-related constraints contain conflicts, or otherwise cannot be
      * processed
+     * @throws java.lang.ClassNotFoundException
      */
+    @Override
     public ServiceRegistrar getRegistrar()
 	throws IOException, ClassNotFoundException
     {
@@ -224,9 +226,11 @@ public final class ConstrainableLookupLo
      * supplied discovery constraints. The <code>timeout</code> is considered a
      * requirement with respect to other constraints specified for this
      * instance.
+     * @return lookup service proxy
      * @throws net.jini.io.UnsupportedConstraintException if the
      * discovery-related constraints contain conflicts, or otherwise cannot be
      * processed
+     * @throws java.lang.ClassNotFoundException
      */
     @Override
     public ServiceRegistrar getRegistrar(int timeout)
@@ -259,19 +263,4 @@ public final class ConstrainableLookupLo
 	return constraints;
     }
 
-    private ServiceRegistrar getRegistrar(InvocationConstraints constraints)
-	throws IOException, ClassNotFoundException
-    {
-	UnicastResponse resp = new MultiIPDiscovery() {	    
-	    protected UnicastResponse performDiscovery(Discovery disco,
-		    DiscoveryConstraints dc,
-		    Socket s)
-		throws IOException, ClassNotFoundException
-	    {
-		return disco.doUnicastDiscovery(
-		    s, dc.getUnfulfilledConstraints(), null, null, null);
-	    }
-	}.getResponse(host, port, constraints);
-	return resp.getRegistrar();
-    }
 }
\ No newline at end of file



Mime
View raw message