You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by jc...@apache.org on 2010/09/01 19:24:37 UTC

svn commit: r991612 - in /incubator/river/jtsk/trunk: src/net/jini/core/event/ src/net/jini/core/lookup/ src/net/jini/discovery/ src/net/jini/lease/ test/src/net/jini/core/event/ test/src/net/jini/discovery/

Author: jcosters
Date: Wed Sep  1 17:24:36 2010
New Revision: 991612

URL: http://svn.apache.org/viewvc?rev=991612&view=rev
Log:
backout RemoteEvent changes

Modified:
    incubator/river/jtsk/trunk/src/net/jini/core/event/RemoteEvent.java
    incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceEvent.java
    incubator/river/jtsk/trunk/src/net/jini/discovery/RemoteDiscoveryEvent.java
    incubator/river/jtsk/trunk/src/net/jini/lease/RenewalFailureEvent.java
    incubator/river/jtsk/trunk/test/src/net/jini/core/event/RemoteEventTest.java
    incubator/river/jtsk/trunk/test/src/net/jini/discovery/RemoteDiscoveryEventTest.java

Modified: incubator/river/jtsk/trunk/src/net/jini/core/event/RemoteEvent.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/core/event/RemoteEvent.java?rev=991612&r1=991611&r2=991612&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/core/event/RemoteEvent.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/core/event/RemoteEvent.java Wed Sep  1 17:24:36 2010
@@ -18,13 +18,7 @@
 
 package net.jini.core.event;
 
-
-import java.io.IOException;
-import java.util.EventObject;
-import net.jini.io.Convert;
-import net.jini.io.MarshalledInstance;
-import net.jini.io.MiToMoOutputStream;
-import net.jini.io.MoToMiInputStream;
+import java.rmi.MarshalledObject;
 
 /**
  * The base class or superclass for remote events.
@@ -33,7 +27,7 @@ import net.jini.io.MoToMiInputStream;
  * to the object in which the event occurred, a long which identifies the
  * kind of event relative to the object in which the event occurred, a long
  * which indicates the sequence number of this instance of the event kind,
- * and a MarshalledInstance that is to be handed back when the notification
+ * and a MarshalledObject that is to be handed back when the notification
  * occurs.  The combination of the event identifier and the object reference
  * obtained from the RemoteEvent object should uniquely identify the event
  * type.
@@ -81,15 +75,11 @@ import net.jini.io.MoToMiInputStream;
  * @author Sun Microsystems, Inc.
  *
  * @since 1.0
- * @version 2.0
  */
-public class RemoteEvent extends java.util.EventObject implements Comparable {
-    /**
-     * Serialization is broken for Serializing to River Releases earlier than
-     * 2.2.0, however it will succeed 
-     * @serial
-     */
+public class RemoteEvent extends java.util.EventObject {
+
     private static final long serialVersionUID = 1777278867291906446L;
+
     /**
      * The event source.
      *
@@ -112,19 +102,11 @@ public class RemoteEvent extends java.ut
     protected long seqNum;
 
     /**
-     * The handback object, there is a remote possibility that this object
-     * is required to be accessed by a subclass, the visibility has been 
-     * changed from protected to private, this may break binary compatibility
-     * for some.
-     * 
-     * The serial form of this field is java.rmi.MarshalledObject, this class
-     * uses stream based converters to convert to and from MarshalledObject
-     * during serialization and deserialization.
-     * 
-     * @see MarshalledObject
+     * The handback object.
+     *
      * @serial
      */
-    private MarshalledInstance handback;
+    protected MarshalledObject handback;
 
     /**
      * Constructs a RemoteEvent object.
@@ -143,49 +125,14 @@ public class RemoteEvent extends java.ut
      * @param seqNum    a <tt>long</tt> containing the event sequence number
      * @param handback  a <tt>MarshalledObject</tt> that was passed in 
      *                  as part of the original event registration.
-     * @deprecated As of Release 2.2.0 this method cannot be supported on
-     * the Java CDC Personal Profile 1.12 platform.
      */
-    @Deprecated
     public RemoteEvent(Object source, long eventID, long seqNum,
-		       java.rmi.MarshalledObject handback) {
+		       MarshalledObject handback) {
 	super(source);
 	this.source = source;
 	this.eventID = eventID;
 	this.seqNum = seqNum;
-        Convert convert = Convert.getInstance();
-	if ( handback != null ){
-	    this.handback = convert.toMarshalledInstance(handback);
-	} else {
-	    this.handback = null;
-	}
-    }
-    /**
-     * Constructs a RemoteEvent object.
-     * <p>
-     * The abstract state contained in a RemoteEvent object includes a 
-     * reference to the object in which the event occurred, a long which 
-     * identifies the kind of event relative to the object in which the 
-     * event occurred, a long which indicates the sequence number of this 
-     * instance of the event kind, and a MarshalledInstance that is to be 
-     * handed back when the notification occurs. The combination of the 
-     * event identifier and the object reference obtained from the 
-     * RemoteEvent object should uniquely identify the event type.
-     * 
-     * @param source    an <tt>Object</tt> representing the event source
-     * @param eventID   a <tt>long</tt> containing the event identifier
-     * @param seqNum    a <tt>long</tt> containing the event sequence number
-     * @param handback  a <tt>MarshalledInstance</tt> that was passed in 
-     *                  as part of the original event registration.
-     */
-    public RemoteEvent( Object source, MarshalledInstance handback, long eventID,
-            long seqNum ) {
-	super(source);
-        this.source = source;
-        this.eventID = eventID;
-        this.seqNum = seqNum;
-        this.handback = handback;
-           
+	this.handback = handback;
     }
 
     /**
@@ -216,145 +163,17 @@ public class RemoteEvent extends java.ut
      * @return the MarshalledObject that was provided as a parameter to
      *         the event interest registration method, if any. 
      */
-    @Deprecated
-    public java.rmi.MarshalledObject getRegistrationObject() {
-        Convert convert = Convert.getInstance();
-	if (handback != null) return convert.toRmiMarshalledObject(handback);
-	return null;
-    }
-    
-    public MarshalledInstance getRegisteredObject() {
-	return handback;      
-    }
-    
-    /* Because the source is also in the parent EventObject and the parent
-     * doesn't itself override equals, the RemoteEvent's are considered 
-     * equal if all fields are equal.  This is conformant with the
-     * idempotent requirement.
-     */ 
-    @Override
-    public boolean equals(Object o){
-	if ( this == o ) return true;
-	if ( !(o instanceof RemoteEvent)) return false;
-	RemoteEvent that = (RemoteEvent) o;
-	if ( (eventID == that.eventID) &&
-		( handback == that.handback || handback.equals(that.handback)) &&
-		( seqNum == that.seqNum ) &&
-		( source == that.source || source.equals(that.source)))
-	{
-	    return true;
-	}
-	return false;
+    public MarshalledObject getRegistrationObject() {
+	return handback;
     }
 
-    @Override
-    public int hashCode() {
-	int hash = 5;
-	hash = 97 * hash + (this.source != null ? this.source.hashCode() : 0);
-	hash = 97 * hash + (int) (this.eventID ^ (this.eventID >>> 32));
-	hash = 97 * hash + (int) (this.seqNum ^ (this.seqNum >>> 32));
-	hash = 97 * hash + (this.handback != null ? this.handback.hashCode() : 0);
-	return hash;
-    }
-     
-    /**
-     * This implementation ignores the fact that remote events may not be
-     * fully equal.  Instead, it just ensures that equal events return 0.
-     * All other orderings then rely on eventID followed by seqNum.  Which
-     * are ordered as intended.
-     * 
-     * The combination of eventID and sequence number and Object provide a 
-     * unique identity. The combination of eventID and Object should uniquely
-     * identify the type.
-     * 
-     * Objects with equal identity but whose equals method returns false
-     * throw an IllegalStateException.
-     * 
-     * @throws IllegalStateException if identity is the same but objects are not equal.
-     * @throws ClassCastException if classes of different types not comparable.
-     */ 
-    public int compareTo(Object o) {
-	if (equals(o)) return 0; // Only return 0 if actually equal.
-	if (o instanceof RemoteEvent ){
-	    RemoteEvent that = (RemoteEvent) o;
-	    if ( eventID < that.eventID ) return -1;
-	    if ( eventID > that.eventID ) return 1;
-	    // If we get to here eventID's are equal.
-	    if ( seqNum < that.seqNum ) return -1;
-	    if ( seqNum > that.seqNum ) return 1;
-	    // If we get to here sequence numbers are equal.
-	    if ( source != null && that.source != null) {
-		int thisHash = source.hashCode();
-		int otherHash = that.source.hashCode();
-		if ( thisHash < otherHash ) return -1;
-		if ( thisHash > otherHash ) return 1;
-	    }
-	    if ( source == that.source || source.equals(that.source)) {
-		throw new IllegalStateException("RemoteEvent's not equal but " +
-			"eventID Object and sequence numbers equal");
-	    }
-	    // If we get here we are very unlucky, since the object isn't equal
-	    // lets check our own hashcodes.
-	    int thisHash = hashCode();
-	    int otherHash = that.hashCode();
-	    if ( thisHash < otherHash ) return -1;
-	    if ( thisHash > otherHash ) return 1;
-	    if ( !this.getClass().equals(that.getClass())) {
-		throw new ClassCastException("Different subclasses were uncomparable");
-	    }
-	    throw new IllegalStateException("something went wrong " +
-		    this.getClass().getCanonicalName() + " has unlucky hashcode" +
-		    "implementation, objects not equal but hashcodes are " +
-		    "not comparable, try to improve hashcode");
-	}
-	throw new ClassCastException("Compared object not a RemoteEvent");	
-    }
-    
     /**
-     * Serialization support, the serialized form of this object converts
-     * a java.rmi.MarshalledObject, later when support for marshalling to
-     * java.rmi.MarshalledObject Serialized Form is dropped, this
-     * method can still convert old events if neccessary.
-     * I need a test to confirm that this is backward serializable compatible.
+     * Serialization support
      */
     private void readObject(java.io.ObjectInputStream stream)
 	throws java.io.IOException, ClassNotFoundException
     {
-	if (stream instanceof MoToMiInputStream){
-	    stream.defaultReadObject();
-	    super.source = source;
-	    return;
-	}
-	MoToMiInputStream in = new MoToMiInputStream(stream);
-	RemoteEvent ev = (RemoteEvent) in.readObject();
-	this.source = ev.source;
+	stream.defaultReadObject();
 	super.source = source;
-	this.eventID = ev.eventID;
-	this.handback = ev.handback;
-	this.seqNum = ev.seqNum;	
-    }
-    
-    /**
-     * 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{
-	if (stream instanceof MiToMoOutputStream){
-	    stream.defaultWriteObject();
-	    return;
-	}
-	MiToMoOutputStream out = new MiToMoOutputStream(stream);
-	out.writeObject(this);
-    }
-    
-    protected void setState(Object source, long eventID, long seqNum, MarshalledInstance handback){
-	super.source = source;
-	this.source = source;
-	this.eventID = eventID;
-	this.seqNum = seqNum;
-	this.handback = handback;
     }
 }

Modified: incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceEvent.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceEvent.java?rev=991612&r1=991611&r2=991612&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceEvent.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceEvent.java Wed Sep  1 17:24:36 2010
@@ -17,8 +17,6 @@
  */
 package net.jini.core.lookup;
 
-import net.jini.io.MarshalledInstance;
-
 /**
  * This class is used for remote events sent by the lookup service.  It
  * extends RemoteEvent with methods to obtain the service ID of the matched
@@ -62,7 +60,6 @@ public abstract class ServiceEvent exten
      * @param serviceID the serviceID of the item that triggered the event
      * @param transition the transition that triggered the event
      */
-    @Deprecated
     public ServiceEvent(Object source,
 			long eventID,
 			long seqNo,
@@ -75,28 +72,6 @@ public abstract class ServiceEvent exten
 	this.transition = transition;
     }
 
-    /**
-     * Simple constructor.
-     *
-     * @param source the source of this ServiceEvent
-     * @param eventID the registration eventID
-     * @param seqNo the sequence number of this event
-     * @param handback the client handback
-     * @param serviceID the serviceID of the item that triggered the event
-     * @param transition the transition that triggered the event
-     */
-    public ServiceEvent(Object source,
-			long eventID,
-			long seqNo,
-			MarshalledInstance handback,
-			ServiceID serviceID,
-			int transition)
-    {
-	super(source, handback, eventID, seqNo);
-	this.serviceID = serviceID;
-	this.transition = transition;
-    }
-    
     /** Returns the serviceID of the item that triggered the event. 
      *
      * @return a <tt>ServiceID</tt> object representing the service ID value
@@ -125,13 +100,13 @@ public abstract class ServiceEvent exten
 	       "[serviceID=").append(getServiceID()).append(
 	       ", transition=");
 	switch (getTransition()) {
-	    case PortableServiceRegistrar.TRANSITION_MATCH_MATCH:
+	    case ServiceRegistrar.TRANSITION_MATCH_MATCH:
 		sBuffer.append("TRANSITION_MATCH_MATCH");
 		break;
-	    case PortableServiceRegistrar.TRANSITION_MATCH_NOMATCH:
+	    case ServiceRegistrar.TRANSITION_MATCH_NOMATCH:
 		sBuffer.append("TRANSITION_MATCH_NOMATCH");
 		break;
-	    case PortableServiceRegistrar.TRANSITION_NOMATCH_MATCH:
+	    case ServiceRegistrar.TRANSITION_NOMATCH_MATCH:
 		sBuffer.append("TRANSITION_NOMATCH_MATCH");
 		break;
 	    default:
@@ -141,32 +116,9 @@ public abstract class ServiceEvent exten
 	sBuffer.append(", source=").append(source).append(
 	    ", eventID=").append(getID()).append(
 	    ", seqNum=").append(getSequenceNumber()).append(
-	    ", handback=").append(getRegisteredObject());
+	    ", handback=").append(getRegistrationObject());
 	return sBuffer.append("]").toString();
     }
-    
-    @Override
-    public boolean equals(Object o){
-	if ( !super.equals(o)) return false;
-	// Super's are equal, let's check this
-	if ( o instanceof ServiceEvent ){
-	    ServiceEvent that = (ServiceEvent) o;
-	    if ( serviceID != null && serviceID.equals(that.serviceID) &&
-		    transition == that.transition )
-	    {
-		return true;
-	    }
-	}
-	return false;
-    }
-
-    @Override
-    public int hashCode() {
-	int hash = super.hashCode();
-	hash = 97 * hash + (this.serviceID != null ? this.serviceID.hashCode() : 0);
-	hash = 97 * hash + this.transition;
-	return hash;
-    }
 
     /**
      * Returns the new state of the item, or null if the item was deleted

Modified: incubator/river/jtsk/trunk/src/net/jini/discovery/RemoteDiscoveryEvent.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/discovery/RemoteDiscoveryEvent.java?rev=991612&r1=991611&r2=991612&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/discovery/RemoteDiscoveryEvent.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/discovery/RemoteDiscoveryEvent.java Wed Sep  1 17:24:36 2010
@@ -23,18 +23,14 @@ import java.io.ObjectInputStream;
 import java.rmi.MarshalledObject;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 
 import net.jini.core.event.RemoteEvent;
 import net.jini.core.lookup.ServiceRegistrar;
-import net.jini.core.lookup.PortableServiceRegistrar;
 import net.jini.io.MarshalledInstance;
 
 import com.sun.jini.proxy.MarshalledWrapper;
-import java.io.ObjectOutputStream;
-import java.util.Iterator;
-import net.jini.io.MiToMoOutputStream;
-import net.jini.io.MoToMiInputStream;
 
 /**
  * Whenever the lookup discovery service discovers or discards a lookup
@@ -61,7 +57,7 @@ import net.jini.io.MoToMiInputStream;
  * of abstract state: a boolean indicating whether the lookup services
  * referenced by the event have been discovered or discarded; and a set
  * consisting of proxy objects where each proxy is a marshalled instance
- * of the PortableServiceRegistrar interface, and each is a proxy of one of the
+ * of the ServiceRegistrar interface, and each is a proxy of one of the
  * recently discovered or discarded lookup service(s). Methods are defined
  * through which this additional state may be retrieved upon receipt of an
  * instance of this class.
@@ -99,8 +95,7 @@ import net.jini.io.MoToMiInputStream;
  * @author Sun Microsystems, Inc.
  *
  * @see net.jini.core.event.RemoteEvent
- * @see net.jini.core.lookup.PortableServiceRegistrar
- * @see net.jini.core.lookup.
+ * @see net.jini.core.lookup.ServiceRegistrar
  */
 public class RemoteDiscoveryEvent extends RemoteEvent {
 
@@ -118,7 +113,7 @@ public class RemoteDiscoveryEvent extend
 
     /**
      * List consisting of marshalled proxy objects where each proxy implements
-     * the <code>PortableServiceRegistrar</code> interface, and each is a proxy of
+     * the <code>ServiceRegistrar</code> interface, and each is a proxy of
      * one of the recently discovered or discarded lookup service(s); the
      * lookup service(s) with which this event is associated. 
      * <p>
@@ -142,7 +137,7 @@ public class RemoteDiscoveryEvent extend
      *
      * @serial
      */
-    protected ArrayList<MarshalledInstance> marshalledRegs;
+    protected ArrayList marshalledRegs;
 
     /**
      * Array containing a subset of the set of proxies to the lookup
@@ -157,7 +152,7 @@ public class RemoteDiscoveryEvent extend
      *
      * @serial
      */
-    protected PortableServiceRegistrar[] regs;
+    protected ServiceRegistrar[] regs;
 
     /**
      * <code>Map</code> from the service IDs of the registrars of this event
@@ -202,7 +197,6 @@ public class RemoteDiscoveryEvent extend
      * @throws java.lang.IllegalArgumentException this exception occurs
      *         when an empty set of registrars is input.
      */
-    @Deprecated
     public RemoteDiscoveryEvent(Object source,
                                 long eventID,
                                 long seqNum,
@@ -217,90 +211,9 @@ public class RemoteDiscoveryEvent extend
             if(groups.size() == 0) {
                 throw new IllegalArgumentException("empty input map");
             }
-            PortableServiceRegistrar[] registrars =
-                          (PortableServiceRegistrar[])(groups.keySet()).toArray
-                                        (new PortableServiceRegistrar[groups.size()]);
-            /* If any elements of the array are null, throw exception */
-            for(int i=0;i<registrars.length;i++) {
-                if(registrars[i] == null) {
-                    throw new NullPointerException("null element ("+i
-                                                   +") in input map");
-                }
-            }
-            /* Create a new marshalled instance of each element of the
-             * registrars array, and place each in the marshalledRegs
-             * ArrayList of this class. Also, construct the groups map that
-             * contains the mappings from the service ID of each registrar
-             * to the registrar's corresponding member groups.
-             *
-             * Drop any element that can't be serialized.
-             */
-            this.groups = new HashMap(groups.size());
-            this.marshalledRegs = new ArrayList<MarshalledInstance>(groups.size());
-            for(int i=0;i<registrars.length;i++) {
-                try {
-                    MarshalledInstance mi = new MarshalledInstance(registrars[i]);
-                    marshalledRegs.add(mi);
-                    (this.groups).put((registrars[i]).getServiceID(),
-                                       groups.get(registrars[i]) );
-		} catch(IOException e) { /* drop if can't serialize */ }
-            }
-            if( !(marshalledRegs.isEmpty()) ) {
-                regs = new PortableServiceRegistrar[marshalledRegs.size()];
-            } else {
-                throw new IOException("failed to serialize any of the "
-                                      +registrars.length+" elements");
-            }
-	} else {
-            throw new NullPointerException("null input map");
-        }
-    }//end constructor
-    
-     /**
-     * Constructs a new instance of <code>RemoteDiscoveryEvent</code>.
-     *
-     * @param source     reference to the lookup discovery service that
-     *                   generated the event
-     * @param eventID    the event identifier that maps a particular
-     *                   registration to its listener and targeted groups
-     *                   and locators
-     * @param seqNum     the sequence number of this event
-     * @param handback   the client handback (null may be input)
-     * @param discarded  flag indicating whether the event being constructed
-     *                   is a discovery event or a discard event
-     * @param groups     mapping from the registrars of this event to the
-     *                   groups in which each registrar is a member
-     *
-     * @throws java.io.IOException when serialization failure occurs on 
-     *         every registrar of this event. That is, if at least one
-     *         registrar is successfully serialized, then this exception
-     *         will not be thrown.
-     *
-     * @throws java.lang.NullPointerException this exception occurs when
-     *         either <code>null</code> is input for the map parameter, or
-     *         at least one element of that map is <code>null</code>.
-     *
-     * @throws java.lang.IllegalArgumentException this exception occurs
-     *         when an empty set of registrars is input.
-     */
-
-    public RemoteDiscoveryEvent(Object source,
-                                long eventID,
-                                long seqNum,
-				MarshalledInstance handback,
-                                boolean discarded,
-                                Map groups)    throws IOException
-    {
-	super( source, handback, eventID, seqNum);
-	this.discarded = discarded;
-        if(groups != null) {
-            /* If the set of registrars is empty, throw exception */
-            if(groups.size() == 0) {
-                throw new IllegalArgumentException("empty input map");
-            }
-            PortableServiceRegistrar[] registrars =
-                          (PortableServiceRegistrar[])(groups.keySet()).toArray
-                                        (new PortableServiceRegistrar[groups.size()]);
+            ServiceRegistrar[] registrars =
+                          (ServiceRegistrar[])(groups.keySet()).toArray
+                                        (new ServiceRegistrar[groups.size()]);
             /* If any elements of the array are null, throw exception */
             for(int i=0;i<registrars.length;i++) {
                 if(registrars[i] == null) {
@@ -320,14 +233,13 @@ public class RemoteDiscoveryEvent extend
             this.marshalledRegs = new ArrayList(groups.size());
             for(int i=0;i<registrars.length;i++) {
                 try {
-                    MarshalledInstance mi = new MarshalledInstance(registrars[i]);
-                    marshalledRegs.add(mi);
+                    marshalledRegs.add(new MarshalledObject(registrars[i]));
                     (this.groups).put((registrars[i]).getServiceID(),
                                        groups.get(registrars[i]) );
 		} catch(IOException e) { /* drop if can't serialize */ }
             }
             if( !(marshalledRegs.isEmpty()) ) {
-                regs = new PortableServiceRegistrar[marshalledRegs.size()];
+                regs = new ServiceRegistrar[marshalledRegs.size()];
             } else {
                 throw new IOException("failed to serialize any of the "
                                       +registrars.length+" elements");
@@ -409,82 +321,7 @@ public class RemoteDiscoveryEvent extend
      *
      * @see net.jini.discovery.LookupUnmarshalException
      */
-    @Deprecated
     public ServiceRegistrar[] getRegistrars() throws LookupUnmarshalException {
-	PortableServiceRegistrar[] psr = getPRegistrars();
-        ArrayList<ServiceRegistrar> sr = new ArrayList<ServiceRegistrar>();
-        int l = psr.length;
-        for ( int i = 0; i < l; i++){
-            if (psr[i] instanceof ServiceRegistrar) {
-                sr.add((ServiceRegistrar) psr[i]);
-            }
-        }
-        ServiceRegistrar[] sra = new ServiceRegistrar[sr.size()];
-        return sr.toArray(sra);
-    }//end getRegistrars
-
-    /**
-     * Returns an array consisting of instances of the PortableServiceRegistrar
-     * interface. Each element in the returned set is a proxy to one of
-     * the newly discovered or discarded lookup service(s) that caused
-     * the current instance of this event class to be sent to the listener
-     * of the client's registration. Note that a new array is returned
-     * on every call.
-     * <p>
-     * When the lookup discovery service sends an instance of this event
-     * class to the listener of a client's registration, the set of lookup
-     * service proxies contained in the event is sent as a set of marshalled
-     * instances of the PortableServiceRegistrar interface. Thus, in order to 
-     * construct the return set, this method attempts to unmarshal each
-     * element of that set of proxies. Should a failure occur while
-     * attempting to unmarshal any of the elements of the set of marshalled
-     * proxy objects contained in the current instance of this class, this
-     * method will throw an exception of type LookupUnmarshalException. 
-     * <p>
-     * When a LookupUnmarshalException is thrown by this method, the
-     * contents of the exception provides the client with the following
-     * useful information: (1) the knowledge that a problem has occurred
-     * while unmarshalling at least one of the as yet unmarshalled proxy
-     * objects, (2) the set consisting of the proxy objects that were
-     * successfully unmarshalled (either on the current invocation of
-     * this method or on some previous invocation), (3) the set consisting
-     * of the marshalled proxy objects that could not be unmarshalled
-     * during the current or any previous invocation of this method, and
-     * (4) the set of exceptions corresponding to each failed attempt at
-     * unmarshalling during the current invocation of this method.
-     * <p>
-     * Typically, the type of exception that occurs when attempting to
-     * unmarshal an element of the set of marshalled proxies is either an
-     * IOException or a ClassNotFoundException. A ClassNotFoundException 
-     * occurs whenever a remote field of the marshalled proxy cannot be
-     * retrieved (usually because the codebase of one of the field's classes
-     * or interfaces is currently 'down'). To address this situation, the
-     * client may wish to invoke this method at some later time when the
-     * 'down' codebase(s) may be accessible. Thus, the client can invoke
-     * this method multiple times until all of the elements of the set of
-     * marshalled proxies can be successfully unmarshalled.
-     * <p>
-     * Note that once an element of the set of marshalled proxy objects has
-     * been successfully unmarshalled on a particular invocation of this
-     * method, the resulting unmarshalled proxy is stored for return on
-     * all future invocations of this method. That is, once successfully
-     * unmarshalled, no attempt will be made to unmarshal that element on
-     * any future invocations of this method. Thus, if this method returns
-     * successfully without throwing a LookupUnmarshalException, the client
-     * is guaranteed that all marshalled proxies have been successfully
-     * unmarshalled; and any future invocations of this method will return
-     * successfully.
-     *
-     * @return an array consisting of references to the discovered or discarded
-     *         lookup service(s) corresponding to this event.
-     * 
-     * @throws net.jini.discovery.LookupUnmarshalException this exception
-     *         occurs when at least one of the set of lookup service
-     *         references cannot be deserialized (unmarshalled).
-     *
-     * @see net.jini.discovery.LookupUnmarshalException
-     */
-    public PortableServiceRegistrar[] getPRegistrars() throws LookupUnmarshalException {
 	synchronized (marshalledRegs) {
             if( marshalledRegs.size() > 0 ) {
                 ArrayList unmarshalledRegs = new ArrayList();
@@ -493,24 +330,18 @@ public class RemoteDiscoveryEvent extend
                 /* Add the un-marshalled elements to the end of regs */
                 insertRegistrars(regs,unmarshalledRegs);
                 if( exceptions.size() > 0 ) {
-                    ArrayList<MarshalledInstance> miRegs = 
-                            new ArrayList<MarshalledInstance>(marshalledRegs.size());
-                    Iterator<MarshalledInstance> moRegsit = marshalledRegs.iterator();
-                    while (moRegsit.hasNext()){
-                        miRegs.add(moRegsit.next());
-                    }
                     throw(new LookupUnmarshalException
                       ( clipNullsFromEnd(regs),
-                        (MarshalledInstance[])(miRegs.toArray
-                               (new MarshalledInstance[miRegs.size()])),
+                        (MarshalledObject[])(marshalledRegs.toArray
+                               (new MarshalledObject[marshalledRegs.size()])),
                         (Throwable[])(exceptions.toArray
                                (new Throwable[exceptions.size()])),
-                        "failed to unmarshal at least one PortableServiceRegistrar") );
+                        "failed to unmarshal at least one ServiceRegistrar") );
                 }//endif
             }//endif
             return clipNullsFromEnd(regs);
         }//end sync(marshalledRegs)
-    }//end getPortableRegistrars
+    }//end getRegistrars
 
     /**
      * Returns a set that maps to the service ID of each registrar referenced
@@ -554,7 +385,7 @@ public class RemoteDiscoveryEvent extend
      * set after all unmarshalling attempts have completed.
      * 
      * @param marshalledRegs   an ArrayList object consisting of marshalled
-     *                         objects of PortableServiceRegistrar, each 
+     *                         instances of ServiceRegistrar, each 
      *                         corresponding to a proxy to a lookup service.
      *
      * @param unmarshalledRegs an ArrayList object consisting of all
@@ -565,9 +396,8 @@ public class RemoteDiscoveryEvent extend
      *         result of attempts to unmarshal each element of the first
      *         argument to this method.
      */
-    private ArrayList unmarshalRegistrars(
-            ArrayList<MarshalledInstance> marshalledRegs,
-            ArrayList<PortableServiceRegistrar> unmarshalledRegs)
+    private ArrayList unmarshalRegistrars(ArrayList marshalledRegs,
+                                          ArrayList unmarshalledRegs)
     {
         ArrayList exceptions = new ArrayList();
        /* Try to un-marshal each element in marshalledRegs; verify codebase
@@ -593,10 +423,13 @@ public class RemoteDiscoveryEvent extend
         int i = 0;
         int nMarshalledRegs = marshalledRegs.size();
         for(int n=0;n<nMarshalledRegs;n++) {
-            MarshalledInstance marshalledInstance = marshalledRegs.get(i);
+            MarshalledObject marshalledObj
+                                  = (MarshalledObject)(marshalledRegs.get(i));
+            MarshalledInstance marshalledInstance
+                                  =  new MarshalledInstance(marshalledObj);
             try {
-                PortableServiceRegistrar reg =
-                         (PortableServiceRegistrar)(marshalledInstance.get(integrity));
+                ServiceRegistrar reg =
+                         (ServiceRegistrar)(marshalledInstance.get(integrity));
                 /* Success: record the un-marshalled element
                  *          delete the corresponding un-marshalled element
                  */
@@ -617,10 +450,10 @@ public class RemoteDiscoveryEvent extend
      * 
      * @param regsArray array that will receive the new references.
      * 
-     * @param regsList ArrayList containing the PortableServiceRegistrar references
+     * @param regsList ArrayList containing the ServiceRegistrar references
      *        to place in regsArray input argument.
      */
-    private static void insertRegistrars(PortableServiceRegistrar[] regsArray,
+    private static void insertRegistrars(ServiceRegistrar[] regsArray,
                                          ArrayList regsList)
     {
         if((regsArray != null) && (regsList != null)) {
@@ -630,7 +463,7 @@ public class RemoteDiscoveryEvent extend
             int beg = indexFirstNull(regsArray);
             int end = ( (beg+lenB) <= lenA ? (beg+lenB) : (lenA) );
             for(int i=beg, j=0; i<end; i++,j++) {
-                regsArray[i] = (PortableServiceRegistrar)(regsList.get(j));
+                regsArray[i] = (ServiceRegistrar)(regsList.get(j));
             }
         }
     }//end insertRegistrars
@@ -643,18 +476,18 @@ public class RemoteDiscoveryEvent extend
      * 
      * @param regsArray array from which to copy elements
      * 
-     * @return array of <code>PortableServiceRegistrar</code> containing each element
+     * @return array of <code>ServiceRegistrar</code> containing each element
      *         of the given array from its first element up to, but not 
      *         including, the <code>null</code> element; and all subsequent
      *         elements. If the first element of the given array is 
      *         <code>null</code>, then this method will return an empty array.
      */
-    private static PortableServiceRegistrar[] clipNullsFromEnd
-                                               (PortableServiceRegistrar[] regsArray)
+    private static ServiceRegistrar[] clipNullsFromEnd
+                                               (ServiceRegistrar[] regsArray)
     {
-        if( regsArray == null) return new PortableServiceRegistrar[0];
+        if( regsArray == null) return new ServiceRegistrar[0];
         int clippedLen = indexFirstNull(regsArray);
-        PortableServiceRegistrar[] clippedArray = new PortableServiceRegistrar[clippedLen];
+        ServiceRegistrar[] clippedArray = new ServiceRegistrar[clippedLen];
         for(int i=0; i<clippedLen; i++) {
             clippedArray[i] = regsArray[i];
         }//end loop
@@ -701,43 +534,15 @@ public class RemoteDiscoveryEvent extend
     private void readObject(ObjectInputStream s)  
                                throws IOException, ClassNotFoundException
     {
-        if (s instanceof MoToMiInputStream){
-	    s.defaultReadObject();
-	    /* Verify source */
-	    if(source == null) {
-		throw new InvalidObjectException("RemoteDiscoveryEvent.readObject "
-						+"failure - source field is null");
-	    }//endif
-	    /* Retrieve the value of the integrity flag */
-	    integrity = MarshalledWrapper.integrityEnforced(s);
-	    return;
-	}
-	ObjectInputStream fois = new MoToMiInputStream(s); // convert to java.rmi.MarshalledObject
-        RemoteDiscoveryEvent ev = (RemoteDiscoveryEvent) fois.readObject();
-	this.discarded = ev.discarded;
-	this.groups = ev.groups;
-	this.integrity = ev.integrity;
-	this.marshalledRegs = ev.marshalledRegs;
-	this.regs = ev.regs;
-	//RemoteEvent
-	setState(ev.getSource(), ev.getID(), ev.getSequenceNumber(), ev.getRegisteredObject());
+        s.defaultReadObject();
+        /* Verify source */
+        if(source == null) {
+            throw new InvalidObjectException("RemoteDiscoveryEvent.readObject "
+                                            +"failure - source field is null");
+        }//endif
+        /* Retrieve the value of the integrity flag */
+        integrity = MarshalledWrapper.integrityEnforced(s);
     }//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{
-        if (stream instanceof MiToMoOutputStream){
-	    stream.defaultWriteObject();
-	    return;
-	}
-	MiToMoOutputStream out = new MiToMoOutputStream(stream);
-	out.writeObject(this);
-    }//end writeObject  
 
 }//end class RemoteDiscoveryEvent
 

Modified: incubator/river/jtsk/trunk/src/net/jini/lease/RenewalFailureEvent.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/lease/RenewalFailureEvent.java?rev=991612&r1=991611&r2=991612&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/lease/RenewalFailureEvent.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/lease/RenewalFailureEvent.java Wed Sep  1 17:24:36 2010
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.rmi.MarshalledObject;
 import net.jini.core.lease.Lease;
 import net.jini.core.event.RemoteEvent;
-import net.jini.io.MarshalledInstance;
 
 /**
  * Event generated by a lease renewal set when it can't renew a lease it
@@ -51,9 +50,7 @@ public abstract class RenewalFailureEven
      *	      event
      * @param seqNum the sequence number of this event
      * @param handback the client handback
-     * @deprecated 
      */
-    @Deprecated
     public RenewalFailureEvent(LeaseRenewalSet  source, 
 			       long             seqNum,
 			       MarshalledObject handback)
@@ -61,22 +58,6 @@ public abstract class RenewalFailureEven
 	super(source, LeaseRenewalSet.RENEWAL_FAILURE_EVENT_ID, seqNum, 
 	      handback);
     }
-    
-    /**
-     * Simple constructor. Note event id is fixed to
-     * <code>LeaseRenewalSet.RENEWAL_FAILURE_EVENT_ID</code>.
-     *
-     * @param source the <code>LeaseRenewalSet</code> that generated the
-     *	      event
-     * @param seqNum the sequence number of this event
-     * @param handback the client handback
-     */
-    public RenewalFailureEvent(LeaseRenewalSet  source, 
-			       long             seqNum,
-			       MarshalledInstance handback)
-    {
-	super( source,handback, LeaseRenewalSet.RENEWAL_FAILURE_EVENT_ID, seqNum);
-    }
 
     /**
      * Returns the lease that could not be renewed. This method may

Modified: incubator/river/jtsk/trunk/test/src/net/jini/core/event/RemoteEventTest.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/test/src/net/jini/core/event/RemoteEventTest.java?rev=991612&r1=991611&r2=991612&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/test/src/net/jini/core/event/RemoteEventTest.java (original)
+++ incubator/river/jtsk/trunk/test/src/net/jini/core/event/RemoteEventTest.java Wed Sep  1 17:24:36 2010
@@ -27,9 +27,7 @@ import java.rmi.MarshalledObject;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import net.jini.io.MarshalledInstance;
-import org.junit.AfterClass;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import static org.junit.Assert.*;
 
@@ -43,7 +41,7 @@ public class RemoteEventTest {
     }
     String s = "happy";
     Object source = "source";
-    MarshalledInstance<String> m = null;
+    MarshalledObject<String> m = null;
     RemoteEvent e = null;
     MarshalledObject<String> mo = null;
 
@@ -51,12 +49,11 @@ public class RemoteEventTest {
     @SuppressWarnings("deprecation")
     public void setUp() {
 	try {
-	    m = new MarshalledInstance<String>(s);
-	    mo = m.convertToMarshalledObject();
+	    m = new MarshalledObject<String>(s);
 	} catch (IOException ex) {
 	    Logger.getLogger(RemoteEventTest.class.getName()).log(Level.SEVERE, null, ex);
 	}
-	e = new RemoteEvent(source, m, 10L, 25L );
+	e = new RemoteEvent(source, 10L, 25L,m);
     }
 
     /**
@@ -103,8 +100,8 @@ public class RemoteEventTest {
     public void getRegisteredObject() {
 	System.out.println("getRegisteredObject");
 	RemoteEvent instance = e;
-	MarshalledInstance expResult = m;
-	MarshalledInstance result = instance.getRegisteredObject();
+	MarshalledObject expResult = m;
+	MarshalledObject result = instance.getRegistrationObject();
 	assertEquals(expResult, result);
     }
     
@@ -112,7 +109,7 @@ public class RemoteEventTest {
     public void testSerialization() {
 	ObjectOutputStream oos = null;
 	System.out.println("test serialization");
-	MarshalledInstance expResult = m;
+	MarshalledObject expResult = m;
 	try {
 	    ByteArrayOutputStream baos = new ByteArrayOutputStream();
 	    oos = new ObjectOutputStream(baos);
@@ -122,11 +119,11 @@ public class RemoteEventTest {
 	    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
 	    ObjectInputStream ois = new ObjectInputStream(bais);
 	    RemoteEvent result = (RemoteEvent) ois.readObject();
-	    MarshalledInstance miResult = result.getRegisteredObject();
+	    MarshalledObject moResult = result.getRegistrationObject();
 	    Object srcResult = result.getSource();
 	    long iDResult = result.getID();
 	    long seqResult = result.getSequenceNumber();
-	    assertEquals(expResult, miResult);
+	    assertEquals(expResult, moResult);
 	    assertEquals(source, srcResult);
 	    assertEquals(10L, iDResult);
 	    assertEquals(25L, seqResult);

Modified: incubator/river/jtsk/trunk/test/src/net/jini/discovery/RemoteDiscoveryEventTest.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/test/src/net/jini/discovery/RemoteDiscoveryEventTest.java?rev=991612&r1=991611&r2=991612&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/test/src/net/jini/discovery/RemoteDiscoveryEventTest.java (original)
+++ incubator/river/jtsk/trunk/test/src/net/jini/discovery/RemoteDiscoveryEventTest.java Wed Sep  1 17:24:36 2010
@@ -53,7 +53,7 @@ import static org.mockito.Mockito.*;
 public class RemoteDiscoveryEventTest {
     String s = "happy";
     Object source = "source";
-    MarshalledInstance<String> m = null;
+    MarshalledObject<String> m = null;
     RemoteDiscoveryEvent e = null;
     MarshalledObject<String> mo = null;
     Map groups = new HashMap(1);
@@ -128,8 +128,7 @@ private static class PSR implements Port
     public void setUp() {
 	groups.put(psr, g);
 	try {
-	    m = new MarshalledInstance<String>(s);
-	    mo = m.convertToMarshalledObject();
+	    m = new MarshalledObject<String>(s);
 	    e = new RemoteDiscoveryEvent(source, 10L, 25L, m, true, groups );
 	} catch (IOException ex) {
 	    Logger.getLogger(RemoteDiscoveryEventTest.class.getName()).log(Level.SEVERE, null, ex);
@@ -196,7 +195,7 @@ private static class PSR implements Port
     public void testSerialization() {
 	ObjectOutputStream oos = null;
 	System.out.println("test serialization");
-	MarshalledInstance expResult = m;
+	MarshalledObject expResult = m;
 	try {
 	    ByteArrayOutputStream baos = new ByteArrayOutputStream();
 	    oos = new ObjectOutputStream(baos);
@@ -206,11 +205,11 @@ private static class PSR implements Port
 	    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
 	    ObjectInputStream ois = new ObjectInputStream(bais);
 	    RemoteDiscoveryEvent result = (RemoteDiscoveryEvent) ois.readObject();
-	    MarshalledInstance miResult = result.getRegisteredObject();
+	    MarshalledObject moResult = result.getRegistrationObject();
 	    Object srcResult = result.getSource();
 	    long iDResult = result.getID();
 	    long seqResult = result.getSequenceNumber();
-	    assertEquals(expResult, miResult);
+	    assertEquals(expResult, moResult);
 	    assertEquals(source, srcResult);
 	    assertEquals(10L, iDResult);
 	    assertEquals(25L, seqResult);