You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pa...@apache.org on 2010/09/16 03:36:11 UTC
svn commit: r997556 [2/2] - in /incubator/river/jtsk/skunk/patsTaskManager:
./ examples/hello/src/com/sun/jini/example/hello/ lib/ qa/ qa/doc/
qa/src/com/sun/jini/test/impl/joinmanager/
qa/src/com/sun/jini/test/impl/norm/ qa/src/com/sun/jini/test/impl/...
Modified: incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/outrigger/JoinStateManager.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/outrigger/JoinStateManager.java?rev=997556&r1=997555&r2=997556&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/outrigger/JoinStateManager.java (original)
+++ incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/outrigger/JoinStateManager.java Thu Sep 16 01:36:08 2010
@@ -29,6 +29,7 @@ import java.util.logging.Logger;
import net.jini.core.discovery.LookupLocator;
import net.jini.core.entry.Entry;
import net.jini.core.lookup.ServiceID;
+import net.jini.discovery.DiscoveryManagement;
import net.jini.discovery.DiscoveryLocatorManagement;
import net.jini.discovery.DiscoveryGroupManagement;
import net.jini.discovery.LookupDiscoveryManager;
@@ -40,8 +41,6 @@ import net.jini.security.ProxyPreparer;
import com.sun.jini.config.Config;
import com.sun.jini.logging.Levels;
-import net.jini.discovery.DiscoveryListenerManagement;
-import net.jini.discovery.RegistrarManagement;
/**
* <code>JoinStateManager</code> provides a utility that manages
@@ -166,20 +165,8 @@ class JoinStateManager implements Storab
new LookupDiscoveryManager(
DiscoveryGroupManagement.NO_GROUPS, null, null,
config));
-
- if (!(dgm instanceof DiscoveryListenerManagement))
- throw throwNewConfigurationException("Entry for component " +
- OutriggerServerImpl.COMPONENT_NAME + ", name " +
- "discoveryManager must implement " +
- "net.jini.discovery.DiscoveryListenerManagement");
-
- if (!(dgm instanceof RegistrarManagement))
- throw throwNewConfigurationException("Entry for component " +
- OutriggerServerImpl.COMPONENT_NAME + ", name " +
- "discoveryManager must implement " +
- "net.jini.discovery.RegistrarManagement");
-
- if (!(dgm instanceof DiscoveryGroupManagement))
+
+ if (!(dgm instanceof DiscoveryManagement))
throw throwNewConfigurationException("Entry for component " +
OutriggerServerImpl.COMPONENT_NAME + ", name " +
"discoveryManager must implement " +
@@ -316,7 +303,7 @@ class JoinStateManager implements Storab
((DiscoveryLocatorManagement)dgm).setLocators(locators);
mgr = new JoinManager(service, attributes, serviceID,
- (DiscoveryListenerManagement)dgm, null, config);
+ (DiscoveryManagement)dgm, null, config);
// Once we are running we don't need the attributes,
// locators, and groups fields, null them out (the
@@ -341,7 +328,7 @@ class JoinStateManager implements Storab
mgr.terminate();
if (dgm != null)
- ((RegistrarManagement)dgm).terminate();
+ ((DiscoveryManagement)dgm).terminate();
}
/* Basically we are implementing JoinAdmin, for get methods we just
Modified: incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/reggie/RegistrarImpl.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/reggie/RegistrarImpl.java?rev=997556&r1=997555&r2=997556&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/reggie/RegistrarImpl.java (original)
+++ incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/reggie/RegistrarImpl.java Thu Sep 16 01:36:08 2010
@@ -109,7 +109,6 @@ import net.jini.core.lookup.ServiceRegis
import net.jini.discovery.Constants;
import net.jini.discovery.ConstrainableLookupLocator;
import net.jini.discovery.DiscoveryGroupManagement;
-import net.jini.discovery.DiscoveryListenerManagement;
import net.jini.discovery.DiscoveryLocatorManagement;
import net.jini.discovery.DiscoveryManagement;
import net.jini.discovery.LookupDiscoveryManager;
@@ -4671,7 +4670,7 @@ class RegistrarImpl implements Registrar
throw new ConfigurationException(null, e);
}
joiner = new JoinManager(proxy, lookupAttrs, myServiceID,
- (DiscoveryListenerManagement) discoer, null, config);
+ discoer, null, config);
/* start up all the daemon threads */
serviceExpirer.start();
Modified: incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/thread/TaskManager.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/thread/TaskManager.java?rev=997556&r1=997555&r2=997556&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/thread/TaskManager.java (original)
+++ incubator/river/jtsk/skunk/patsTaskManager/src/com/sun/jini/thread/TaskManager.java Thu Sep 16 01:36:08 2010
@@ -82,7 +82,7 @@ public class TaskManager {
/** Read-only view of tasks */
protected final List roTasks = Collections.unmodifiableList(tasks);
/** Active threads */
- protected final List<TaskThread> threads = new ArrayList<TaskThread>();
+ protected final List threads = new ArrayList();
/** Maximum number of threads allowed */
protected final int maxThreads;
/** Idle time before a thread should exit */
@@ -130,10 +130,10 @@ public class TaskManager {
tasks.add(t);
boolean poke = true;
while (threads.size() < maxThreads && needThread()) {
- TaskThread thread;
+ Thread th;
try {
- thread = new TaskThread();
- thread.start();
+ th = new TaskThread();
+ th.start();
} catch (Throwable tt) {
try {
logger.log(threads.isEmpty() ?
@@ -143,7 +143,7 @@ public class TaskManager {
}
break;
}
- threads.add(thread);
+ threads.add(th);
poke = false;
}
if (poke &&
@@ -228,11 +228,10 @@ public class TaskManager {
if (i < firstPending) {
firstPending--;
for (int j = threads.size(); --j >= 0; ) {
- TaskThread thread = threads.get(j);
- if (thread.getTask() == t) {
- if ( !thread.isCurrentThread()) {
- thread.interrupt();
- }
+ TaskThread thread = (TaskThread)threads.get(j);
+ if (thread.task == t) {
+ if (thread != Thread.currentThread())
+ thread.interrupt();
break;
}
}
@@ -250,7 +249,7 @@ public class TaskManager {
public synchronized void terminate() {
terminated = true;
for (int i = threads.size(); --i >= 0; ) {
- (threads.get(i)).interrupt();
+ ((Thread)threads.get(i)).interrupt();
}
}
@@ -268,29 +267,15 @@ public class TaskManager {
return maxThreads;
}
- private class TaskThread implements Runnable {
+ private class TaskThread extends Thread {
/** The task being run, if any */
- private Task task;
- private final Thread thread;
+ public Task task = null;
public TaskThread() {
- task = null;
- thread = new Thread(this, "task");
- thread.setDaemon(true);
- }
-
- public void start(){
- thread.start();
- }
-
- public boolean isCurrentThread() {
- return ( Thread.currentThread() == thread);
- }
-
- public void interrupt() {
- thread.interrupt();
- }
+ super("task");
+ setDaemon(true);
+ }
/**
* Find the next task that can be run, and mark it taken by
@@ -308,7 +293,7 @@ public class TaskManager {
tasks.add(firstPending, t);
}
firstPending++;
- setTask(t);
+ task = t;
return true;
}
}
@@ -320,16 +305,16 @@ public class TaskManager {
synchronized (TaskManager.this) {
if (terminated)
return;
- if (getTask() != null) {
+ if (task != null) {
for (int i = firstPending; --i >= 0; ) {
- if (tasks.get(i) == getTask()) {
+ if (tasks.get(i) == task) {
tasks.remove(i);
firstPending--;
break;
}
}
- setTask(null);
- thread.interrupted(); // clear interrupt bit
+ task = null;
+ interrupted(); // clear interrupt bit
}
if (!takeTask()) {
try {
@@ -343,7 +328,7 @@ public class TaskManager {
}
}
try {
- getTask().run();
+ task.run();
} catch (Throwable t) {
try {
logger.log(Level.WARNING, "Task.run exception", t);
@@ -352,13 +337,5 @@ public class TaskManager {
}
}
}
-
- public Task getTask() {
- return task;
- }
-
- public void setTask(Task task) {
- this.task = task;
- }
}
}
Modified: incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/core/discovery/LookupLocator.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/core/discovery/LookupLocator.java?rev=997556&r1=997555&r2=997556&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/core/discovery/LookupLocator.java (original)
+++ incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/core/discovery/LookupLocator.java Thu Sep 16 01:36:08 2010
@@ -29,16 +29,11 @@ import java.net.SocketException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
+import java.rmi.MarshalledObject;
import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.net.SocketFactory;
-import net.jini.core.lookup.PortableServiceRegistrar;
import net.jini.core.lookup.ServiceRegistrar;
-import net.jini.core.lookup.StreamServiceRegistrar;
-import net.jini.lookup.ServiceRegistrarFacade;
-import net.jini.lookup.StreamServiceRegistrarFacade;
-import net.jini.io.MarshalledInstance;
-import net.jini.io.MoToMiInputStream;
/**
* A utility class that performs unicast discovery, using version 1 of the
@@ -47,7 +42,6 @@ import net.jini.io.MoToMiInputStream;
* @author Sun Microsystems, Inc.
*
* @since 1.0
- * @see{net.jini.discovery.LookupLocatorDiscovery}
*/
public class LookupLocator implements Serializable {
private static final long serialVersionUID = 1448769379829432795L;
@@ -313,7 +307,6 @@ public class LookupLocator implements Se
return port;
}
-
/**
* Perform unicast discovery and return the ServiceRegistrar
* object for the given lookup service. Unicast discovery is
@@ -330,38 +323,13 @@ public class LookupLocator implements Se
* @throws IOException an error occurred during discovery
* @throws ClassNotFoundException if a class required to unmarshal the
* <code>ServiceRegistrar</code> proxy cannot be found
- * @deprecated replaced by {@link #reveal()}
*/
- @Deprecated
public ServiceRegistrar getRegistrar()
throws IOException, ClassNotFoundException
{
return getRegistrar(defaultTimeout);
}
-
- /**
- * Perform unicast discovery and return the PortableServiceRegistrar
- * object for the given lookup service. Unicast discovery is
- * performed anew each time this method is called.
- * <code>LookupLocator</code> implements this method to simply invoke
- * {@link #getRegistrar(int)} with a timeout value, which is determined
- * by the value of the <code>net.jini.discovery.timeout</code> system
- * property. If the property is set, is not negative, and can be parsed as
- * an <code>Integer</code>, the value of the property is used as the timeout
- * value. Otherwise, a default value of <code>60</code> seconds is assumed.
- *
- * @return the PortableServiceRegistrar for the lookup service denoted by
- * this LookupLocator object
- * @throws IOException an error occurred during discovery
- * @throws ClassNotFoundException if a class required to unmarshal the
- * <code>ServiceRegistrar</code> proxy cannot be found
- */
- public StreamServiceRegistrar getStreamRegistrar()
- throws IOException, ClassNotFoundException
- {
- return getStreamRegistrar(defaultTimeout);
- }
-
+
/**
* Perform unicast discovery and return the ServiceRegistrar
* object for the given lookup service, with the given discovery timeout.
@@ -383,82 +351,8 @@ public class LookupLocator implements Se
* @throws ClassNotFoundException if a class required to unmarshal the
* <code>ServiceRegistrar</code> proxy cannot be found
* @throws IllegalArgumentException if <code>timeout</code> is negative
- * @deprecated replaced by {@link #reveal(int)}
*/
- @Deprecated
public ServiceRegistrar getRegistrar(int timeout)
- throws IOException, ClassNotFoundException
- {
- PortableServiceRegistrar psr = getPortableRegistrar(timeout);
- if ( psr instanceof ServiceRegistrar) {
- return (ServiceRegistrar) psr;
- }
- return new ServiceRegistrarFacade(psr);
- }
-
- /**
- * Perform unicast discovery and return the StreamServiceRegistrar
- * object for the given lookup service, with the given discovery timeout.
- * 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.
- *
- * The Java CDC platform can only recieve implementations of
- * PortableServiceRegistrar or StreamServiceRegistrar, however this
- * method will return a ServiceRegistrar, wrapped as
- * a StreamServiceRegistrar, the notify method will be converted on
- * platforms that support java.rmi.MarshalledObject and will throw
- * an UnsupportedMethodException on those that don't.
- *
- * <p>
- * If a connection can be established to start unicast discovery
- * but the remote end fails to respond within the given time
- * limit, an exception is thrown.
- *
- * @param timeout the maximum time to wait for a response, in
- * milliseconds. A value of <code>0</code> specifies an infinite timeout.
- * @return the StreamServiceRegistrar for the lookup service denoted by
- * this LookupLocator object
- * @throws IOException an error occurred during discovery
- * @throws ClassNotFoundException if a class required to unmarshal the
- * <code>ServiceRegistrar</code> proxy cannot be found
- * @throws IllegalArgumentException if <code>timeout</code> is negative
- */
- public StreamServiceRegistrar getStreamRegistrar(int timeout)
- throws IOException, ClassNotFoundException
- {
- PortableServiceRegistrar psr = getPortableRegistrar(timeout);
- if ( psr instanceof StreamServiceRegistrar){
- return (StreamServiceRegistrar) psr;
- }
- return new StreamServiceRegistrarFacade(psr);
- }
-
- /**
- * Perform unicast discovery and return the PortableServiceRegistrar
- * object for the given lookup service, with the given discovery timeout.
- * 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.
- *
- * <p>
- * If a connection can be established to start unicast discovery
- * but the remote end fails to respond within the given time
- * limit, an exception is thrown.
- *
- * @param timeout the maximum time to wait for a response, in
- * milliseconds. A value of <code>0</code> specifies an infinite timeout.
- * @param true if a ServiceRegistrar instance is to be returned.
- * @return the ServiceRegistrar for the lookup service denoted by
- * this LookupLocator object
- * @throws IOException an error occurred during discovery
- * @throws ClassNotFoundException if a class required to unmarshal the
- * <code>PortableServiceRegistrar</code> proxy cannot be found
- * @throws IllegalArgumentException if <code>timeout</code> is negative
- */
- private PortableServiceRegistrar getPortableRegistrar(int timeout)
throws IOException, ClassNotFoundException
{
InetAddress[] addrs = null;
@@ -473,9 +367,7 @@ public class LookupLocator implements Se
} else {
sock = sf.createSocket(host, port);
}
- PortableServiceRegistrar psr =
- getRegistrarFromSocket(sock, timeout);
- return psr;
+ return getRegistrarFromSocket(sock, timeout);
}
IOException ioEx = null;
SecurityException secEx = null;
@@ -488,9 +380,7 @@ public class LookupLocator implements Se
} else {
sock = sf.createSocket(addrs[i], port);
}
- PortableServiceRegistrar psr =
- getRegistrarFromSocket(sock, timeout);
- return psr;
+ return getRegistrarFromSocket(sock, timeout);
} catch (ClassNotFoundException ex) {
cnfEx = ex;
} catch (IOException ex) {
@@ -512,7 +402,7 @@ public class LookupLocator implements Se
}
// Convenience method to do unicast discovery on a socket
- private static PortableServiceRegistrar getRegistrarFromSocket(Socket sock,
+ private static ServiceRegistrar getRegistrarFromSocket(Socket sock,
int timeout)
throws IOException, ClassNotFoundException
{
@@ -532,12 +422,10 @@ public class LookupLocator implements Se
new DataOutputStream(sock.getOutputStream());
dstr.writeInt(protoVersion);
dstr.flush();
- // Convert any MarshalledObject into MarshalledInstance.
ObjectInputStream istr =
- new MoToMiInputStream(sock.getInputStream());
- // Reminder, should we check codebase integrity or make it an option?
- PortableServiceRegistrar registrar =
- (PortableServiceRegistrar)((MarshalledInstance)istr.readObject()).get(false);
+ new ObjectInputStream(sock.getInputStream());
+ ServiceRegistrar registrar =
+ (ServiceRegistrar)((MarshalledObject)istr.readObject()).get();
for (int grpCount = istr.readInt(); --grpCount >= 0; ) {
istr.readUTF(); // ensure proper format, then discard
}
Modified: incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/ConstrainableLookupLocator.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/ConstrainableLookupLocator.java?rev=997556&r1=997555&r2=997556&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/ConstrainableLookupLocator.java (original)
+++ incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/ConstrainableLookupLocator.java Thu Sep 16 01:36:08 2010
@@ -18,8 +18,6 @@
package net.jini.discovery;
-import net.jini.lookup.StreamServiceRegistrarFacade;
-import net.jini.lookup.ServiceRegistrarFacade;
import com.sun.jini.discovery.Discovery;
import com.sun.jini.discovery.DiscoveryConstraints;
import com.sun.jini.discovery.UnicastResponse;
@@ -35,17 +33,15 @@ import net.jini.core.constraint.Invocati
import net.jini.core.constraint.MethodConstraints;
import net.jini.core.constraint.RemoteMethodControl;
import net.jini.core.discovery.LookupLocator;
-import net.jini.core.lookup.PortableServiceRegistrar;
import net.jini.core.lookup.ServiceRegistrar;
-import net.jini.core.lookup.StreamServiceRegistrar;
/**
* <code>LookupLocator</code> subclass which supports constraint operations
* through the {@link RemoteMethodControl} interface. The constraints of a
* <code>ConstrainableLookupLocator</code> instance control how it performs
- * unicast discovery, and apply only to its {@link LookupLocator#getPRegistrar()
- * getPRegistrar()} and {@link LookupLocator#getPRegistrar(int)
- * getPRegistrar(int)} methods. The constraints may also be used by other
+ * unicast discovery, and apply only to its {@link LookupLocator#getRegistrar()
+ * getRegistrar()} and {@link LookupLocator#getRegistrar(int)
+ * getRegistrar(int)} methods. The constraints may also be used by other
* utilities, such as {@link LookupLocatorDiscovery}, to determine how unicast
* discovery should be performed on behalf of a given
* <code>ConstrainableLookupLocator</code> instance. Untrusted
@@ -92,7 +88,7 @@ import net.jini.core.lookup.StreamServic
* used) perform unicast discovery to the host <code>target_host</code> on port
* 4160 using discovery protocol version 2, with a socket read timeout of
* 120000 milliseconds unless one was explicitly specified using the {@link
- * #getPRegistrar(int)} method.
+ * #getRegistrar(int)} method.
*/
public final class ConstrainableLookupLocator
extends LookupLocator implements RemoteMethodControl
@@ -101,9 +97,7 @@ public final class ConstrainableLookupLo
private static final int DEFAULT_TIMEOUT = 60 * 1000;
private static final Method getRegistrarMethod;
- private static final Method getStreamRegistrarMethod;
private static final Method getRegistrarTimeoutMethod;
- private static final Method getStreamRegistrarTimeoutMethod;
static {
try {
// REMIND: lookup methods on ConstrainableLookupLocator instead?
@@ -111,10 +105,6 @@ public final class ConstrainableLookupLo
"getRegistrar", new Class[0]);
getRegistrarTimeoutMethod = LookupLocator.class.getMethod(
"getRegistrar", new Class[]{ int.class });
- getStreamRegistrarMethod = LookupLocator.class.getMethod(
- "getStreamRegistrar", new Class[0]);
- getStreamRegistrarTimeoutMethod = LookupLocator.class.getMethod(
- "getStreamRegistrar", new Class[]{ int.class });
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
}
@@ -137,7 +127,7 @@ public final class ConstrainableLookupLo
* The <code>url</code> must be a valid URL of scheme <code>"jini"</code> as
* described in <code>LookupLocator(String)</code>. A <code>null
* constraints</code> value is interpreted as mapping both
- * <code>getPRegistrar</code> methods to empty constraints.
+ * <code>getRegistrar</code> methods to empty constraints.
*
* @param url the URL to use
* @param constraints the constraints to apply to unicast discovery, or
@@ -162,7 +152,7 @@ public final class ConstrainableLookupLo
* rethrown.
*
* <p>A <code>null constraints</code> value is interpreted as mapping both
- * <code>getPRegistrar</code> methods to empty constraints. The
+ * <code>getRegistrar</code> methods to empty constraints. The
* <code>host</code> and <code>port</code> must satisfy the requirements of
* the <code>LookupLocator(String, int)</code> constructor.
*
@@ -184,10 +174,10 @@ public final class ConstrainableLookupLo
/**
* Performs unicast discovery as specified by
- * <code>LookupLocator.getPRegistrar()</code> with the following differences.
+ * <code>LookupLocator.getRegistrar()</code> with the following differences.
* <ul>
* <li> It applies the supplied constraints (if any) for this method.
- * <li> It does not invoke the <code>getPRegistrar(int)</code> method.
+ * <li> It does not invoke the <code>getRegistrar(int)</code> method.
* <li> If no timeout constraints are specified, this method assumes a
* default timeout of 60 seconds. A non default timeout can only be
* specified through the supplied constraints, the
@@ -199,69 +189,25 @@ public final class ConstrainableLookupLo
* @throws net.jini.io.UnsupportedConstraintException if the
* discovery-related constraints contain conflicts, or otherwise cannot be
* processed
- * @deprecated replaced by {@link #getStreamRegistrar()}
*/
- @Deprecated
- @Override
public ServiceRegistrar getRegistrar()
throws IOException, ClassNotFoundException
{
- PortableServiceRegistrar psr = getRegistrar((constraints != null) ?
+ return getRegistrar((constraints != null) ?
constraints.getConstraints(getRegistrarMethod) :
InvocationConstraints.EMPTY);
- if ( psr instanceof ServiceRegistrar){
- return (ServiceRegistrar) psr;
- }
- return new ServiceRegistrarFacade(psr);
}
-
- /**
- * Performs unicast discovery as specified by
- * <code>LookupLocator.getStreeamRegistrar()</code> with the following differences.
- * <ul>
- * <li> It applies the supplied constraints (if any) for this method.
- * <li> It does not invoke the <code>getPRegistrar(int)</code> method.
- * <li> If no timeout constraints are specified, this method assumes a
- * default timeout of 60 seconds. A non default timeout can only be
- * specified through the supplied constraints, the
- * <code>net.jini.discovery.timeout</code> system property is ignored.
- * </ul>
- * <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.
- * @throws java.io.IOException
- * @throws java.lang.ClassNotFoundException
- * @throws net.jini.io.UnsupportedConstraintException if the
- * discovery-related constraints contain conflicts, or otherwise cannot be
- * processed
- * @since 2.2.0
- */
- @Override
- public StreamServiceRegistrar getStreamRegistrar()
- throws IOException, ClassNotFoundException
- {
- PortableServiceRegistrar psr = getRegistrar((constraints != null) ?
- constraints.getConstraints(getStreamRegistrarMethod) :
- InvocationConstraints.EMPTY);
- if ( psr instanceof StreamServiceRegistrar){
- return (StreamServiceRegistrar) psr;
- }
- return new StreamServiceRegistrarFacade(psr);
- }
-
+
/**
* Performs unicast discovery as specified by
- * <code>LookupLocator.getPRegistrar(int)</code>, additionally applying the
+ * <code>LookupLocator.getRegistrar(int)</code>, additionally applying the
* supplied discovery constraints. The <code>timeout</code> is considered a
* requirement with respect to other constraints specified for this
* instance.
* @throws net.jini.io.UnsupportedConstraintException if the
* discovery-related constraints contain conflicts, or otherwise cannot be
* processed
- * @deprecated replaced by {@link #getStreamRegistrar(int)}
*/
- @Deprecated
- @Override
public ServiceRegistrar getRegistrar(int timeout)
throws IOException, ClassNotFoundException
{
@@ -270,42 +216,7 @@ public final class ConstrainableLookupLo
InvocationConstraints.EMPTY;
Collection reqs = new ArrayList(ic.requirements());
reqs.add(new UnicastSocketTimeout(timeout));
- PortableServiceRegistrar psr =
- getRegistrar(new InvocationConstraints(reqs, ic.preferences()));
- if ( psr instanceof ServiceRegistrar){
- return (ServiceRegistrar) psr;
- }
- return new ServiceRegistrarFacade(psr);
- }
-
- /**
- * Performs unicast discovery as specified by
- * <code>LookupLocator.getStreamRegistrar(int)</code>, additionally applying the
- * supplied discovery constraints. The <code>timeout</code> is considered a
- * requirement with respect to other constraints specified for this
- * instance.
- * @throws java.io.IOException
- * @throws java.lang.ClassNotFoundException
- * @throws net.jini.io.UnsupportedConstraintException if the
- * discovery-related constraints contain conflicts, or otherwise cannot be
- * processed
- * @since 2.2.0
- */
- @Override
- public StreamServiceRegistrar getStreamRegistrar(int timeout)
- throws IOException, ClassNotFoundException
- {
- InvocationConstraints ic = (constraints != null) ?
- constraints.getConstraints(getStreamRegistrarTimeoutMethod) :
- InvocationConstraints.EMPTY;
- Collection reqs = new ArrayList(ic.requirements());
- reqs.add(new UnicastSocketTimeout(timeout));
- PortableServiceRegistrar psr =
- getRegistrar(new InvocationConstraints(reqs, ic.preferences()));
- if ( psr instanceof StreamServiceRegistrar){
- return (StreamServiceRegistrar) psr;
- }
- return new StreamServiceRegistrarFacade(psr);
+ return getRegistrar(new InvocationConstraints(reqs, ic.preferences()));
}
/**
@@ -327,7 +238,7 @@ public final class ConstrainableLookupLo
return constraints;
}
- private PortableServiceRegistrar getRegistrar(InvocationConstraints constraints)
+ private ServiceRegistrar getRegistrar(InvocationConstraints constraints)
throws IOException, ClassNotFoundException
{
UnicastResponse resp = new MultiIPDiscovery() {
@@ -340,6 +251,6 @@ public final class ConstrainableLookupLo
s, dc.getUnfulfilledConstraints(), null, null, null);
}
}.getResponse(host, port, constraints);
- return resp.getPRegistrar();
+ return resp.getRegistrar();
}
}
\ No newline at end of file
Modified: incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/DiscoveryEvent.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/DiscoveryEvent.java?rev=997556&r1=997555&r2=997556&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/DiscoveryEvent.java (original)
+++ incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/DiscoveryEvent.java Thu Sep 16 01:36:08 2010
@@ -17,14 +17,9 @@
*/
package net.jini.discovery;
-import net.jini.lookup.StreamServiceRegistrarFacade;
-import net.jini.lookup.ServiceRegistrarFacade;
-import java.util.ArrayList;
import java.util.EventObject;
import java.util.Map;
-import net.jini.core.lookup.PortableServiceRegistrar;
import net.jini.core.lookup.ServiceRegistrar;
-import net.jini.core.lookup.StreamServiceRegistrar;
/**
* Event object passed (via either the <code>DiscoveryListener</code>
@@ -49,7 +44,7 @@ public class DiscoveryEvent extends Even
*
* @serial
*/
- private PortableServiceRegistrar[] regs;
+ protected ServiceRegistrar[] regs;
/**
* Map from the registrars of this event to the groups in which each
@@ -57,34 +52,17 @@ public class DiscoveryEvent extends Even
*
* @serial
*/
- private Map groups;
+ protected Map groups;
/**
* Construct a new <code>DiscoveryEvent</code> object, with the given
* source and set of registrars. The set of registrars should not be
- * empty. This constructor has been left in place to maintain binary
- * compatibility.
- *
- * @param source the source of this event
- * @param regs the registrars to which this event applies
- * @deprecated
- */
- @Deprecated
- public DiscoveryEvent(Object source, ServiceRegistrar[] regs) {
- super(source);
- this.regs = regs;
- this.groups = null;
- }
-
- /**
- * Construct a new <code>DiscoveryEvent</code> object, with the given
- * source and set of registrars. The set of registrars should not be
* empty.
*
* @param source the source of this event
* @param regs the registrars to which this event applies
*/
- public DiscoveryEvent(Object source, PortableServiceRegistrar[] regs) {
+ public DiscoveryEvent(Object source, ServiceRegistrar[] regs) {
super(source);
this.regs = regs;
this.groups = null;
@@ -103,46 +81,19 @@ public class DiscoveryEvent extends Even
public DiscoveryEvent(Object source, Map groups) {
super(source);
this.groups = groups;
- this.regs = (PortableServiceRegistrar[])(groups.keySet()).toArray
- (new PortableServiceRegistrar[groups.size()]);
+ this.regs = (ServiceRegistrar[])(groups.keySet()).toArray
+ (new ServiceRegistrar[groups.size()]);
}
/**
* Return the set of registrars to which this event applies.
* The same array is returned on every call; a copy is not made.
- *
- * I'm going to experiment with returning a copy to see if anything
- * breaks.
- *
* @return the set of registrars to which this event applies.
*/
public ServiceRegistrar[] getRegistrars() {
- int l = regs.length;
- ArrayList<ServiceRegistrar> sr = new ArrayList<ServiceRegistrar>(l);
- for ( int i = 0; i < l; i++ ){
- if (regs[i] instanceof ServiceRegistrar) {
- sr.add( (ServiceRegistrar) regs[i]);
- } else {
- sr.add( new ServiceRegistrarFacade(regs[i]));
- }
- }
- ServiceRegistrar[] sra = new ServiceRegistrar[sr.size()];
- return sr.toArray(sra);
- }
-
- /**
- * Return the set of registrars to which this event applies.
- * The same array is returned on every call; a copy is not made.
- *
- * I'm going to experiment with returning a copy to see if anything
- * breaks.
- *
- * @return the set of registrars to which this event applies.
- */
- public PortableServiceRegistrar[] getPRegistrars() {
- return regs;
+ return regs;
}
-
+
/**
* Returns a set that maps to each registrar referenced by this event,
* the current set of groups in which each registrar is a member.
Modified: incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/IncomingUnicastResponse.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/IncomingUnicastResponse.java?rev=997556&r1=997555&r2=997556&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/IncomingUnicastResponse.java (original)
+++ incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/IncomingUnicastResponse.java Thu Sep 16 01:36:08 2010
@@ -17,15 +17,11 @@
*/
package net.jini.discovery;
-import net.jini.lookup.ServiceRegistrarFacade;
import java.io.InputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
-import net.jini.core.lookup.PortableServiceRegistrar;
+import java.rmi.MarshalledObject;
import net.jini.core.lookup.ServiceRegistrar;
-import net.jini.core.lookup.StreamServiceRegistrar;
-import net.jini.io.MarshalledInstance;
-import net.jini.io.MoToMiInputStream;
/**
* This class encapsulates the details of unmarshaling an incoming
@@ -38,23 +34,17 @@ import net.jini.io.MoToMiInputStream;
public class IncomingUnicastResponse {
/**
* The registrar we have discovered.
- * Changed from protected to private in 2.2.0
*/
- private PortableServiceRegistrar registrar;
+ protected ServiceRegistrar registrar;
/**
* The groups the lookup service was a member of, at the time
* discovery was performed. This may be out of date.
- * Changed from protected to private in 2.2.0
*/
- private String[] groups;
+ protected String[] groups;
/**
* Construct a new object, initialized by unmarshaling the
* contents of an input stream.
- *
- * This class remains backward compatible with earlier releases of Jini
- * since 2.0, however it will be eventually dropped and only support
- * versions 2.2.0 and later.
*
* @param str the stream from which to unmarshal the response
* @exception IOException an error occurred while unmarshaling the
@@ -65,11 +55,9 @@ public class IncomingUnicastResponse {
public IncomingUnicastResponse(InputStream str)
throws IOException, ClassNotFoundException
{
- ObjectInputStream istr = new MoToMiInputStream(str);
- // need to look at configurable option for verify codebase integrity.
- boolean verifyCodebaseIntegrity = false;
+ ObjectInputStream istr = new ObjectInputStream(str);
registrar =
- (PortableServiceRegistrar)((MarshalledInstance)istr.readObject()).get(verifyCodebaseIntegrity);
+ (ServiceRegistrar)((MarshalledObject)istr.readObject()).get();
int grpCount = istr.readInt();
groups = new String[grpCount];
for (int i = 0; i < groups.length; i++) {
@@ -79,28 +67,11 @@ public class IncomingUnicastResponse {
/**
* Return the lookup service registrar we have discovered.
- * This method won't be available on Java CDC.
*
* @return the lookup service registrar we have discovered
- * @deprecated replaced by {@link #getPRegistrar()}
*/
- @Deprecated
public ServiceRegistrar getRegistrar() {
- if (registrar instanceof ServiceRegistrar ) return (ServiceRegistrar) registrar;
- return new ServiceRegistrarFacade(registrar);
- }
-
- /**
- * Return the lookup portable service registrar we have discovered.
- *
- * For maximum platform compatbility don't downcast,
- * use PortableServiceRegistrar where possible.
- *
- * @return the lookup service registrar we have discovered
- * @since 2.2.0
- */
- public PortableServiceRegistrar getPRegistrar () {
- return registrar;
+ return registrar;
}
/**
Modified: incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/LookupUnmarshalException.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/LookupUnmarshalException.java?rev=997556&r1=997555&r2=997556&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/LookupUnmarshalException.java (original)
+++ incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/discovery/LookupUnmarshalException.java Thu Sep 16 01:36:08 2010
@@ -18,22 +18,12 @@
package net.jini.discovery;
-import net.jini.lookup.StreamServiceRegistrarFacade;
-import net.jini.lookup.ServiceRegistrarFacade;
import net.jini.core.lookup.ServiceRegistrar;
-import net.jini.core.lookup.PortableServiceRegistrar;
import java.io.InvalidObjectException;
import java.io.IOException;
import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.rmi.MarshalledObject;
-import java.util.ArrayList;
-import java.util.Arrays;
-import net.jini.io.Convert;
-import net.jini.io.MarshalledInstance;
-import net.jini.io.MiToMoOutputStream;
-import net.jini.io.MoToMiInputStream;
/**
* When unmarshalling an instance of <code>MarshalledObject</code>, different
@@ -49,22 +39,22 @@ import net.jini.io.MoToMiInputStream;
* This class provides a mechanism that clients of the lookup discovery
* service may use for efficient handling of the exceptions that may
* occur when unmarshalling elements of a set of marshalled instances
- * of the <code>PortableServiceRegistrar</code> interface. When elements in such
+ * of the <code>ServiceRegistrar</code> interface. When elements in such
* a set are unmarshalled, the <code>LookupUnmarshalException</code> class
* may be used to collect and report pertinent information generated when
* failure occurs while unmarshalling the elements of the set.
* <p>
* The information that may be of interest to entities that receive this
* exception class is contained in the following fields: a set of
- * <code>PortableServiceRegistrar</code> instances in which each element is the
+ * <code>ServiceRegistrar</code> instances in which each element is the
* result of a successful unmarshalling attempt, a set of marshalled instances
- * of <code>PortableServiceRegistrar</code> in which each element could not be
+ * of <code>ServiceRegistrar</code> in which each element could not be
* successfully unmarshalled, and a set of exceptions (<code>IOException<code>,
* <code>ClassNotFoundException</code>, or some unchecked exception) in which
* each element corresponds to one of the unmarshalling failures.
* <p>
* Thus, when exceptional conditions occur while unmarshalling a set of
- * marshalled instances of <code>PortableServiceRegistrar</code>, this class can
+ * marshalled instances of <code>ServiceRegistrar</code>, this class can
* be used not only to indicate that an exceptional condition has occurred,
* but also to provide information that can be used to perform error handling
* activities such as: determining if it is feasible to continue with
@@ -72,12 +62,11 @@ import net.jini.io.MoToMiInputStream;
* <p>
* Note that this exception class should be used only to report exceptional
* conditions occurring when unmarshalling a set of marshalled instances
- * of the <code>PortableServiceRegistrar</code> interface.
+ * of the <code>ServiceRegistrar</code> interface.
*
* @author Sun Microsystems, Inc.
*
* @see net.jini.core.lookup.ServiceRegistrar
- * @see net.jini.core.lookup.PortableServiceRegistrar
*/
public class LookupUnmarshalException extends Exception {
@@ -91,16 +80,16 @@ public class LookupUnmarshalException ex
*
* @serial
*/
- private PortableServiceRegistrar[] registrars = null;
+ private ServiceRegistrar[] registrars = null;
/**
- * Array containing the set of <code>PortableServiceRegistrar</code> instances
+ * Array containing the set of <code>ServiceRegistrar</code> instances
* that could not be unmarshalled. This set should not be <code>null</code>
* and should contain at least one element.
*
* @serial
*/
- private MarshalledInstance[] marshalledRegistrars = null;
+ private MarshalledObject[] marshalledRegistrars = null;
/**
* Array containing the set of exceptions that occurred during the
@@ -108,7 +97,7 @@ public class LookupUnmarshalException ex
* of <code>IOException</code>, <code>ClassNotFoundException</code>, or
* some unchecked exception. Furthermore, there should be a one-to-one
* correspondence between each element in this set and each element in
- * the set of still-to-be-unmarshalled <code>PortableServiceRegistrar</code>
+ * the set of still-to-be-unmarshalled <code>ServiceRegistrar</code>
* instances. That is, the element of this set corresponding to index i
* should be an instance of the exception that occurred while attempting
* to unmarshal the element at index i of <code>marshalledRegistrars<code>.
@@ -123,11 +112,11 @@ public class LookupUnmarshalException ex
* Constructs a new instance of <code>LookupUnmarshalException</code>.
*
* @param registrars Array containing the set of instances of
- * <code>PortableServiceRegistrar</code> that were
+ * <code>ServiceRegistrar</code> that were
* successfully unmarshalled.
*
* @param marshalledRegistrars Array containing the set of marshalled
- * <code>PortableServiceRegistrar</code> instances
+ * <code>ServiceRegistrar</code> instances
* that could not be unmarshalled.
*
* @param exceptions Array containing the set of exceptions that
@@ -156,27 +145,24 @@ public class LookupUnmarshalException ex
* either the <code>marshalledRegistrars</code> parameter or the
* <code>exceptions</code> parameter has zero length; or when the
* lengths of those two parameters are not equal.
- * @deprecated
*/
- @Deprecated
- public LookupUnmarshalException(PortableServiceRegistrar[] registrars,
+ public LookupUnmarshalException(ServiceRegistrar[] registrars,
MarshalledObject[] marshalledRegistrars,
Throwable[] exceptions)
{
super();
- MarshalledInstance[] jmo = asMarshalledInstance(marshalledRegistrars);
- init(registrars,jmo,exceptions);
+ init(registrars,marshalledRegistrars,exceptions);
}//end constructor
/**
* Constructs a new instance of <code>LookupUnmarshalException</code>.
*
* @param registrars Array containing the set of instances of
- * <code>PortableServiceRegistrar</code> that were
+ * <code>ServiceRegistrar</code> that were
* successfully unmarshalled.
*
* @param marshalledRegistrars Array containing the set of marshalled
- * <code>PortableServiceRegistrar</code> instances
+ * <code>ServiceRegistrar</code> instances
* that could not be unmarshalled.
*
* @param exceptions Array containing the set of exceptions that
@@ -208,116 +194,17 @@ public class LookupUnmarshalException ex
* either the <code>marshalledRegistrars</code> parameter or the
* <code>exceptions</code> parameter has zero length; or when the
* lengths of those two parameters are not equal.
- * @deprecated
*/
- @Deprecated
- public LookupUnmarshalException(PortableServiceRegistrar[] registrars,
+ public LookupUnmarshalException(ServiceRegistrar[] registrars,
MarshalledObject[] marshalledRegistrars,
Throwable[] exceptions,
String message)
{
super(message);
- MarshalledInstance[] mi = asMarshalledInstance(marshalledRegistrars);
- init(registrars,mi,exceptions);
- }//end constructor
-
- /**
- * Constructs a new instance of <code>LookupUnmarshalException</code>.
- *
- * @param registrars Array containing the set of instances of
- * <code>PortableServiceRegistrar</code> that were
- * successfully unmarshalled.
- *
- * @param marshalledRegistrars Array containing the set of marshalled
- * <code>PortableServiceRegistrar</code> instances
- * that could not be unmarshalled.
- *
- * @param exceptions Array containing the set of exceptions that
- * occurred during the unmarshalling process.
- * Each element in this set should be an
- * instance of <code>IOException</code>,
- * <code>ClassNotFoundException</code>, or
- * some unchecked exception. Furthermore,
- * there should be a one-to-one correspondence
- * between each element in this set and
- * each element in the
- * <code>marshalledRegistrars</code> parameter.
- * <p>
- * That is, the element of this set
- * corresponding to index i should be an
- * instance of the exception that occurred
- * while attempting to unmarshal the element
- * at index i of the
- * <code>marshalledRegistrars</code> parameter.
- *
- * @throws java.lang.NullPointerException this exception occurs
- * when <code>null</code> is input for either the
- * <code>marshalledRegistrars</code> parameter or the
- * <code>exceptions</code> parameter.
- * @throws java.lang.IllegalArgumentException this exception occurs when
- * either the <code>marshalledRegistrars</code> parameter or the
- * <code>exceptions</code> parameter has zero length; or when the
- * lengths of those two parameters are not equal.
- */
- public LookupUnmarshalException(PortableServiceRegistrar[] registrars,
- MarshalledInstance[] marshalledRegistrars,
- Throwable[] exceptions)
- {
- super();
init(registrars,marshalledRegistrars,exceptions);
}//end constructor
/**
- * Constructs a new instance of <code>LookupUnmarshalException</code>.
- *
- * @param registrars Array containing the set of instances of
- * <code>PortableServiceRegistrar</code> that were
- * successfully unmarshalled.
- *
- * @param marshalledRegistrars Array containing the set of marshalled
- * <code>PortableServiceRegistrar</code> instances
- * that could not be unmarshalled.
- *
- * @param exceptions Array containing the set of exceptions that
- * occurred during the unmarshalling process.
- * Each element in this set should be an
- * instance of <code>IOException</code>,
- * <code>ClassNotFoundException</code>, or
- * some unchecked exception. Furthermore,
- * there should be a one-to-one correspondence
- * between each element in this set and
- * each element in the
- * <code>marshalledRegistrars</code> parameter.
- * <p>
- * That is, the element of this set
- * corresponding to index i should be an
- * instance of the exception that occurred
- * while attempting to unmarshal the element
- * at index i of the
- * <code>marshalledRegistrars</code> parameter.
- *
- * @param message <code>String</code> describing the nature
- * of the exception
- *
- * @throws java.lang.NullPointerException this exception occurs
- * when <code>null</code> is input for either the
- * <code>marshalledRegistrars</code> parameter or the
- * <code>exceptions</code> parameter.
- * @throws java.lang.IllegalArgumentException this exception occurs when
- * either the <code>marshalledRegistrars</code> parameter or the
- * <code>exceptions</code> parameter has zero length; or when the
- * lengths of those two parameters are not equal.
- */
- public LookupUnmarshalException(PortableServiceRegistrar[] registrars,
- MarshalledInstance[] marshalledRegistrars,
- Throwable[] exceptions,
- String message)
- {
- super(message);
- init(registrars,marshalledRegistrars,exceptions);
- }//end constructor
-
- /**
* Accessor method that returns an array consisting of instances of
* <code>ServiceRegistrar</code>, where each element of the array
* corresponds to a successfully unmarshalled object. Note that the
@@ -328,77 +215,25 @@ public class LookupUnmarshalException ex
* each element corresponds to a successfully unmarshalled object.
*/
public ServiceRegistrar[] getRegistrars() {
- ArrayList<ServiceRegistrar> sr = new ArrayList<ServiceRegistrar>();
- int l = registrars.length;
- for ( int i = 0; i < l; i++){
- if (registrars[i] instanceof ServiceRegistrar) {
- sr.add((ServiceRegistrar) registrars[i]);
- }
- }
- ServiceRegistrar[] sra = new ServiceRegistrar[sr.size()];
- return sr.toArray(sra);
- }//end getRegistrars
-
- /**
- * Accessor method that returns an array consisting of instances of
- * <code>PortableServiceRegistrar</code>, where each element of the array
- * corresponds to a successfully unmarshalled object. Note that the
- * same array is returned on each invocation of this method; that is,
- * a copy is not made.
- *
- * @return array of instances of <code>PortableServiceRegistrar</code>, where
- * each element corresponds to a successfully unmarshalled object.
- */
- public PortableServiceRegistrar[] getPRegistrars() {
- // Defensive copy.
- return Arrays.copyOf(registrars, registrars.length);
+ return registrars;
}//end getRegistrars
/**
* Accessor method that returns an array consisting of instances of
* <code>MarshalledObject</code>, where each element of the array is a
- * marshalled instance of the <code>PortableServiceRegistrar</code> interface,
+ * marshalled instance of the <code>ServiceRegistrar</code> interface,
* and corresponds to an object that could not be successfully
* unmarshalled. Note that the same array is returned on each invocation
* of this method; that is, a copy is not made.
*
- * @return array of marshalled instances of <code>PortableServiceRegistrar</code>,
+ * @return array of marshalled instances of <code>ServiceRegistrar</code>,
* where each element corresponds to an object in which failure
* occurred while attempting to unmarshal the object.
*/
- @Deprecated
public MarshalledObject[] getMarshalledRegistrars() {
- return asMarshalledObject(marshalledRegistrars);
+ return marshalledRegistrars;
}//end getMarshalledRegistrars
-
- @Deprecated
- private MarshalledInstance[] asMarshalledInstance(MarshalledObject[] mo) {
- Convert convert = Convert.getInstance();
- int l = mo.length;
- MarshalledInstance[] mi = new MarshalledInstance[l];
- for (int i = 0; i < l; i++){
- mi[i] = convert.toMarshalledInstance(mo[i]);
- }
- return mi;
- }
-
- @Deprecated
- @SuppressWarnings("unchecked")
- private MarshalledObject[] asMarshalledObject(MarshalledInstance[] mi){
- Convert convert = Convert.getInstance();
- int l = mi.length;
- MarshalledObject[] rmiMo = new MarshalledObject[l];
- for (int i = 0; i < l; i++){
- rmiMo[i] = convert.toRmiMarshalledObject(mi[i]);
- }
- return rmiMo;
- }
-
- public MarshalledInstance[] getMarshalledInstRegistrars(){
- // Defensive copy.
- return Arrays.copyOf(marshalledRegistrars, marshalledRegistrars.length);
- }
-
+
/**
* Accessor method that returns an array consisting of instances of
* <code>Throwable</code>, where each element of the array corresponds
@@ -421,19 +256,18 @@ public class LookupUnmarshalException ex
* the unmarshalling process.
*/
public Throwable[] getExceptions() {
- // Defensive copy.
- return Arrays.copyOf(exceptions, exceptions.length);
+ return exceptions;
}//end getExceptions
/**
* Initializes the abstract state of this class.
*
* @param registrars Array containing the set of instances of
- * <code>PortableServiceRegistrar</code> that were
+ * <code>ServiceRegistrar</code> that were
* successfully unmarshalled.
*
* @param marshalledRegistrars Array containing the set of marshalled
- * <code>PortableServiceRegistrar</code> instances
+ * <code>ServiceRegistrar</code> instances
* that could not be unmarshalled.
*
* @param exceptions Array containing the set of exceptions that
@@ -448,8 +282,8 @@ public class LookupUnmarshalException ex
* <code>exceptions</code> parameter has zero length; or when the
* lengths of those two parameters are not equal.
*/
- private void init(PortableServiceRegistrar[] registrars,
- MarshalledInstance[] marshalledRegistrars,
+ private void init(ServiceRegistrar[] registrars,
+ MarshalledObject[] marshalledRegistrars,
Throwable[] exceptions) {
/* Verify the input arguments */
if(marshalledRegistrars == null) {
@@ -485,8 +319,7 @@ public class LookupUnmarshalException ex
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException
{
- ObjectInputStream fois = new MoToMiInputStream(s); // convert to java.rmi.MarshalledObject
- fois.defaultReadObject();
+ s.defaultReadObject();
/* Verify marshalledRegistrars and exceptions fields */
if(marshalledRegistrars == null) {
throw new InvalidObjectException
@@ -512,17 +345,5 @@ public class LookupUnmarshalException ex
}//endif
}//end readObject
-
- /**
- * This method is an interim temporary measure to provide a transition
- * period for the Serialized form in Apache River versions prior to
- * 2.2.0
- * @param stream
- * @throws java.io.IOException
- */
- private void writeObject(java.io.ObjectOutputStream stream) throws IOException{
- ObjectOutputStream newOutStream = new MiToMoOutputStream(stream); // Convert from java.rmi.MarshalledObject
- newOutStream.defaultWriteObject();
- }
}//end class LookupUnmarshalException
Modified: incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/io/MarshalledInstance.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/io/MarshalledInstance.java?rev=997556&r1=997555&r2=997556&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/io/MarshalledInstance.java (original)
+++ incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/io/MarshalledInstance.java Thu Sep 16 01:36:08 2010
@@ -24,6 +24,7 @@ import java.io.InputStream;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
import java.io.ObjectStreamException;
import java.io.OutputStream;
import java.io.Serializable;
@@ -68,7 +69,7 @@ import net.jini.io.context.IntegrityEnfo
* @author Sun Microsystems, Inc.
* @since 2.0
*/
-public class MarshalledInstance<T> implements Serializable {
+public class MarshalledInstance implements Serializable {
/**
* @serial Bytes of serialized representation. If <code>objBytes</code> is
@@ -93,14 +94,6 @@ public class MarshalledInstance<T> imple
static final long serialVersionUID = -5187033771082433496L;
- MarshalledInstance(net.jini.io.MarshalledObject<T> mo){
- if ( mo == null) throw new NullPointerException("MarshalledObject was null");
- // for some reason objBytes.clone() throws a null pointer exception.
- objBytes = Arrays.copyOf(mo.objBytes, mo.objBytes.length);
- locBytes = mo.locBytes;
- hash = mo.hash;
- }
-
/**
* Creates a new <code>MarshalledInstance</code> that contains the
* marshalled representation of the current state of the supplied
@@ -114,7 +107,7 @@ public class MarshalledInstance<T> imple
* <code>MarshalledInstance</code>
* @throws IOException if the object cannot be serialized
*/
- public MarshalledInstance(T obj) throws IOException {
+ public MarshalledInstance(Object obj) throws IOException {
this(obj, Collections.EMPTY_SET);
}
@@ -133,7 +126,7 @@ public class MarshalledInstance<T> imple
* @throws IOException if the object cannot be serialized
* @throws NullPointerException if <code>context</code> is <code>null</code>
*/
- public MarshalledInstance(T obj, Collection context)
+ public MarshalledInstance(Object obj, Collection context)
throws IOException
{
if (context == null)
@@ -183,10 +176,8 @@ public class MarshalledInstance<T> imple
* the object the new <code>MarshalledInstance</code> should
* contain
* @throws NullPointerException if <code>mo</code> is <code>null</code>
- * @deprecated As of Release 2.2.0 replaced by {@link Convert}
*/
- @Deprecated
- public MarshalledInstance(java.rmi.MarshalledObject<T> mo) {
+ public MarshalledInstance(java.rmi.MarshalledObject mo) {
if (mo == null)
throw new NullPointerException();
@@ -197,9 +188,22 @@ public class MarshalledInstance<T> imple
// version of MarshalledObject allows access to the needed
// fields.
//
- Convert<T> convert = new Convert<T>();
- net.jini.io.MarshalledObject<T> privateMO =
- convert.toJiniMarshalledObject(mo);
+ net.jini.io.MarshalledObject privateMO = null;
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(mo);
+ oos.flush();
+ byte[] bytes = baos.toByteArray();
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = new FromMOInputStream(bais);
+ privateMO =
+ (net.jini.io.MarshalledObject)ois.readObject();
+ } catch (IOException ioe) {
+ throw new AssertionError(ioe);
+ } catch (ClassNotFoundException cnfe) {
+ throw new AssertionError(cnfe);
+ }
objBytes = privateMO.objBytes;
locBytes = privateMO.locBytes;
hash = privateMO.hash;
@@ -212,27 +216,44 @@ public class MarshalledInstance<T> imple
* <p>
* The object contained in this <code>MarshalledInstance</code>
* object will not be unmarshalled as part of this call.
- * @deprecated As of Release 2.2.0 replaced by {@link Convert}
* @return A new <code>MarshalledObject</code> which
* contains an object equivalent to the object
* contained in this <code>MarshalledInstance</code>
*/
- @SuppressWarnings("unchecked")
- @Deprecated
- public java.rmi.MarshalledObject<T> convertToMarshalledObject() {
- Convert convert = Convert.getInstance();
- return convert.toRmiMarshalledObject(this);
- }
-
- MarshalledObject<T> asMarshalledObject(){
- MarshalledObject<T> mo = new MarshalledObject<T>();
- // Don't worry about defensive copies, this is package private.
- mo.objBytes = objBytes;
- mo.locBytes = locBytes;
- mo.hash = hash;
- return mo;
+ public java.rmi.MarshalledObject convertToMarshalledObject() {
+
+ // To create a java.rmi.MarshalledObject with previously
+ // serialized data we first create a private
+ // net.jini.io.MarshalledObject with the
+ // data and then convert it to the final object by changing
+ // the class during readObject(). (See resolveClass() in
+ // ToMOInputStream)
+ //
+ net.jini.io.MarshalledObject privateMO =
+ new net.jini.io.MarshalledObject();
+
+ privateMO.objBytes = objBytes;
+ privateMO.locBytes = locBytes;
+ privateMO.hash = hash;
+
+ java.rmi.MarshalledObject mo = null;
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(privateMO);
+ oos.flush();
+ byte[] bytes = baos.toByteArray();
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = new ToMOInputStream(bais);
+ mo = (java.rmi.MarshalledObject)ois.readObject();
+ } catch (IOException ioe) {
+ throw new AssertionError(ioe);
+ } catch (ClassNotFoundException cnfe) {
+ throw new AssertionError(cnfe);
+ }
+ return mo;
}
-
+
/**
* Returns a new copy of the contained object. Deserialization is
* performed with the semantics defined by <code>MarshalInputStream</code>.
@@ -260,7 +281,7 @@ public class MarshalledInstance<T> imple
* is <code>true</code> and the integrity of the
* contained object's codebase cannot be confirmed
*/
- public T get(final boolean verifyCodebaseIntegrity)
+ public Object get(final boolean verifyCodebaseIntegrity)
throws IOException, ClassNotFoundException
{
return get(null, verifyCodebaseIntegrity, null, null);
@@ -306,7 +327,7 @@ public class MarshalledInstance<T> imple
* is <code>true</code> and the integrity of the
* contained object's codebase cannot be confirmed
*/
- public T get(ClassLoader defaultLoader,
+ public Object get(ClassLoader defaultLoader,
final boolean verifyCodebaseIntegrity,
ClassLoader verifierLoader,
Collection context)
@@ -334,8 +355,7 @@ public class MarshalledInstance<T> imple
verifierLoader,
context);
in.useCodebaseAnnotations();
- @SuppressWarnings("unchecked")
- T obj = (T) in.readObject();
+ Object obj = in.readObject();
in.close();
return obj;
}
@@ -419,55 +439,166 @@ public class MarshalledInstance<T> imple
*/
private void readObjectNoData() throws ObjectStreamException {
throw new InvalidObjectException("Bad class hierarchy");
- }
-
- private static class MarshalledInstanceInputStream extends MarshalInputStream {
+ }
+
+ /**
+ * This class is used to marshal objects for
+ * <code>MarshalledInstance</code>. It places the location annotations
+ * to one side so that two <code>MarshalledInstance</code>s can be
+ * compared for equality if they differ only in location
+ * annotations. Objects written using this stream should be read back
+ * from a <code>MarshalledInstanceInputStream</code>.
+ *
+ * @see MarshalledInstanceInputStream
+ */
+ private static class MarshalledInstanceOutputStream
+ extends MarshalOutputStream
+ {
+ /** The stream on which location objects are written. */
+ private ObjectOutputStream locOut;
+
+ /** <code>true</code> if non-<code>null</code> annotations are
+ * written.
+ */
+ private boolean hadAnnotations;
+
+ /**
+ * Creates a new <code>MarshalledObjectOutputStream</code> whose
+ * non-location bytes will be written to <code>objOut</code> and whose
+ * location annotations (if any) will be written to
+ * <code>locOut</code>.
+ */
+ public MarshalledInstanceOutputStream(OutputStream objOut,
+ OutputStream locOut,
+ Collection context)
+ throws IOException
+ {
+ super(objOut, context);
+ this.locOut = new ObjectOutputStream(locOut);
+ hadAnnotations = false;
+ }
+
+ /**
+ * Returns <code>true</code> if any non-<code>null</code> location
+ * annotations have been written to this stream.
+ */
+ public boolean hadAnnotations() {
+ return hadAnnotations;
+ }
+
+ /**
+ * Overrides <code>MarshalOutputStream.writeAnnotation</code>
+ * implementation to write annotations to the location stream.
+ */
+ protected void writeAnnotation(String loc) throws IOException {
+ hadAnnotations |= (loc != null);
+ locOut.writeObject(loc);
+ }
- private ObjectInputStream locIn;
+ public void flush() throws IOException {
+ super.flush();
+ locOut.flush();
+ }
+ }
+
+ /**
+ * The counterpart to <code>MarshalledInstanceOutputStream</code>.
+ *
+ * @see MarshalledInstanceOutputStream
+ */
+ private static class MarshalledInstanceInputStream
+ extends MarshalInputStream
+ {
+ /**
+ * The stream from which annotations will be read. If this is
+ * <code>null</code>, then all annotations were <code>null</code>.
+ */
+ private ObjectInputStream locIn;
+
+ /**
+ * Creates a new <code>MarshalledObjectInputStream</code> that
+ * reads its objects from <code>objIn</code> and annotations
+ * from <code>locIn</code>. If <code>locIn</code> is
+ * <code>null</code>, then all annotations will be
+ * <code>null</code>.
+ */
+ MarshalledInstanceInputStream(InputStream objIn,
+ InputStream locIn,
+ ClassLoader defaultLoader,
+ boolean verifyCodebaseIntegrity,
+ ClassLoader verifierLoader,
+ Collection context)
+ throws IOException
+ {
+ super(objIn,
+ defaultLoader,
+ verifyCodebaseIntegrity,
+ verifierLoader,
+ context);
+ this.locIn = (locIn == null ? null : new ObjectInputStream(locIn));
+ }
+
+ /**
+ * Overrides <code>MarshalInputStream.readAnnotation</code> to
+ * return locations from the stream we were given, or <code>null</code>
+ * if we were given a <code>null</code> location stream.
+ */
+ protected String readAnnotation()
+ throws IOException, ClassNotFoundException
+ {
+ return (locIn == null ? null : (String)locIn.readObject());
+ }
+ }
+
+ /**
+ * Input stream to convert <code>java.rmi.MarshalledObject</code>
+ * into <code>net.jini.io.MarshalledObject</code>.
+ */
+ private static class FromMOInputStream extends ObjectInputStream {
- MarshalledInstanceInputStream(InputStream objIn, InputStream locIn, ClassLoader defaultLoader, boolean verifyCodebaseIntegrity, ClassLoader verifierLoader, Collection context) throws IOException {
- super(objIn, defaultLoader, verifyCodebaseIntegrity, verifierLoader, context);
- this.locIn = (locIn == null ? null : new ObjectInputStream(locIn));
- }
-
- @Override
- protected String readAnnotation() throws IOException, ClassNotFoundException {
- return locIn == null ? null : (String) locIn.readObject();
- }
+ public FromMOInputStream(InputStream in) throws IOException {
+ super(in);
+ }
+
+ /**
+ * Overrides <code>ObjectInputStream.resolveClass</code> to change
+ * an occurence of class <code>java.rmi.MarshalledObject</code> to
+ * class <code>net.jini.io.MarshalledObject</code>.
+ */
+ protected Class resolveClass(ObjectStreamClass desc)
+ throws IOException, ClassNotFoundException
+ {
+ if (desc.getName().equals("java.rmi.MarshalledObject")) {
+ return net.jini.io.MarshalledObject.class;
+ }
+ return super.resolveClass(desc);
+ }
}
-
- private static class MarshalledInstanceOutputStream extends MarshalOutputStream {
- private ObjectOutputStream locOut;
- /** <code>true</code> if non-<code>null</code> annotations are
- * written.
- */
- private boolean hadAnnotations;
-
- public MarshalledInstanceOutputStream(OutputStream objOut, OutputStream locOut, Collection context) throws IOException {
- super(objOut, context);
- this.locOut = new ObjectOutputStream(locOut);
- hadAnnotations = false;
- }
-
- /**
- * Returns <code>true</code> if any non-<code>null</code> location
- * annotations have been written to this stream.
- */
- public boolean hadAnnotations() {
- return hadAnnotations;
- }
-
- @Override
- protected void writeAnnotation(String loc) throws IOException {
- hadAnnotations |= (loc != null);
- locOut.writeObject(loc);
- }
-
- @Override
- public void flush() throws IOException {
- super.flush();
- locOut.flush();
- }
+ /**
+ * Input stream to convert
+ * <code>net.jini.io.MarshalledObject</code> into
+ * <code>java.rmi.MarshalledObject</code>.
+ */
+ private static class ToMOInputStream extends ObjectInputStream {
+
+ public ToMOInputStream(InputStream in) throws IOException {
+ super(in);
+ }
+
+ /**
+ * Overrides <code>ObjectInputStream.resolveClass</code>
+ * to change an occurence of class
+ * <code>net.jini.io.MarshalledObject</code>
+ * to class <code>java.rmi.MarshalledObject</code>.
+ */
+ protected Class resolveClass(ObjectStreamClass desc)
+ throws IOException, ClassNotFoundException
+ {
+ if (desc.getName().equals("net.jini.io.MarshalledObject")) {
+ return java.rmi.MarshalledObject.class;
+ }
+ return super.resolveClass(desc);
+ }
}
}
Modified: incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/lookup/JoinManager.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/lookup/JoinManager.java?rev=997556&r1=997555&r2=997556&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/lookup/JoinManager.java (original)
+++ incubator/river/jtsk/skunk/patsTaskManager/src/net/jini/lookup/JoinManager.java Thu Sep 16 01:36:08 2010
@@ -53,10 +53,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
-import net.jini.core.lookup.PortableServiceRegistrar;
-import net.jini.discovery.DiscoveryListenerManagement;
-import net.jini.discovery.RegistrarManagement;
-import org.apache.river.api.util.Facade;
/**
* A goal of any well-behaved service is to advertise the facilities and
@@ -441,31 +437,7 @@ import org.apache.river.api.util.Facade;
* @see java.util.logging.Logger
*/
public class JoinManager {
-
- private static void discard(DiscoveryListenerManagement dlm,
- PortableServiceRegistrar proxy, Logger logger){
- try {
- if (dlm instanceof RegistrarManagement){
- RegistrarManagement rm = (RegistrarManagement) dlm;
- rm.discard(proxy);
- } else {
- throw new UnsupportedOperationException("Not instance of " +
- "RegistrarManagement");
- }
- } catch(IllegalStateException e1) {
- logger.log(Level.FINEST,
- "JoinManager - cannot discard lookup, "
- +"discovery manager already terminated",
- e1);
- } catch(UnsupportedOperationException ex){
- logger.log(Level.FINEST,
- "JoinManager - cannot discard lookup, "
- +"DiscoveryManager not supported on this" +
- " platform, use RegistrarManagement instead.",
- ex);
- }
- }
-
+
/** Implementation Note:
*
* This class executes a number of tasks asynchronously. Each task is
@@ -1173,7 +1145,7 @@ public class JoinManager {
* this class, and with which this join manager's service will be
* registered.
*/
- public PortableServiceRegistrar proxy;
+ public ServiceRegistrar proxy;
/** The <i>prepared</i> registration proxy returned by this class'
* associated lookup service when this join manager registers its
* associated service.
@@ -1201,12 +1173,12 @@ public class JoinManager {
* which the sub-tasks referenced in this class will be
* executed in order
*/
- public ProxyReg(PortableServiceRegistrar proxy) {
+ public ProxyReg(ServiceRegistrar proxy) {
if(proxy == null) throw new IllegalArgumentException
("proxy can't be null");
this.proxy = proxy;
- }//end constructor
-
+ }//end constructor
+
/** Convenience method that adds new sub-tasks to this class'
* task queue.
*
@@ -1354,12 +1326,17 @@ public class JoinManager {
LogUtil.logThrow(logger, Level.INFO, ProxyReg.class, "fail",
"JoinManager - failure for lookup service proxy: {0}",
new Object[] { proxy }, e);
- discard(discMgr, proxy, logger);
+ try {
+ discMgr.discard(proxy);
+ } catch(IllegalStateException e1) {
+ logger.log(Level.FINEST,
+ "JoinManager - cannot discard lookup, "
+ +"discovery manager already terminated",
+ e1);
+ }
}//endif
}//end sync(this)
}//end ProxyReg.fail
-
-
/** Returns true if the both objects' associated proxies are equal. */
public boolean equals(Object obj) {
@@ -1382,15 +1359,15 @@ public class JoinManager {
/* Invoked when new or previously discarded lookup is discovered. */
public void discovered(DiscoveryEvent e) {
synchronized(joinSet) {
- PortableServiceRegistrar[] proxys
- = (PortableServiceRegistrar[])e.getPRegistrars();
+ ServiceRegistrar[] proxys
+ = (ServiceRegistrar[])e.getRegistrars();
for(int i=0;i<proxys.length;i++) {
/* Prepare the proxy to the discovered lookup service
* before interacting with it.
*/
try {
proxys[i]
- = (PortableServiceRegistrar)registrarPreparer.prepareProxy
+ = (ServiceRegistrar)registrarPreparer.prepareProxy
(proxys[i]);
logger.log(Level.FINEST, "JoinManager - discovered "
+"lookup service proxy prepared: {0}",
@@ -1400,7 +1377,7 @@ public class JoinManager {
DiscMgrListener.class, "discovered", "failure "
+ "preparing discovered ServiceRegistrar proxy: "
+ "{0}", new Object[] { proxys[i] }, e1);
- discard( discMgr, proxys[i], logger);
+ discMgr.discard(proxys[i]);
continue;
}
/* If the serviceItem is a lookup service, don't need to
@@ -1499,11 +1476,11 @@ public class JoinManager {
* references a proxy to one of the lookup services with which this
* join manager's service is registered.
*/
- private final ArrayList<ProxyReg> joinSet = new ArrayList<ProxyReg>(1);
+ private final ArrayList joinSet = new ArrayList(1);
/** Contains the discovery manager that discovers the lookup services
* with which this join manager will register its associated service.
*/
- private DiscoveryListenerManagement discMgr = null;
+ private DiscoveryManagement discMgr = null;
/** Contains the discovery listener registered by this join manager with
* the discovery manager so that this join manager is notified whenever
* one of the desired lookup services is discovered or discarded.
@@ -1635,10 +1612,7 @@ public class JoinManager {
* @see net.jini.discovery.DiscoveryManagement
* @see net.jini.discovery.LookupDiscoveryManager
* @see net.jini.lease.LeaseRenewalManager
- * @deprecated {@link replaced by #JoinManager(Object, Entry[],
- * ServiceIDListener, LeaseRenewalManager, DiscoveryListenerManagement)}
*/
- @Deprecated
public JoinManager(Object serviceProxy,
Entry[] attrSets,
ServiceIDListener callback,
@@ -1651,20 +1625,6 @@ public class JoinManager {
EmptyConfiguration.INSTANCE);
} catch(ConfigurationException e) { /* swallow this exception */ }
}//end constructor
-
- public JoinManager(Object serviceProxy,
- Entry[] attrSets,
- ServiceIDListener callback,
- DiscoveryListenerManagement discoveryMgr,
- LeaseRenewalManager leaseMgr
- ) throws IOException
- {
- discMgr = discoveryMgr;
- try {
- createJoinManager(null, serviceProxy, attrSets, callback, leaseMgr,
- EmptyConfiguration.INSTANCE);
- } catch(ConfigurationException e) { /* swallow this exception */ }
- }//end constructor
/**
* Constructs an instance of this class, configured using the items
@@ -1769,7 +1729,6 @@ public class JoinManager {
* @see net.jini.config.Configuration
* @see net.jini.config.ConfigurationException
*/
- @Deprecated
public JoinManager(Object serviceProxy,
Entry[] attrSets,
ServiceIDListener callback,
@@ -1783,19 +1742,6 @@ public class JoinManager {
callback, leaseMgr, config);
}//end constructor
- public JoinManager(Object serviceProxy,
- Entry[] attrSets,
- ServiceIDListener callback,
- DiscoveryListenerManagement discoveryMgr,
- LeaseRenewalManager leaseMgr,
- Configuration config)
- throws IOException, ConfigurationException
- {
- discMgr = discoveryMgr;
- createJoinManager(null, serviceProxy, attrSets,
- callback, leaseMgr, config);
- }//end constructor
-
/**
* Constructs an instance of this class that will register the
* service with all discovered lookup services, using the supplied
@@ -1845,7 +1791,6 @@ public class JoinManager {
* @see net.jini.discovery.LookupDiscoveryManager
* @see net.jini.lease.LeaseRenewalManager
*/
- @Deprecated
public JoinManager(Object serviceProxy,
Entry[] attrSets,
ServiceID serviceID,
@@ -1860,22 +1805,6 @@ public class JoinManager {
} catch(ConfigurationException e) { /* swallow this exception */ }
}//end constructor
- public JoinManager(Object serviceProxy,
- Entry[] attrSets,
- ServiceID serviceID,
- DiscoveryListenerManagement discoveryMgr,
- LeaseRenewalManager leaseMgr
- )
- throws IOException
- {
- discMgr = discoveryMgr;
- try {
- createJoinManager(serviceID, serviceProxy, attrSets,
- (ServiceIDListener)null, leaseMgr,
- EmptyConfiguration.INSTANCE);
- } catch(ConfigurationException e) { /* swallow this exception */ }
- }//end constructor
-
/**
* Constructs an instance of this class, configured using the items
* retrieved through the given <code>Configuration</code>, that will
@@ -1940,7 +1869,6 @@ public class JoinManager {
* @see net.jini.config.Configuration
* @see net.jini.config.ConfigurationException
*/
- @Deprecated
public JoinManager(Object serviceProxy,
Entry[] attrSets,
ServiceID serviceID,
@@ -1953,19 +1881,6 @@ public class JoinManager {
createJoinManager(serviceID, serviceProxy, attrSets,
(ServiceIDListener)null, leaseMgr, config);
}//end constructor
-
- public JoinManager(Object serviceProxy,
- Entry[] attrSets,
- ServiceID serviceID,
- DiscoveryListenerManagement discoveryMgr,
- LeaseRenewalManager leaseMgr,
- Configuration config)
- throws IOException, ConfigurationException
- {
- discMgr = discoveryMgr;
- createJoinManager(serviceID, serviceProxy, attrSets,
- (ServiceIDListener)null, leaseMgr, config);
- }//end constructor
/**
* Returns the instance of <code>DiscoveryManagement</code> that was
@@ -1984,54 +1899,16 @@ public class JoinManager {
*
* @see net.jini.discovery.DiscoveryManagement
* @see net.jini.discovery.LookupDiscoveryManager
- * @deprecated replaced by {@link #discoveryManager()}
*/
- @Deprecated
public DiscoveryManagement getDiscoveryManager(){
synchronized(this) {
if(bTerminated) {
throw new IllegalStateException("join manager was terminated");
}//endif
}//end sync
- // Don't need to worry about facades, all implementers of the new
- // interfaces implement DiscoveryManagement, at least until this method is removed.
- if (discMgr instanceof DiscoveryManagement){
- return (DiscoveryManagement) discMgr;
- }
- return null;
-
- }//end getDiscoveryManager
-
- /**
- * Returns the instance of <code>DiscoveryListenerManagement</code> that was
- * either passed into the constructor, or that was created as a result
- * of <code>null</code> being input to that parameter.
- * <p>
- * The object returned by this method encapsulates the mechanism by which
- * either the <code>JoinManager</code> or the entity itself can set
- * discovery listeners and discard previously discovered lookup services
- * when they are found to be unavailable.
- *
- * @return the instance of the <code>DiscoveryListenerManagement</code> interface
- * that was either passed into the constructor, or that was
- * created as a result of <code>null</code> being input to that
- * parameter.
- *
- * @see net.jini.discovery.DiscoveryListenerManagement
- * @see net.jini.discovery.RegistrarManagement
- * @see net.jini.discovery.LookupDiscoveryManager
- */
- public DiscoveryListenerManagement discoveryManager(){
- synchronized(this) {
- if(bTerminated) {
- throw new IllegalStateException("join manager was terminated");
- }//endif
- }//end sync
- // Don't need to worry about revealing facades, they do that in their
- // constructor.
- return discMgr;
+ return discMgr;
}//end getDiscoveryManager
-
+
/**
* Returns the instance of the <code>LeaseRenewalManager</code> class
* that was either passed into the constructor, or that was created
@@ -2061,7 +1938,6 @@ public class JoinManager {
return leaseRenewalMgr;
}//end getLeaseRenewalManager
-
/**
* Returns an array of <code>ServiceRegistrar</code> objects, each
* corresponding to a lookup service with which the service is currently
@@ -2075,7 +1951,7 @@ public class JoinManager {
*
* @see net.jini.core.lookup.ServiceRegistrar
*/
- public PortableServiceRegistrar[] getPJoinSet() {
+ public ServiceRegistrar[] getJoinSet() {
synchronized(this) {
if(bTerminated) {
throw new IllegalStateException("join manager was terminated");
@@ -2090,38 +1966,11 @@ public class JoinManager {
retList.add(proxyReg.proxy);
}//endif
}//end loop
- return ( (PortableServiceRegistrar[])(retList.toArray
- (new PortableServiceRegistrar[retList.size()]) ) );
- }//end sync(joinSet)
- }//end getPJoinSet
-
- @Deprecated
- public ServiceRegistrar[] getJoinSet() {
- synchronized(this) {
- if(bTerminated) {
- throw new IllegalStateException("join manager was terminated");
- }//endif
- }//end sync
- synchronized(joinSet) {
- ArrayList<ServiceRegistrar> retList =
- new ArrayList<ServiceRegistrar>(joinSet.size());
- int k = 0;
- for (Iterator iter = joinSet.iterator(); iter.hasNext(); ) {
- ProxyReg proxyReg = (ProxyReg)iter.next();
- if(proxyReg.srvcRegistration != null) {//test registration flag
- PortableServiceRegistrar psr = proxyReg.proxy;
- if (psr instanceof ServiceRegistrar){
- retList.add((ServiceRegistrar)psr);
- }else{
- retList.add(new ServiceRegistrarFacade(psr));
- }
- }//endif
- }//end loop
return ( (ServiceRegistrar[])(retList.toArray
(new ServiceRegistrar[retList.size()]) ) );
}//end sync(joinSet)
}//end getJoinSet
-
+
/**
* Returns an array containing the set of attributes currently associated
* with the service. If the service is not currently associated with an
@@ -2711,12 +2560,10 @@ public class JoinManager {
if(discMgr == null) {
bCreateDiscMgr = true;
try {
- // Changed to the new Interface which all DiscoveryManagers
- // must implement.
- discMgr = (DiscoveryListenerManagement)config.getEntry
+ discMgr = (DiscoveryManagement)config.getEntry
(COMPONENT_NAME,
"discoveryManager",
- DiscoveryListenerManagement.class);
+ DiscoveryManagement.class);
} catch(NoSuchEntryException e) { /* use default */
discMgr = new LookupDiscoveryManager
(new String[] {""}, null, null, config);
@@ -2730,11 +2577,7 @@ public class JoinManager {
* such an element, returns that element; otherwise returns
* <code>null</code>.
*/
- private ProxyReg findReg(PortableServiceRegistrar proxy) {
- while ( proxy instanceof Facade){
- Facade f = (Facade)proxy;
- proxy = (PortableServiceRegistrar) f.reveal();
- }
+ private ProxyReg findReg(ServiceRegistrar proxy) {
for (Iterator iter = joinSet.iterator(); iter.hasNext(); ) {
ProxyReg reg =(ProxyReg)iter.next();
if(reg.proxy.equals(proxy)) return reg;