river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcost...@apache.org
Subject svn commit: r997542 [2/2] - in /incubator/river/jtsk/trunk: examples/hello/src/com/sun/jini/example/hello/ qa/src/com/sun/jini/test/impl/joinmanager/ qa/src/com/sun/jini/test/spec/joinmanager/ src/com/sun/jini/discovery/ src/com/sun/jini/discovery/inte...
Date Wed, 15 Sep 2010 23:45:53 GMT
Modified: incubator/river/jtsk/trunk/src/net/jini/io/MarshalledInstance.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/io/MarshalledInstance.java?rev=997542&r1=997541&r2=997542&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/io/MarshalledInstance.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/io/MarshalledInstance.java Wed Sep 15 23:45:52
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/trunk/src/net/jini/lookup/JoinManager.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/lookup/JoinManager.java?rev=997542&r1=997541&r2=997542&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/lookup/JoinManager.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/lookup/JoinManager.java Wed Sep 15 23:45:52 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;



Mime
View raw message