You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2010/08/30 00:50:20 UTC

svn commit: r990669 - in /incubator/river/jtsk/trunk: qa/ src/com/sun/jini/lease/ src/com/sun/jini/mahalo/ src/net/jini/core/event/ src/net/jini/core/lookup/ src/net/jini/discovery/ src/net/jini/io/ src/net/jini/lease/ src/net/jini/lookup/ src/org/apac...

Author: peter_firmstone
Date: Sun Aug 29 22:50:19 2010
New Revision: 990669

URL: http://svn.apache.org/viewvc?rev=990669&view=rev
Log:
River-345 patch merged into ServiceDiscoverManager

Serialization Issue fixed in RemoteEvent and RemoteDiscoveryEvent, unit tests included.

Null pointer fixed in RemoteEvent, when null MarhalledObject is passed in and converted to a null MarshalledInstance.

Other changes relate to new method signatures, and the ExecutionContextManager.

The ExecutionContextManager will probably be removed.  The RevokeableDynamicPolicy will be moved out of the Public API, since this is still experimental.

Added:
    incubator/river/jtsk/trunk/test/src/net/jini/core/
    incubator/river/jtsk/trunk/test/src/net/jini/core/event/
    incubator/river/jtsk/trunk/test/src/net/jini/core/event/RemoteEventTest.java   (with props)
    incubator/river/jtsk/trunk/test/src/net/jini/discovery/
    incubator/river/jtsk/trunk/test/src/net/jini/discovery/RemoteDiscoveryEventTest.java   (with props)
Modified:
    incubator/river/jtsk/trunk/qa/build.xml
    incubator/river/jtsk/trunk/src/com/sun/jini/lease/BasicRenewalFailureEvent.java
    incubator/river/jtsk/trunk/src/com/sun/jini/mahalo/JoinStateManager.java
    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/core/lookup/StreamServiceRegistrar.java
    incubator/river/jtsk/trunk/src/net/jini/discovery/LookupUnmarshalException.java
    incubator/river/jtsk/trunk/src/net/jini/discovery/RemoteDiscoveryEvent.java
    incubator/river/jtsk/trunk/src/net/jini/io/MiToMoOutputStream.java
    incubator/river/jtsk/trunk/src/net/jini/lease/RenewalFailureEvent.java
    incubator/river/jtsk/trunk/src/net/jini/lookup/JoinManager.java
    incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java
    incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceRegistrarFacade.java
    incubator/river/jtsk/trunk/src/net/jini/lookup/StreamServiceRegistrarFacade.java
    incubator/river/jtsk/trunk/src/org/apache/river/api/security/ExecutionContextManager.java
    incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/ConcurrentPermissions.java
    incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/DynamicConcurrentPolicyProvider.java
    incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/ECM.java

Modified: incubator/river/jtsk/trunk/qa/build.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/qa/build.xml?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/qa/build.xml (original)
+++ incubator/river/jtsk/trunk/qa/build.xml Sun Aug 29 22:50:19 2010
@@ -271,7 +271,7 @@
         <!--<property name="run.tests" value="com/sun/jini/test/spec/policyprovider/policyFileProvider/NullPolicy.td"/>*pass*-->
         <!--<property name="run.tests" value="com/sun/jini/test/spec/joinmanager/GetDiscoveryManager.td"/>-->
         <!--<property name="run.tests" value="com/sun/jini/test/spec/joinmanager/TerminateDiscovery.td"/>-->
-        <property name="run.tests" value="com/sun/jini/test/impl/joinmanager/ZRegisterStorm.td"/>
+        <!--<property name="run.tests" value="com/sun/jini/test/impl/joinmanager/ZRegisterStorm.td"/>-->
         <!--<property name="run.tests" value="com/sun/jini/test/impl/joinmanager/LeaseRenewDurRFE.td"/>-->
         <!--<property name="run.tests" value="com/sun/jini/test/spec/policyprovider/dynamicPolicyProvider/GrantPrincipalSame.td"/>-->
         <!--<property name="run.tests" value="com/sun/jini/test/spec/policyprovider/dynamicPolicyProvider/GrantPrincipal.td"/>-->
@@ -279,9 +279,9 @@
         <!--<property name="run.tests" value="com/sun/jini/test/spec/loader/pref/preferredClassLoader/GetPermissionsSecurityException.td"/>-->
         <!--<property name="run.tests" value="com/sun/jini/test/spec/loader/pref/preferredClassProvider/LoadClassesSecurityExceptionHttpCann.td"/>-->
         <!--<property name="run.tests" value="com/sun/jini/test/spec/policyprovider/dynamicPolicyProvider/NullCases.td"/>-->
-        <!--<property name="run.tests" value=""/>-->
-        <!--<property name="run.tests" value=""/>-->
-        <!--<property name="run.tests" value=""/>-->
+        <!--<property name="run.tests" value="com/sun/jini/test/spec/policyprovider/revokableDynamicPolicyProvider/OptimisedPermissionCheck.td"/>-->
+        <!--<property name="run.tests" value="com/sun/jini/test/impl/servicediscovery/event/DiscardDownReDiscover.td"/>-->
+        <property name="run.tests" value="com/sun/jini/test/spec/servicediscovery/event/SetAttrServiceChanged.td"/>
         <!--<property name="run.tests" value=""/>-->
         <testrun>
             <!-- Run specific test(s) -->
@@ -298,7 +298,7 @@
         <!--<property name="test.categories" value="id,loader,policyprovider,locatordiscovery,activation,
         config,constraint,discoverymanager,discoveryservice,joinmanager,url,
         eventmailbox,jeri,iiop,jrmp,reliability,scalability,thread,renewalservice"/>-->
-        <property name="run.categories" value="loader"/>
+        <property name="run.categories" value="servicediscovery"/>
         <testrun>
              <!-- Run one or more test categories -->
             <arg value="-categories"/>

Modified: incubator/river/jtsk/trunk/src/com/sun/jini/lease/BasicRenewalFailureEvent.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/com/sun/jini/lease/BasicRenewalFailureEvent.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/com/sun/jini/lease/BasicRenewalFailureEvent.java (original)
+++ incubator/river/jtsk/trunk/src/com/sun/jini/lease/BasicRenewalFailureEvent.java Sun Aug 29 22:50:19 2010
@@ -110,13 +110,13 @@ public class BasicRenewalFailureEvent ex
      *        <code>null</code> in which case <code>getThrowable</code> will
      *        return <code>null</code>.
      */
-    public BasicRenewalFailureEvent(MarshalledInstance handback,
-                                    LeaseRenewalSet source, 
+    public BasicRenewalFailureEvent(LeaseRenewalSet source, 
 				    long seqNum,
+				    MarshalledInstance handback,
 				    MarshalledInstance marshalledLease,
 				    MarshalledInstance marshalledThrowable) 
     {
-	super(handback, source, seqNum);
+	super( source, seqNum, handback);
 	this.marshalledThrowable = marshalledThrowable;
 	this.marshalledLease = marshalledLease;
     }

Modified: incubator/river/jtsk/trunk/src/com/sun/jini/mahalo/JoinStateManager.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/com/sun/jini/mahalo/JoinStateManager.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/com/sun/jini/mahalo/JoinStateManager.java (original)
+++ incubator/river/jtsk/trunk/src/com/sun/jini/mahalo/JoinStateManager.java Sun Aug 29 22:50:19 2010
@@ -41,7 +41,6 @@ import net.jini.discovery.DiscoveryGroup
 import net.jini.discovery.LookupDiscoveryManager;
 import net.jini.id.Uuid;
 import net.jini.lookup.JoinManager;
-import net.jini.lookup.ServiceIDListener;
 import net.jini.security.ProxyPreparer;
 
 
@@ -50,7 +49,6 @@ import com.sun.jini.logging.Levels;
 import com.sun.jini.reliableLog.LogHandler;
 import com.sun.jini.reliableLog.ReliableLog;
 import net.jini.discovery.DiscoveryListenerManagement;
-import net.jini.io.MiToMoOutputStream;
 
 /**
  * <code>JoinStateManager</code> provides a utility that manages

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=990669&r1=990668&r2=990669&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 Sun Aug 29 22:50:19 2010
@@ -20,8 +20,12 @@ package net.jini.core.event;
 
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.ObjectStreamField;
+import java.rmi.MarshalledObject;
 import net.jini.io.Convert;
 import net.jini.io.MarshalledInstance;
 import net.jini.io.MiToMoOutputStream;
@@ -155,7 +159,11 @@ public class RemoteEvent extends java.ut
 	this.eventID = eventID;
 	this.seqNum = seqNum;
         Convert convert = Convert.getInstance();
-	this.handback = convert.toMarshalledInstance(handback);
+	if ( handback != null ){
+	    this.handback = convert.toMarshalledInstance(handback);
+	} else {
+	    this.handback = null;
+	}
     }
     /**
      * Constructs a RemoteEvent object.
@@ -175,7 +183,7 @@ public class RemoteEvent extends java.ut
      * @param handback  a <tt>MarshalledInstance</tt> that was passed in 
      *                  as part of the original event registration.
      */
-    public RemoteEvent(MarshalledInstance handback, Object source, long eventID,
+    public RemoteEvent( Object source, MarshalledInstance handback, long eventID,
             long seqNum ) {
 	super(source);
         this.source = source;
@@ -216,25 +224,36 @@ public class RemoteEvent extends java.ut
     @Deprecated
     public java.rmi.MarshalledObject getRegistrationObject() {
         Convert convert = Convert.getInstance();
-	return convert.toRmiMarshalledObject(handback);
+	if (handback != null) return convert.toRmiMarshalledObject(handback);
+	return null;
     }
     
     public MarshalledInstance getRegisteredObject() {
 	return handback;      
     }
-
+    
     /**
      * 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.
      */
     private void readObject(java.io.ObjectInputStream stream)
 	throws java.io.IOException, ClassNotFoundException
     {
-	ObjectInputStream newStream = new MoToMiInputStream(stream);
-        newStream.defaultReadObject();
+	if (stream instanceof MoToMiInputStream){
+	    stream.defaultReadObject();
+	    super.source = source;
+	    return;
+	}
+	MoToMiInputStream in = new MoToMiInputStream(stream);
+	RemoteEvent ev = (RemoteEvent) in.readObject();
+	this.source = ev.source;
 	super.source = source;
+	this.eventID = ev.eventID;
+	this.handback = ev.handback;
+	this.seqNum = ev.seqNum;	
     }
     
     /**
@@ -245,7 +264,19 @@ public class RemoteEvent extends java.ut
      * @throws java.io.IOException
      */
     private void writeObject(java.io.ObjectOutputStream stream) throws IOException{
-        ObjectOutputStream newOutStream = new MiToMoOutputStream(stream);
-        newOutStream.defaultWriteObject();
+	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=990669&r1=990668&r2=990669&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 Sun Aug 29 22:50:19 2010
@@ -85,14 +85,14 @@ public abstract class ServiceEvent exten
      * @param serviceID the serviceID of the item that triggered the event
      * @param transition the transition that triggered the event
      */
-    public ServiceEvent(MarshalledInstance handback,
-                        Object source,
+    public ServiceEvent(Object source,
 			long eventID,
 			long seqNo,
+			MarshalledInstance handback,
 			ServiceID serviceID,
 			int transition)
     {
-	super(handback, source, eventID, seqNo);
+	super(source, handback, eventID, seqNo);
 	this.serviceID = serviceID;
 	this.transition = transition;
     }

Modified: incubator/river/jtsk/trunk/src/net/jini/core/lookup/StreamServiceRegistrar.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/core/lookup/StreamServiceRegistrar.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/core/lookup/StreamServiceRegistrar.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/core/lookup/StreamServiceRegistrar.java Sun Aug 29 22:50:19 2010
@@ -77,10 +77,10 @@ public interface StreamServiceRegistrar 
      * @throws java.rmi.RemoteException
      * @since 2.2.0
      */
-    EventRegistration notify(MarshalledInstance handback,
+    public EventRegistration notify(
                              ServiceTemplate tmpl,
 			     int transitions,
-			     RemoteEventListener listener,
+			     RemoteEventListener listener,MarshalledInstance handback,
 			     long leaseDuration)
 	throws IOException;
 

Modified: incubator/river/jtsk/trunk/src/net/jini/discovery/LookupUnmarshalException.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/discovery/LookupUnmarshalException.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/discovery/LookupUnmarshalException.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/discovery/LookupUnmarshalException.java Sun Aug 29 22:50:19 2010
@@ -409,7 +409,7 @@ public class LookupUnmarshalException ex
     }
     
     public MarshalledInstance[] getMarshalledInstRegistrars(){
-        // Defensive copy.
+        // Defensive copy. TODO: Java 6 only method revise
          return Arrays.copyOf(marshalledRegistrars, marshalledRegistrars.length);
     }
     
@@ -499,32 +499,38 @@ public class LookupUnmarshalException ex
     private void readObject(ObjectInputStream s)  
                                throws IOException, ClassNotFoundException
     {
+	if (s instanceof MoToMiInputStream){
+	    s.defaultReadObject();
+	     /* Verify marshalledRegistrars and exceptions fields */
+	    if(marshalledRegistrars == null) {
+		throw new InvalidObjectException
+				("LookupUnmarshalException.readObject "
+				 +"failure - marshalledRegistrars field is null");
+	    }//endif
+	    if(exceptions == null) {
+		throw new InvalidObjectException
+					  ("LookupUnmarshalException.readObject "
+					   +"failure - exceptions field is null");
+	    }//endif
+	    if(marshalledRegistrars.length == 0) {
+		throw new InvalidObjectException
+				 ("LookupUnmarshalException.readObject "
+				  +"failure - marshalledRegistrars.length == 0");
+	    }//endif
+	    if(exceptions.length != marshalledRegistrars.length) {
+		throw new InvalidObjectException
+			       ("LookupUnmarshalException.readObject failure - "
+				+"exceptions.length ("+exceptions.length
+				+") is not equal to marshalledRegistrars.length "
+				+"("+marshalledRegistrars.length+")");
+	    }//endif
+	    return;
+	}
         ObjectInputStream fois = new MoToMiInputStream(s); // convert to java.rmi.MarshalledObject
-        fois.defaultReadObject();
-        /* Verify marshalledRegistrars and exceptions fields */
-        if(marshalledRegistrars == null) {
-            throw new InvalidObjectException
-                            ("LookupUnmarshalException.readObject "
-                             +"failure - marshalledRegistrars field is null");
-        }//endif
-        if(exceptions == null) {
-            throw new InvalidObjectException
-                                      ("LookupUnmarshalException.readObject "
-                                       +"failure - exceptions field is null");
-        }//endif
-        if(marshalledRegistrars.length == 0) {
-            throw new InvalidObjectException
-                             ("LookupUnmarshalException.readObject "
-                              +"failure - marshalledRegistrars.length == 0");
-        }//endif
-        if(exceptions.length != marshalledRegistrars.length) {
-            throw new InvalidObjectException
-                           ("LookupUnmarshalException.readObject failure - "
-                            +"exceptions.length ("+exceptions.length
-                            +") is not equal to marshalledRegistrars.length "
-                            +"("+marshalledRegistrars.length+")");
-        }//endif
-
+        LookupUnmarshalException lue = (LookupUnmarshalException) fois.readObject();
+	this.exceptions = lue.exceptions;
+	this.registrars = lue.registrars;
+	this.marshalledRegistrars = lue.marshalledRegistrars;
     }//end readObject
     
     /**
@@ -535,8 +541,12 @@ public class LookupUnmarshalException ex
      * @throws java.io.IOException
      */
     private void writeObject(java.io.ObjectOutputStream stream) throws IOException{
+	if (stream instanceof MiToMoOutputStream){
+	    stream.defaultWriteObject();	    
+	    return;
+	}
         ObjectOutputStream newOutStream = new MiToMoOutputStream(stream); // Convert from java.rmi.MarshalledObject
-        newOutStream.defaultWriteObject();
+        newOutStream.writeObject(this);
     }
 
 }//end class LookupUnmarshalException

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=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/discovery/RemoteDiscoveryEvent.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/discovery/RemoteDiscoveryEvent.java Sun Aug 29 22:50:19 2010
@@ -284,14 +284,14 @@ public class RemoteDiscoveryEvent extend
      *         when an empty set of registrars is input.
      */
 
-    public RemoteDiscoveryEvent(MarshalledInstance handback,
-                                Object source,
+    public RemoteDiscoveryEvent(Object source,
                                 long eventID,
                                 long seqNum,
+				MarshalledInstance handback,
                                 boolean discarded,
                                 Map groups)    throws IOException
     {
-	super(handback, source, eventID, seqNum);
+	super( source, handback, eventID, seqNum);
 	this.discarded = discarded;
         if(groups != null) {
             /* If the set of registrars is empty, throw exception */
@@ -701,15 +701,26 @@ public class RemoteDiscoveryEvent extend
     private void readObject(ObjectInputStream s)  
                                throws IOException, ClassNotFoundException
     {
-        ObjectInputStream fois = new MoToMiInputStream(s); // convert to java.rmi.MarshalledObject
-        fois.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);
+        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());
     }//end readObject
     
     /**
@@ -720,8 +731,12 @@ public class RemoteDiscoveryEvent extend
      * @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();
+        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/io/MiToMoOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/io/MiToMoOutputStream.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/io/MiToMoOutputStream.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/io/MiToMoOutputStream.java Sun Aug 29 22:50:19 2010
@@ -84,7 +84,7 @@ public MiToMoOutputStream(OutputStream o
                             Long moSuid = new Long(8988374069173025854L); //MarshalledObject serialVersionUID
                             fields[i].set(tempDesc, moSuid);
                             continue;
-                        }
+                        }   
                         Object fieldValue = fields[i].get(desc);
                         try {
                             fields[i].set(tempDesc, fieldValue);

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=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/lease/RenewalFailureEvent.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/lease/RenewalFailureEvent.java Sun Aug 29 22:50:19 2010
@@ -71,11 +71,11 @@ public abstract class RenewalFailureEven
      * @param seqNum the sequence number of this event
      * @param handback the client handback
      */
-    public RenewalFailureEvent(MarshalledInstance handback,
-                               LeaseRenewalSet  source, 
-			       long             seqNum)
+    public RenewalFailureEvent(LeaseRenewalSet  source, 
+			       long             seqNum,
+			       MarshalledInstance handback)
     {
-	super(handback, source, LeaseRenewalSet.RENEWAL_FAILURE_EVENT_ID, seqNum);
+	super( source,handback, LeaseRenewalSet.RENEWAL_FAILURE_EVENT_ID, seqNum);
     }
 
     /**

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=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/lookup/JoinManager.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/lookup/JoinManager.java Sun Aug 29 22:50:19 2010
@@ -442,13 +442,18 @@ import org.apache.river.api.util.Facade;
  */
 public class JoinManager {
     
+    @SuppressWarnings("deprecation")
     private static void discard(DiscoveryListenerManagement dlm, 
             PortableServiceRegistrar proxy, Logger logger){
         try {
             if (dlm instanceof RegistrarManagement){
                 RegistrarManagement rm = (RegistrarManagement) dlm;
                 rm.discard(proxy);
-            } else {
+            } else if ( dlm instanceof DiscoveryManagement 
+		    && proxy instanceof ServiceRegistrar) {
+		DiscoveryManagement dm = (DiscoveryManagement) dlm;
+		dm.discard((ServiceRegistrar) proxy);
+	    } else {
                 throw new UnsupportedOperationException("Not instance of " +
                         "RegistrarManagement");
             }

Modified: incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java Sun Aug 29 22:50:19 2010
@@ -21,6 +21,7 @@ import com.sun.jini.logging.Levels;
 import com.sun.jini.lookup.entry.LookupAttributes;
 import com.sun.jini.proxy.BasicProxyTrustVerifier;
 import com.sun.jini.thread.TaskManager;
+import com.sun.jini.thread.TaskManager.Task;
 
 import net.jini.config.Configuration;
 import net.jini.config.ConfigurationException;
@@ -52,12 +53,15 @@ import net.jini.core.lookup.ServiceID;
 import net.jini.core.lookup.ServiceEvent;
 import net.jini.core.lookup.ServiceItem;
 import net.jini.core.lookup.ServiceMatches;
+import net.jini.core.lookup.ServiceRegistrar;
 import net.jini.core.lookup.ServiceTemplate;
 
 import java.io.IOException;
 
 import java.rmi.RemoteException;
 import java.rmi.server.ExportException;
+import java.rmi.server.RemoteObject;
+import java.rmi.server.UnicastRemoteObject;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -69,11 +73,9 @@ import java.util.Map;
 import java.util.Random;
 import java.util.Set;
 import net.jini.core.lookup.PortableServiceRegistrar;
-import net.jini.core.lookup.ServiceRegistrar;
 import net.jini.core.lookup.StreamServiceRegistrar;
 import net.jini.discovery.DiscoveryListenerManagement;
 import net.jini.discovery.RegistrarManagement;
-import org.apache.river.api.util.Facade;
 
 /**
  * The <code>ServiceDiscoveryManager</code> class is a helper utility class
@@ -325,7 +327,7 @@ import org.apache.river.api.util.Facade;
  *            this utility, and not by the utility itself.
  * </table>
  *
- * <a name="getDiscoveryListenerManager">
+ * <a name="discoveryManager">
  * <table summary="Describes the discoveryManager configuration entry" 
  *                border="0" cellpadding="2">
  *   <tr valign="top">
@@ -602,7 +604,7 @@ import org.apache.river.api.util.Facade;
  * @see net.jini.lookup.LookupCache
  * @see net.jini.lookup.ServiceDiscoveryListener
  * @see net.jini.lookup.ServiceDiscoveryEvent
- * @see net.jini.core.lookup.PortableServiceRegistrar
+ * @see net.jini.core.lookup.ServiceRegistrar
  */
 public class ServiceDiscoveryManager {
 
@@ -666,6 +668,7 @@ public class ServiceDiscoveryManager {
          *  @param tasks the tasks to consider.
          *  @param size elements with index less than size are considered.
          */
+	@Override
         public boolean runAfter(List tasks, int size) {
             for(int i=0; i<size; i++) {
                 TaskManager.Task t = (TaskManager.Task)tasks.get(i);
@@ -694,7 +697,7 @@ public class ServiceDiscoveryManager {
     private final static class ServiceDiscoveryListenerImpl 
                                           implements ServiceDiscoveryListener
     {
-	ArrayList items = new ArrayList(1);
+	ArrayList<ServiceItem> items = new ArrayList<ServiceItem>(1);
 	public synchronized void serviceAdded(ServiceDiscoveryEvent event) {
 	    items.add(event.getPostEventServiceItem());
 	    this.notifyAll();
@@ -743,9 +746,11 @@ public class ServiceDiscoveryManager {
      * track where the ServiceItem comes from.
      */
     private final static class ServiceItemReg  {
-	/* Stores ServiceRegistrars that has the ServiceItem registered. */
-	private final ArrayList<PortableServiceRegistrar> proxys = 
-                new ArrayList<PortableServiceRegistrar>(1);
+	/* Maps ServiceRegistrars to their latest registered item */
+	private final Map<PortableServiceRegistrar, ServiceItem> items =
+		new HashMap<PortableServiceRegistrar, ServiceItem>();
+	/* The ServiceRegistrar currently being used to track changes */
+	private volatile PortableServiceRegistrar proxy;
 	/* Flag that indicates that the ServiceItem has been discarded. */
 	private boolean bDiscarded = false;
         /* The discovered service, prior to filtering. */
@@ -756,28 +761,42 @@ public class ServiceDiscoveryManager {
          * lookup service proxy.
          */
 	public ServiceItemReg(PortableServiceRegistrar proxy, ServiceItem item) {
-	    addProxy(proxy);
+	    this.proxy = proxy;
+	    addProxy(proxy, item);
 	    this.item = item;
 	}  
-	/* Adds the given proxy to the 'id-to-itemReg' map. This method is
+	/* Adds the given proxy to the 'proxy-to-item' map. This method is
          * called from this class' constructor, LookupTask, NotifyEventTask,
-         * and ProxyRegDropTask.
+         * and ProxyRegDropTask.  Returns true if the proxy is being used
+	 * to track changes, false otherwise.
          */
-	public void addProxy(PortableServiceRegistrar proxy) {
-	    if(!proxys.contains(proxy))  proxys.add(proxy);
+	public boolean addProxy(PortableServiceRegistrar proxy, ServiceItem item) {
+	    items.put(proxy, item);
+	    return proxy.equals(this.proxy);
 	}
-	/* Removes the given proxy from the 'id-to-itemReg' map. This method
-         * is called from NotifyEventTask and ProxyRegDropTask.
-         */
-	public void removeProxy(PortableServiceRegistrar proxy) {
-	    int index = proxys.indexOf(proxy);
-	    if(index != -1)  proxys.remove(index);
+	/* Removes the given proxy from the 'proxy-to-item' map. This method
+         * is called from NotifyEventTask and ProxyRegDropTask.  If this proxy
+	 * was being used to track changes, then pick a new one and return
+	 * its current item, else return null.
+         */
+	public ServiceItem removeProxy(PortableServiceRegistrar proxy) {
+	    items.remove(proxy);
+	    if (proxy.equals(this.proxy)) {
+		if (items.isEmpty()) {
+		    this.proxy = null;
+		} else {
+		    Map.Entry ent = (Map.Entry) items.entrySet().iterator().next();
+		    this.proxy = (PortableServiceRegistrar) ent.getKey();
+		    return (ServiceItem) ent.getValue();
+		}//endif
+	    }//endif
+	    return null;
 	}
-	/* Determines if the 'id-to-itemReg' map contains any mappings.
+	/* Determines if the 'proxy-to-item' map contains any mappings.
          * This method is called from NotifyEventTask and ProxyRegDropTask.
          */
 	public boolean hasNoProxys() {
-	    return proxys.isEmpty();
+	    return items.isEmpty();
 	}
 	/* Marks the ServiceItem as discarded. */ 
 	public void setDiscarded(boolean b) {
@@ -791,14 +810,10 @@ public class ServiceDiscoveryManager {
 
     /** A wrapper class for a ServiceRegistrar. */
     private final static class ProxyReg  {
-	public PortableServiceRegistrar proxy;
-	public ProxyReg(PortableServiceRegistrar proxy) {
+	public ServiceRegistrar proxy;
+	public ProxyReg(ServiceRegistrar proxy) {
 	    if(proxy == null)  throw new IllegalArgumentException
                                                      ("proxy cannot be null");
-            // Unwrap any facades.
-            while ( proxy instanceof Facade){
-                proxy = (PortableServiceRegistrar) ((Facade)proxy).reveal();
-            }
 	    this.proxy = proxy;
 	}//end constructor	    
 
@@ -990,10 +1005,6 @@ public class ServiceDiscoveryManager {
                         cacheTaskMgr.add(t);
                     }//end loop
                     /* 3. Handle events that came in prior to lookup */
-                    /* Fix provided by Bob Scheifler to JIRA [#RIVER-324] fix
-                     * to assign new task sequence numbers, to pending events
-                     * added to cacheTaskMgr.
-                     */ 
                     eReg.lookupsPending--;
 		    for (iter = eReg.pending.iterator(); iter.hasNext(); ) {
 			NotifyEventTask t = (NotifyEventTask) iter.next();
@@ -1024,6 +1035,7 @@ public class ServiceDiscoveryManager {
              *  @param tasks the tasks to consider.
              *  @param size elements with index less than size are considered.
              */
+	    @Override
             public boolean runAfter(List tasks, int size) {
                 for(int i=0; i<size; i++) {
                     CacheTask t = (CacheTask)tasks.get(i);
@@ -1083,33 +1095,18 @@ public class ServiceDiscoveryManager {
             }//end run
 	}//end class LookupCacheImpl.ProxyRegDropTask
 
-	/** Task class used to asynchronously discard the given service. */
+	/** Task class used to asynchronously notify service discard. */
         private final class DiscardServiceTask extends CacheTask {
-	    private Object service;
-                public DiscardServiceTask(Object service) {
+	    private final ServiceItem item;
+                public DiscardServiceTask(ServiceItem item) {
                 super(null, 0);
-		this.service = service;
+		this.item = item;
 	    }
 
             public void run() {
                 logger.finest("ServiceDiscoveryManager - DiscardServiceTask "
                               +"started");
-		Iterator iter = getServiceIdMapEntrySetIterator();
-		while(iter.hasNext()) {
-		    Map.Entry e = (Map.Entry)iter.next();
-		    ServiceItemReg itemReg = (ServiceItemReg)e.getValue();
-                    ServiceItem item;
-                    synchronized(itemReg) {
-                        item = itemReg.filteredItem;
-                    }//end sync(itemReg)
-		    if( (item.service).equals(service) ) {
-			ServiceID sid = (ServiceID)e.getKey();
                         removeServiceNotify(item);
-                        serviceDiscardTimerTaskMgr.add
-                                         ( new ServiceDiscardTimerTask(sid) );
-			return;
-		    }//endif
-		}//end loop
                 logger.finest("ServiceDiscoveryManager - DiscardServiceTask "
                               +"completed");
             }//end run
@@ -1236,9 +1233,11 @@ public class ServiceDiscoveryManager {
          */
         private final class ServiceDiscardTimerTask implements TaskManager.Task
         {
-            private ServiceID serviceID;
+            private final ServiceID serviceID;
+	    private final long endTime;
             public ServiceDiscardTimerTask(ServiceID serviceID) {
                 this.serviceID = serviceID;
+                this.endTime = discardWait+System.currentTimeMillis();
             }//end constructor
             public void run(){
                 logger.finest("ServiceDiscoveryManager - "
@@ -1254,9 +1253,7 @@ public class ServiceDiscoveryManager {
                 synchronized(serviceIdMap) {
                     if(!serviceIdMap.containsKey(serviceID))  return;
                 }//end sync(serviceIdMap)
-                /* Default to twice the (common) 5 minute max lease duration */
-                long curDur = discardWait;
-                long endTime = curDur+System.currentTimeMillis();
+                long curDur = endTime-System.currentTimeMillis();
                 synchronized(serviceDiscardMutex) {
                     /* Wait until interrupted or time expires */
                     while(curDur > 0) {
@@ -1313,6 +1310,7 @@ public class ServiceDiscoveryManager {
                     ServiceItem item = null;
                     ServiceItem filteredItem = null;
                     synchronized(itemReg) {
+			if(!itemReg.isDiscarded()) return;
                         if(itemReg.filteredItem == null) {
                             item = new ServiceItem
                                               ( (itemReg.item).serviceID,
@@ -1419,15 +1417,11 @@ public class ServiceDiscoveryManager {
             public void run() {
                 logger.finest("ServiceDiscoveryManager - NewOldServiceTask "
                               +"started");
+		boolean changed = false;
                 ServiceItemReg itemReg;
                 synchronized(serviceIdMap) {
                     itemReg = (ServiceItemReg)serviceIdMap.get(thisTaskSid);
-                }//end sync(serviceIdMap)
-                if(itemReg != null) {//a. old, previously discovered item
-                    itemMatchMatchChange(reg.proxy, srvcItem,
-                                         itemReg, matchMatchEvent);
-                } else {//(itemReg == null) ==> b. newly discovered item
-                    synchronized(serviceIdMap) {
+		    if (itemReg == null) {
                         if( !eventRegMap.containsKey(reg) ) {
                             /* reg must have been discarded, simply return */
                             logger.finest("ServiceDiscoveryManager - "
@@ -1436,7 +1430,14 @@ public class ServiceDiscoveryManager {
                         }//endif
                         itemReg = new ServiceItemReg( reg.proxy, srvcItem );
                         serviceIdMap.put( thisTaskSid, itemReg );
+		    } else {
+			changed = true;
+		    }
                     }//end sync(serviceIdMap)
+                if(changed) {//a. old, previously discovered item
+                    itemMatchMatchChange(reg.proxy, srvcItem,
+                                         itemReg, matchMatchEvent);
+                } else {//b. newly discovered item
                     ServiceItem newFilteredItem =
                                   filterMaybeDiscard(srvcItem,reg.proxy,false);
                     if(newFilteredItem != null) {
@@ -1493,14 +1494,21 @@ public class ServiceDiscoveryManager {
             public void run() {
                 logger.finest("ServiceDiscoveryManager - UnmapProxyTask "
                               +"started");
-                ServiceItem item = null;
+		PortableServiceRegistrar proxy = null;
+                ServiceItem item;
                 synchronized(itemReg) {
-                    itemReg.removeProxy(reg.proxy);//disassociate the LUS
-                    if( itemReg.hasNoProxys() ) {//no more LUSs, remove map
+                    item = itemReg.removeProxy(reg.proxy);//disassociate the LUS
+		    if (item != null) {// new LUS chosen to track changes
+			proxy = itemReg.proxy;
+		    } else if( itemReg.hasNoProxys() ) {//no more LUSs, remove from map
                         item = itemReg.filteredItem;
                     }//endif
                 }//end sync(itemReg)
-                if(item != null) removeServiceIdMap(thisTaskSid,item);
+		if(proxy != null) {
+		    itemMatchMatchChange(proxy, item, itemReg, false);
+		} else if(item != null) {
+		    removeServiceIdMap(thisTaskSid,item);
+		}//endif
                 logger.finest("ServiceDiscoveryManager - UnmapProxyTask "
                               +"completed");
             }//end run
@@ -1652,20 +1660,24 @@ public class ServiceDiscoveryManager {
 	    while(iter.hasNext()) {
 		Map.Entry e = (Map.Entry)iter.next();
 		ServiceItemReg itemReg = (ServiceItemReg)e.getValue();
+		ServiceItem filteredItem;
 		synchronized(itemReg) {
-                    if((itemReg.filteredItem.service).equals(serviceReference))
+		    filteredItem = itemReg.filteredItem;
+                    if((filteredItem.service).equals(serviceReference))
                     {
                         if( itemReg.isDiscarded() ) return;//already discarded
                         itemReg.setDiscarded(true);
                         discardIt = true;
-                        break;
                     }//endif
 		}//end sync(itemReg)
-	    }//end loop
             if(discardIt) {
-                CacheTask t = new DiscardServiceTask(serviceReference);
-                cacheTaskMgr.add(t);
+		    ServiceID sid = (ServiceID)e.getKey();
+		    serviceDiscardTimerTaskMgr.add
+                                     ( new ServiceDiscardTimerTask(sid) );
+		    cacheTaskMgr.add(new DiscardServiceTask(filteredItem));
+		    return;
             }//endif
+	    }//end loop
 	}//end LookupCacheImpl.discard
 
 	/* Returns the iterator of entry set in the copy of the ServiceIdMap */
@@ -1858,16 +1870,6 @@ public class ServiceDiscoveryManager {
 				      int transition)
         {
             if(eventSource == null) return;
-
-            if (logger.isLoggable(Level.FINEST)) {
-                if( (item != null) && (item.attributeSets != null) ) {
-                    for(int i=0; i<(item.attributeSets).length; i++) {
-                        logger.finest("notifyServiceMap - attribute["+i+"] = "
-                                      +(item.attributeSets)[i]);
-                    }//end loop
-                }//endif
-            }//endif(FINEST)
-
             synchronized(serviceIdMap) {
                 /* Search eventRegMap for ProxyReg corresponding to event. */
                 ProxyReg reg = null;
@@ -1893,12 +1895,12 @@ public class ServiceDiscoveryManager {
                 if(seqNo == (prevSeqNo+1)) {//no gap, handle current event
                     t = new NotifyEventTask
                                     (reg, sid, item, transition, taskSeqN++);
-                    if(eReg.lookupsPending > 0) {
+		    if (eReg.lookupsPending > 0) {
                         eReg.pending.add(t);
                         return;
-                    }//endif
-                } else if(eReg.lookupsPending > 1) {
-                    //gap in event sequence, but snapshot already pending
+		    }
+		} else if (eReg.lookupsPending > 1) {
+		    // gap in event sequence, but snapshot already pending
                     return;
                 } else {//gap in event sequence, request snapshot
                     eReg.lookupsPending++;
@@ -2070,23 +2072,28 @@ public class ServiceDiscoveryManager {
              */
 	    ServiceItem oldItem;
 	    ServiceItem oldFilteredItem;
+	    boolean itemRegIsDiscarded;
 	    synchronized(itemReg) {
+		itemRegIsDiscarded = itemReg.isDiscarded();
+                if(!itemReg.addProxy(proxy, newItem)) { // not tracking
+		    if(matchMatchEvent || !itemRegIsDiscarded) return;
+		    itemReg.proxy = proxy; // start tracking instead
+		}//endif
                 oldItem = itemReg.item;
                 oldFilteredItem = itemReg.filteredItem;
-		if(itemReg.isDiscarded()) {
+		if(itemRegIsDiscarded) {
                     itemReg.item = newItem;//capture changes for discard
                     itemReg.filteredItem = null;//so filter will be retried
-                    return;
+                    if(matchMatchEvent) return;
                 }//endif
-                itemReg.addProxy(proxy);
 	    }//end sync(itemReg)
             /* For an explanation of the logic of the following if-else-block,
              * refer to the method description above.
              */
             boolean attrsChanged = false;
             boolean versionChanged = false;
-            boolean isSameVersion = sameVersion(newItem,oldItem);
-            if( matchMatchEvent || isSameVersion ) {
+	    if( matchMatchEvent || sameVersion(newItem,oldItem) ) {
+		if(itemRegIsDiscarded) return;
                 /* Same version, determine if the attributes have changed.
                  * But first, replace the new service proxy with the old
                  * service proxy so the client always uses the old proxy
@@ -2096,73 +2103,23 @@ public class ServiceDiscoveryManager {
                 /* Now compare attributes */
                 attrsChanged = !LookupAttributes.equal(newItem.attributeSets,
                                                        oldItem.attributeSets);
-                if (logger.isLoggable(Level.FINEST)) {
-                    if((oldItem != null) && (oldItem.attributeSets != null)) {
-                        for(int i=0; i<(oldItem.attributeSets).length; i++) {
-                            logger.finest("itemMatchMatchChange - "
-                                          +"OLD Attribute["+i+"] = "
-                                          +(oldItem.attributeSets)[i]);
-                        }//end loop
-                    }//endif
-                    logger.finest("    ");
-                    if((newItem != null) && (newItem.attributeSets != null)) {
-                        for(int i=0; i<(newItem.attributeSets).length; i++) {
-                            logger.finest("itemMatchMatchChange - "
-                                          +"NEW Attribute["+i+"] = "
-                                          +(newItem.attributeSets)[i]);
-                        }//end loop
-                    }//endif
-                }//endif(FINEST)
-
-                if (logger.isLoggable(Level.FINER)) {
-                    if(attrsChanged) {
-                        if(matchMatchEvent) {
-                            logger.finer("itemMatchMatchChange - attributes "
-                                         +"changed [TRANSITION_MATCH_MATCH]");
-                        } else if( isSameVersion ) {
-                            logger.finer("ServiceDiscoveryManager."
-                                         +"itemMatchMatchChange - attributes "
-                                         +"changed [same version]");
-                        }//endif
-                    } else {//(!attrChanged)
-                        if(matchMatchEvent) {
-                            logger.finer("itemMatchMatchChange - "
-                                         +"attributes NOT changed ["
-                                         +"TRANSITION_MATCH_MATCH] ..."
-                                         +"return");
-                        } else if( isSameVersion ) {
-                            logger.finer("itemMatchMatchChange - "
-                                         +"attributes NOT changed [same"
-                                         +"version] ... return");
-                        }//endif
-                    }//endif
-                }//endif
-
                 if(!attrsChanged) return;//no change, no need to filter
             } else {//(!matchMatchEvent && !same version) ==> re-registration
                 versionChanged = true;
-                logger.finer("itemMatchMatchChange - version changed");
             }//endif
             /* Now apply the filter, and send events if appropriate */
-            ServiceItem newFilteredItem = filterMaybeDiscard
-                                                       (newItem, proxy, true);
+            ServiceItem newFilteredItem =
+		filterMaybeDiscard(newItem, proxy, !itemRegIsDiscarded);
             if(newFilteredItem != null) {
                 /* Passed the filter, okay to send event(s). */
-                if(attrsChanged) {
-                    logger.finer("itemMatchMatchChange - send serviceChanged");
-                    changeServiceNotify(newFilteredItem,
+                if(attrsChanged) changeServiceNotify(newFilteredItem,
                                         oldFilteredItem);
-                }//endif
-
                 if(versionChanged) {
-                    logger.finer("itemMatchMatchChange - send serviceRemoved");
+                    if (!itemRegIsDiscarded) {
                     removeServiceNotify(oldFilteredItem);
-                    logger.finer("itemMatchMatchChange - send serviceAdded");
+		    }//endif
                     addServiceNotify(newFilteredItem);
                 }//endif
-            } else {
-                logger.finer("ServiceDiscoveryManager.itemMatchMatchChange - "
-                             +"NULL returned by filter");
             }//endif
 	}//end LookupCacheImpl.itemMatchMatchChange
 
@@ -2361,7 +2318,12 @@ public class ServiceDiscoveryManager {
                         }//end sync(itemReg)
                         removeServiceIdMap(srvcID, oldFilteredItem);
                     } else {
+			boolean itemRegIsDiscarded;
+                        synchronized(itemReg) {
+			    itemRegIsDiscarded = itemReg.isDiscarded();
+                        }//end sync(itemReg)
                         removeServiceIdMapSendNoEvent(srvcID);
+			if(itemRegIsDiscarded) cancelDiscardTask(srvcID);
                     }//endif
                 }//endif
                 return null;
@@ -2394,10 +2356,15 @@ public class ServiceDiscoveryManager {
                 itemReg = (ServiceItemReg)serviceIdMap.get(item.serviceID);
             }//end sync(serviceIdMap)
             if(itemReg == null)  return;
+	    boolean itemRegIsDiscarded;
             synchronized(itemReg) {
                 itemReg.item = item;
                 itemReg.filteredItem = filteredItem;
+		if(itemRegIsDiscarded = itemReg.isDiscarded()) {
+		    itemReg.setDiscarded(false);
+		}//endif
             }//end sync(itemReg)
+	    if(itemRegIsDiscarded) cancelDiscardTask(item.serviceID);
         }//end LookupCacheImpl.addFilteredItemToMap
 
 	/** Convenience method called by <code>filterMaybeDiscard</code>
@@ -2432,9 +2399,9 @@ public class ServiceDiscoveryManager {
                 }//endif
                 itemReg.setDiscarded(true);
             }//end sync(itemReg)
-            if(sendEvent)  removeServiceNotify(oldFilteredItem);
             serviceDiscardTimerTaskMgr.add
                               ( new ServiceDiscardTimerTask(item.serviceID) );
+            if(sendEvent)  removeServiceNotify(oldFilteredItem);
         }//end LookupCacheImpl.discardRetryLater
 
 	/** Convenience method called by <code>NotifyEventTask.run</code> (only
@@ -2452,35 +2419,47 @@ public class ServiceDiscoveryManager {
                 itemReg = (ServiceItemReg)serviceIdMap.get(srvcID);
             }//end sync(serviceIdMap)
             if(itemReg != null) {
+		ServiceItem newItem;
                 boolean itemRegHasNoProxys;
                 boolean itemRegIsDiscarded;
                 ServiceItem filteredItem;
                 synchronized(itemReg) {
-                    itemReg.removeProxy(proxy);
+                    newItem = itemReg.removeProxy(proxy);
                     itemRegHasNoProxys = itemReg.hasNoProxys();
                     itemRegIsDiscarded = itemReg.isDiscarded();
                     filteredItem = itemReg.filteredItem;
                 }//end sync(itemReg)
-                if(itemRegHasNoProxys) {
+		if(newItem != null) {
+		    itemMatchMatchChange(itemReg.proxy, newItem, itemReg,
+					 false);
+                } else if(itemRegHasNoProxys) {
                     if(itemRegIsDiscarded) {
                         /* Remove item from map and wake up the discard task */
-                        logger.finer("handleMatchNoMatch - "
-                                     +"TRANSITION_MATCH_NOMATCH && service in "
-                                     +"discard queue - send NO event");
                         removeServiceIdMapSendNoEvent(srvcID);
-                        synchronized(serviceDiscardMutex) {
-                            serviceDiscardMutex.notifyAll();
-                        }//end sync
+			cancelDiscardTask(srvcID);
                     } else {//remove item from map and send removed event
-                        logger.finer("handleMatchNoMatch - "
-                                     +"TRANSITION_MATCH_NOMATCH - send "
-                                     +"serviceRemoved");
                         removeServiceIdMap(srvcID, filteredItem);
                     }//endif
                 }//endif
             }//endif
         }//end LookupCacheImpl.handleMatchNoMatch
 
+	/** Wake up service discard task if running, else remove from mgr. */
+	private void cancelDiscardTask(ServiceID sid) {
+	    Iterator iter = serviceDiscardTimerTaskMgr.getPending().iterator();
+	    while (iter.hasNext()) {
+		ServiceDiscardTimerTask t =
+		    (ServiceDiscardTimerTask)iter.next();
+		if (sid.equals(t.serviceID)) {
+		    if(serviceDiscardTimerTaskMgr.removeIfPending(t)) return;
+		    break;
+		}//endif
+	    }//end loop
+	    synchronized(serviceDiscardMutex) {
+		serviceDiscardMutex.notifyAll();
+	    }//end sync
+	}//end LookupCacheImpl.cancelDiscardTask
+
     }//end class ServiceDiscoveryManager.LookupCacheImpl
     
     /* Name of this component; used in config entry retrieval and the logger.*/
@@ -2525,14 +2504,14 @@ public class ServiceDiscoveryManager {
     private class DiscMgrListener implements DiscoveryListener {
 	/* New or previously discarded proxy has been discovered. */
 	public void discovered(DiscoveryEvent e) {
-	    PortableServiceRegistrar[] proxys = (PortableServiceRegistrar[])e.getPRegistrars();
+	    ServiceRegistrar[] proxys = (ServiceRegistrar[])e.getRegistrars();
 	    ArrayList newProxys = new ArrayList(1);
 	    ArrayList notifies  = null;
 	    for(int i=0; i<proxys.length; i++) {
                 /* Prepare each lookup service proxy before using it. */
                 try {
                     proxys[i]
-                          = (PortableServiceRegistrar)registrarPreparer.prepareProxy
+                          = (ServiceRegistrar)registrarPreparer.prepareProxy
                                                                    (proxys[i]);
                     logger.log(Level.FINEST, "ServiceDiscoveryManager - "
                               +"discovered lookup service proxy prepared: {0}",
@@ -2565,7 +2544,7 @@ public class ServiceDiscoveryManager {
 
 	/* Previously discovered proxy has been discarded. */
 	public void discarded(DiscoveryEvent e) {
-	   PortableServiceRegistrar[] proxys = e.getPRegistrars();
+	    ServiceRegistrar[] proxys = (ServiceRegistrar[])e.getRegistrars();
 	    ArrayList notifies;
 	    ArrayList drops = new ArrayList(1);
 	    synchronized(proxyRegSet) {
@@ -2575,10 +2554,7 @@ public class ServiceDiscoveryManager {
 			proxyRegSet.remove(proxyRegSet.indexOf(reg));
 			drops.add(reg);
 		    } else {
-			//throw new RuntimeException("discard error");
-                        if (logger.isLoggable(Level.WARNING)){
-                            logger.log(Level.WARNING, COMPONENT_NAME, "River-337");
-                        }
+			throw new RuntimeException("discard error");
                     }//endif
 		}//end loop
 	    }//end sync(proxyRegSet)
@@ -2665,7 +2641,7 @@ public class ServiceDiscoveryManager {
      * remote listener, <i>it is the entity's responsibility</i> to provide a
      * mechanism for any lookup service to acquire the proxy to the exported
      * listener. One way to do this is to configure this utility to export
-     * the listener using the Jini Extensible Remote Invocation (Jini ERI)
+     * the listener using the Jini(TM) Extensible Remote Invocation (Jini ERI)
      * communication framework. When the listener is exported to use Jini ERI,
      * and no proxy customizations (such as a custom invocation handler or
      * transport endpoint) are used, no other action is necessary to make the
@@ -2861,9 +2837,7 @@ public class ServiceDiscoveryManager {
      * @see net.jini.core.lookup.ServiceRegistrar
      * @see net.jini.config.Configuration
      * @see net.jini.config.ConfigurationException
-     * @deprecated 
      */
-    @Deprecated
     public ServiceDiscoveryManager(DiscoveryManagement discoveryMgr,
                                    LeaseRenewalManager leaseMgr,
                                    Configuration config)
@@ -2896,8 +2870,7 @@ public class ServiceDiscoveryManager {
 	Iterator iter = notifies.iterator();
 	while (iter.hasNext()) {
 	    DiscoveryEvent evt = new DiscoveryEvent
-                                        ( this,
-                                          (PortableServiceRegistrar[])proxys.clone() );
+                                        ( this,proxys.clone() );
 	    ((DiscoveryListener)iter.next()).discarded(evt);
 	}//end loop
     }//end listenerDropped
@@ -3231,6 +3204,7 @@ public class ServiceDiscoveryManager {
      *
      *  @return DiscoveryManagement implementation
      *  @see net.jini.discovery.DiscoveryManagement
+     * @deprecated 
      */
     @Deprecated
     public DiscoveryManagement getDiscoveryManager() {
@@ -3409,7 +3383,7 @@ public class ServiceDiscoveryManager {
         /* retrieve the lookup service(s) to query for matching service(s) */
 	PortableServiceRegistrar[] proxys;
 	synchronized(proxyRegSet) {
-	    proxys = buildServiceRegistrar();
+	    proxys =  buildServiceRegistrar();
 	}
 	int len = proxys.length;
 	ArrayList sItemSet = new ArrayList(len);
@@ -3693,10 +3667,7 @@ public class ServiceDiscoveryManager {
     }//end createLookupCache
 
     /** Returns element from proxyRegSet that corresponds to the given proxy.*/
-    private ProxyReg findReg(PortableServiceRegistrar proxy) {
-        if (proxy instanceof Facade){
-            proxy = (PortableServiceRegistrar) ((Facade)proxy).reveal();
-        }
+    private ProxyReg findReg(ServiceRegistrar proxy) {
 	Iterator iter = proxyRegSet.iterator();
 	while(iter.hasNext()) {
 	    ProxyReg reg =(ProxyReg)iter.next();
@@ -3761,18 +3732,15 @@ public class ServiceDiscoveryManager {
 
     /** Discards a ServiceRegistrar through the discovery manager.*/
     private void discard(PortableServiceRegistrar proxy) {
-        if (discMgr instanceof RegistrarManagement){
+        if (discMgr instanceof RegistrarManagement){ // which it should be.
             RegistrarManagement dm = (RegistrarManagement) discMgr;
             dm.discard(proxy);
         } 
         // This will need to be commented out for Java cdc Personal Basis Profile
         else if (discMgr instanceof DiscoveryManagement){
             DiscoveryManagement dm = (DiscoveryManagement) discMgr;
-            if (proxy instanceof ServiceRegistrar){
-                ServiceRegistrar prxy = (ServiceRegistrar) proxy;
-                dm.discard(prxy);
+	    dm.discard( (ServiceRegistrar) proxy);           
             }
-        }
     }//end discard
 
     /** Cancels the given event lease. */
@@ -3808,7 +3776,7 @@ public class ServiceDiscoveryManager {
                            | PortableServiceRegistrar.TRANSITION_MATCH_NOMATCH
                            | PortableServiceRegistrar.TRANSITION_MATCH_MATCH   );
         if (proxy instanceof StreamServiceRegistrar){
-            e = ((StreamServiceRegistrar)proxy).notify(null, tmpl, transition, listenerProxy, duration);
+            e = ((StreamServiceRegistrar)proxy).notify( tmpl, transition, listenerProxy, null, duration);
         }
         try {
             // This should be the only occurrance of ServiceRegistrar in this class.
@@ -3893,14 +3861,6 @@ public class ServiceDiscoveryManager {
 	return false;
     }//end isArrayContainsServiceItems
     
-//    private void init(DiscoveryManagement discoveryMgr,
-//                      LeaseRenewalManager leaseMgr,
-//                      Configuration config)
-//                                    throws IOException, ConfigurationException
-//    {
-//        init(discoveryMgr, leaseMgr, config);
-//    }
-
     /* Convenience method that encapsulates the retrieval of the configurable
      * items from the given <code>Configuration</code> object.
      */
@@ -3947,15 +3907,26 @@ public class ServiceDiscoveryManager {
 	if(discMgr == null) {
 	    discMgrInternal = true;
             try {
-                // All Discovery Managers Must implement RegistrarManagement
+                // Old DiscoverManagement interface.
                 discMgr = (DiscoveryListenerManagement) thisConfig.getEntry(
                                     COMPONENT_NAME,
                                     "discoveryManager",
-                                    DiscoveryListenerManagement.class);
+                                    DiscoveryManagement.class);
+	    } catch(NoSuchEntryException ex) {
+		try {
+		    // All new Discovery Managers Must implement RegistrarManagement
+		    // I'm not entirely happy with the name, perhaps it shoud
+		    // be discoveryManager2?  or something?
+		    discMgr = (DiscoveryListenerManagement) thisConfig.getEntry(
+				    COMPONENT_NAME,
+						    "registrarManager",
+				    RegistrarManagement.class);
+		
             } catch(NoSuchEntryException e) { /* use default */
                 discMgr = new LookupDiscoveryManager
                                    (new String[] {""}, null, null, thisConfig);
             }
+            }
 	}//endif
 	discMgr.addDiscoveryListener(discMgrListener); 
     }//end init

Modified: incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceRegistrarFacade.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceRegistrarFacade.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceRegistrarFacade.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceRegistrarFacade.java Sun Aug 29 22:50:19 2010
@@ -58,7 +58,7 @@ public class ServiceRegistrarFacade impl
                 @SuppressWarnings(value = "unchecked")
                 MarshalledInstance hback = convert.toMarshalledInstance(handback);
                 StreamServiceRegistrar ssr = (StreamServiceRegistrar) sr;
-                return ssr.notify(hback, tmpl, transitions, listener, leaseDuration);
+                return ssr.notify(tmpl, transitions, listener, hback, leaseDuration);
             } catch (IOException ex) {
                 throw new RemoteException("ServiceRegistrarFacade threw exception",ex);
             }

Modified: incubator/river/jtsk/trunk/src/net/jini/lookup/StreamServiceRegistrarFacade.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/lookup/StreamServiceRegistrarFacade.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/lookup/StreamServiceRegistrarFacade.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/lookup/StreamServiceRegistrarFacade.java Sun Aug 29 22:50:19 2010
@@ -42,8 +42,8 @@ public class StreamServiceRegistrarFacad
         psr = registrar;
     }
 
-    public EventRegistration notify(MarshalledInstance handback,
-            ServiceTemplate tmpl, int transitions, RemoteEventListener listener,
+    public EventRegistration notify(
+            ServiceTemplate tmpl, int transitions, RemoteEventListener listener,MarshalledInstance handback,
             long leaseDuration) throws RemoteException {
         try {
             if ( psr instanceof net.jini.core.lookup.ServiceRegistrar) {

Modified: incubator/river/jtsk/trunk/src/org/apache/river/api/security/ExecutionContextManager.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/org/apache/river/api/security/ExecutionContextManager.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/org/apache/river/api/security/ExecutionContextManager.java (original)
+++ incubator/river/jtsk/trunk/src/org/apache/river/api/security/ExecutionContextManager.java Sun Aug 29 22:50:19 2010
@@ -97,4 +97,7 @@ public interface ExecutionContextManager
      */
     public void checkPermission(Collection<Permission> perms) 
 	    throws AccessControlException, NullPointerException;
+    
+    public void checkPermission(Permission perm) throws AccessControlException,
+	    NullPointerException;
 }
\ No newline at end of file

Modified: incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/ConcurrentPermissions.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/ConcurrentPermissions.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/ConcurrentPermissions.java (original)
+++ incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/ConcurrentPermissions.java Sun Aug 29 22:50:19 2010
@@ -74,7 +74,7 @@ implements Serializable {
      * causes it to throw an exception.
      */ 
     private transient final PermissionPendingResolutionCollection unresolved;
-    private ConcurrentHashMap<Class<?>, PermissionCollection> permsMap;
+    private transient ConcurrentHashMap<Class<?>, PermissionCollection> permsMap;
     private transient volatile boolean allPermission;
     
     /* Let Permissions, UnresolvedPermission and 

Modified: incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/DynamicConcurrentPolicyProvider.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/DynamicConcurrentPolicyProvider.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/DynamicConcurrentPolicyProvider.java (original)
+++ incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/DynamicConcurrentPolicyProvider.java Sun Aug 29 22:50:19 2010
@@ -42,6 +42,7 @@ import org.apache.river.api.security.Rev
 import org.apache.river.imp.security.policy.util.PermissionGrantBuilderImp;
 import org.apache.river.imp.security.policy.util.PolicyUtils;
 import org.apache.river.imp.util.ConcurrentWeakIdentityMap;
+import org.apache.river.imp.util.ConcurrentWeakMap;
 
 /**
  * <p>This is a Dynamic Policy Provider that supports concurrent access,
@@ -169,7 +170,7 @@ public class DynamicConcurrentPolicyProv
 	pGrants = new PermissionGrant[0];
         basePolicy = null;
         cache = new ConcurrentWeakIdentityMap<ProtectionDomain, PermissionCollection>();
-	grantCache = new ConcurrentWeakIdentityMap<PermissionGrant, Permission[]>();
+	grantCache = new ConcurrentWeakMap<PermissionGrant, Permission[]>();
         basePolicyIsDynamic = false;
         revokeable = true;
         logger = Logger.getLogger("net.jini.security.policy");

Modified: incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/ECM.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/ECM.java?rev=990669&r1=990668&r2=990669&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/ECM.java (original)
+++ incubator/river/jtsk/trunk/src/org/apache/river/imp/security/policy/se/ECM.java Sun Aug 29 22:50:19 2010
@@ -97,27 +97,38 @@ class ECM implements ExecutionContextMan
 	AccessControlContext executionContext = AccessController.getContext();
 	HashSet<Permission> permissions = new HashSet<Permission>(perms.size());
 	permissions.addAll(perms);
-	rl.lock();
-	try {
-	    // checkedCache - the permission check, fast for repeated calls.
-	    Iterator<Permission> permiter = permissions.iterator();
-	    while (permiter.hasNext()){
-		Permission p = permiter.next();
-		Set<AccessControlContext> checked = checkedCache.get(p);
-		if (checked == null ){
-		    checked = Collections.synchronizedSet(new HashSet<AccessControlContext>());
-		    Set<AccessControlContext> existed = checkedCache.putIfAbsent(p, checked);
-		    if (existed != null){
-			checked = existed;
-		    }
+	Iterator<Permission> permiter = permissions.iterator();
+	while (permiter.hasNext()){
+	    Permission p = permiter.next();
+	    checkPermission(p, executionContext);
+	}
+	
+    }
+
+    public void checkPermission(Permission perm) throws AccessControlException, NullPointerException {
+	AccessControlContext executionContext = AccessController.getContext();
+	checkPermission(perm, executionContext);
+    }
+    
+    private void checkPermission(Permission perm, AccessControlContext context)
+	    throws AccessControlException, NullPointerException {
+//	rl.lock();
+//	try {
+	    // checkedCache - the permission check, fast for repeated calls.	   
+	    Set<AccessControlContext> checked = checkedCache.get(perm);
+	    if (checked == null ){
+		checked = Collections.synchronizedSet(new HashSet<AccessControlContext>());
+		Set<AccessControlContext> existed = checkedCache.putIfAbsent(perm, checked);
+		if (existed != null){
+		    checked = existed;
 		}
-		if ( checked.contains(executionContext)) continue; // it's passed before.
-		executionContext.checkPermission(p); // Throws AccessControlException
-		// If we get here cache the AccessControlContext.
-		checked.add(executionContext);
 	    }
-	} finally {
-	    rl.unlock();
-	}
+	    if ( checked.contains(context)) return; // it's passed before.
+	    context.checkPermission(perm); // Throws AccessControlException
+	    // If we get here cache the AccessControlContext.
+	    checked.add(context);	    
+//	} finally {
+//	    rl.unlock();
+//	}
     }
 }

Added: 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=990669&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/test/src/net/jini/core/event/RemoteEventTest.java (added)
+++ incubator/river/jtsk/trunk/test/src/net/jini/core/event/RemoteEventTest.java Sun Aug 29 22:50:19 2010
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.jini.core.event;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+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.*;
+
+/**
+ *
+ * @author peter
+ */
+public class RemoteEventTest {
+
+    public RemoteEventTest() {
+    }
+    String s = "happy";
+    Object source = "source";
+    MarshalledInstance<String> m = null;
+    RemoteEvent e = null;
+    MarshalledObject<String> mo = null;
+
+    @Before
+    @SuppressWarnings("deprecation")
+    public void setUp() {
+	try {
+	    m = new MarshalledInstance<String>(s);
+	    mo = m.convertToMarshalledObject();
+	} catch (IOException ex) {
+	    Logger.getLogger(RemoteEventTest.class.getName()).log(Level.SEVERE, null, ex);
+	}
+	e = new RemoteEvent(source, m, 10L, 25L );
+    }
+
+    /**
+     * Test of getID method, of class RemoteEvent.
+     */
+    @Test
+    public void getID() {
+	System.out.println("getID");
+	RemoteEvent instance = e;
+	long expResult = 10L;
+	long result = instance.getID();
+	assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of getSequenceNumber method, of class RemoteEvent.
+     */
+    @Test
+    public void getSequenceNumber() {
+	System.out.println("getSequenceNumber");
+	RemoteEvent instance = e;
+	long expResult = 25L;
+	long result = instance.getSequenceNumber();
+	assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of getRegistrationObject method, of class RemoteEvent.
+     */
+    @Test
+    public void getRegistrationObject() {
+	System.out.println("getRegistrationObject");
+	RemoteEvent instance = e;
+	MarshalledObject expResult = mo;
+	@SuppressWarnings("deprecation")
+	MarshalledObject result = instance.getRegistrationObject();
+	assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of getRegisteredObject method, of class RemoteEvent.
+     */
+    @Test
+    public void getRegisteredObject() {
+	System.out.println("getRegisteredObject");
+	RemoteEvent instance = e;
+	MarshalledInstance expResult = m;
+	MarshalledInstance result = instance.getRegisteredObject();
+	assertEquals(expResult, result);
+    }
+    
+    @Test
+    public void testSerialization() {
+	ObjectOutputStream oos = null;
+	System.out.println("test serialization");
+	MarshalledInstance expResult = m;
+	try {
+	    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+	    oos = new ObjectOutputStream(baos);
+	    oos.writeObject(e);
+	    oos.flush();
+	    byte[] bytes = baos.toByteArray();
+	    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+	    ObjectInputStream ois = new ObjectInputStream(bais);
+	    RemoteEvent result = (RemoteEvent) ois.readObject();
+	    MarshalledInstance miResult = result.getRegisteredObject();
+	    Object srcResult = result.getSource();
+	    long iDResult = result.getID();
+	    long seqResult = result.getSequenceNumber();
+	    assertEquals(expResult, miResult);
+	    assertEquals(source, srcResult);
+	    assertEquals(10L, iDResult);
+	    assertEquals(25L, seqResult);
+	} catch (IOException ex) {
+	    Logger.getLogger(RemoteEventTest.class.getName()).log(Level.SEVERE, null, ex);
+	} catch (ClassNotFoundException ex) {
+	    Logger.getLogger(RemoteEventTest.class.getName()).log(Level.SEVERE, null, ex);
+	} finally {
+	    try {
+		oos.close();
+	    } catch (IOException ex) {
+		Logger.getLogger(RemoteEventTest.class.getName()).log(Level.SEVERE, null, ex);
+	    }
+	}
+    }
+
+}
\ No newline at end of file

Propchange: incubator/river/jtsk/trunk/test/src/net/jini/core/event/RemoteEventTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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=990669&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/test/src/net/jini/discovery/RemoteDiscoveryEventTest.java (added)
+++ incubator/river/jtsk/trunk/test/src/net/jini/discovery/RemoteDiscoveryEventTest.java Sun Aug 29 22:50:19 2010
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.jini.discovery;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+import java.rmi.RemoteException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import net.jini.core.discovery.LookupLocator;
+import net.jini.core.lookup.PortableServiceRegistrar;
+import net.jini.core.lookup.ServiceID;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.lookup.ServiceMatches;
+import net.jini.core.lookup.ServiceRegistrar;
+import net.jini.core.lookup.ServiceRegistration;
+import net.jini.core.lookup.ServiceTemplate;
+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.*;
+import static org.mockito.Mockito.*;
+
+/**
+ *
+ * @author peter
+ */
+public class RemoteDiscoveryEventTest {
+    String s = "happy";
+    Object source = "source";
+    MarshalledInstance<String> m = null;
+    RemoteDiscoveryEvent e = null;
+    MarshalledObject<String> mo = null;
+    Map groups = new HashMap(1);
+    String g = "grp";
+    PortableServiceRegistrar psr = new PSR();
+    
+private static class PSR implements PortableServiceRegistrar, Serializable {
+	private final ServiceID s = new ServiceID(36L, 58098L);  
+
+	public Class[] getEntryClasses(ServiceTemplate tmpl) throws RemoteException {
+	    throw new UnsupportedOperationException("Not supported yet.");
+	}
+
+	public Object[] getFieldValues(ServiceTemplate tmpl, int setIndex, String field) throws NoSuchFieldException, RemoteException {
+	    throw new UnsupportedOperationException("Not supported yet.");
+	}
+
+	public String[] getGroups() throws RemoteException {
+	    String[] groups = new String[1];
+	    groups[0] = "grp";
+	    return groups;
+	}
+
+	public LookupLocator getLocator() throws RemoteException {
+	    throw new UnsupportedOperationException("Not supported yet.");
+	}
+
+	public ServiceID getServiceID() {
+	    return s;    
+	}
+
+	public Class[] getServiceTypes(ServiceTemplate tmpl, String prefix) throws RemoteException {
+	    throw new UnsupportedOperationException("Not supported yet.");
+	}
+
+	public Object lookup(ServiceTemplate tmpl) throws RemoteException {
+	    throw new UnsupportedOperationException("Not supported yet.");
+	}
+
+	public ServiceMatches lookup(ServiceTemplate tmpl, int maxMatches) throws RemoteException {
+	    throw new UnsupportedOperationException("Not supported yet.");
+	}
+
+	public ServiceRegistration register(ServiceItem item, long leaseDuration) throws RemoteException {
+	    throw new UnsupportedOperationException("Not supported yet.");
+	}
+	
+	@Override
+	public boolean equals(Object o){
+	    if (o == this) return true;
+	    if (!(o instanceof PSR)) return false;
+	    PSR that = (PSR) o;
+	    if (s.equals(that.s)) return true;
+	    return false;
+	}
+
+	@Override
+	public int hashCode() {
+	    int hash = 3;
+	    hash = 79 * hash + (this.s != null ? this.s.hashCode() : 0);
+	    return hash;
+	}
+	
+    };
+    
+    
+    
+    public RemoteDiscoveryEventTest() {
+    }
+
+    @Before
+    public void setUp() {
+	groups.put(psr, g);
+	try {
+	    m = new MarshalledInstance<String>(s);
+	    mo = m.convertToMarshalledObject();
+	    e = new RemoteDiscoveryEvent(source, 10L, 25L, m, true, groups );
+	} catch (IOException ex) {
+	    Logger.getLogger(RemoteDiscoveryEventTest.class.getName()).log(Level.SEVERE, null, ex);
+	}
+    }
+
+//    /**
+//     * Test of isDiscarded method, of class RemoteDiscoveryEvent.
+//     */
+//    @Test
+//    public void isDiscarded() {
+//	System.out.println("isDiscarded");
+//	RemoteDiscoveryEvent instance = null;
+//	boolean expResult = false;
+//	boolean result = instance.isDiscarded();
+//	assertEquals(expResult, result);
+//	// TODO review the generated test code and remove the default call to fail.
+//	fail("The test case is a prototype.");
+//    }
+//
+//    /**
+//     * Test of getRegistrars method, of class RemoteDiscoveryEvent.
+//     */
+//    @Test
+//    public void getRegistrars() throws Exception {
+//	System.out.println("getRegistrars");
+//	RemoteDiscoveryEvent instance = null;
+//	ServiceRegistrar[] expResult = null;
+//	ServiceRegistrar[] result = instance.getRegistrars();
+//	assertEquals(expResult, result);
+//	// TODO review the generated test code and remove the default call to fail.
+//	fail("The test case is a prototype.");
+//    }
+//
+//    /**
+//     * Test of getPRegistrars method, of class RemoteDiscoveryEvent.
+//     */
+//    @Test
+//    public void getPRegistrars() throws Exception {
+//	System.out.println("getPRegistrars");
+//	RemoteDiscoveryEvent instance = null;
+//	PortableServiceRegistrar[] expResult = null;
+//	PortableServiceRegistrar[] result = instance.getPRegistrars();
+//	assertEquals(expResult, result);
+//	// TODO review the generated test code and remove the default call to fail.
+//	fail("The test case is a prototype.");
+//    }
+//
+//    /**
+//     * Test of getGroups method, of class RemoteDiscoveryEvent.
+//     */
+//    @Test
+//    public void getGroups() {
+//	System.out.println("getGroups");
+//	RemoteDiscoveryEvent instance = null;
+//	Map expResult = null;
+//	Map result = instance.getGroups();
+//	assertEquals(expResult, result);
+//	// TODO review the generated test code and remove the default call to fail.
+//	fail("The test case is a prototype.");
+//    }
+    
+    @Test
+    public void testSerialization() {
+	ObjectOutputStream oos = null;
+	System.out.println("test serialization");
+	MarshalledInstance expResult = m;
+	try {
+	    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+	    oos = new ObjectOutputStream(baos);
+	    oos.writeObject(e);
+	    oos.flush();
+	    byte[] bytes = baos.toByteArray();
+	    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+	    ObjectInputStream ois = new ObjectInputStream(bais);
+	    RemoteDiscoveryEvent result = (RemoteDiscoveryEvent) ois.readObject();
+	    MarshalledInstance miResult = result.getRegisteredObject();
+	    Object srcResult = result.getSource();
+	    long iDResult = result.getID();
+	    long seqResult = result.getSequenceNumber();
+	    assertEquals(expResult, miResult);
+	    assertEquals(source, srcResult);
+	    assertEquals(10L, iDResult);
+	    assertEquals(25L, seqResult);
+	} catch (IOException ex) {
+	    Logger.getLogger(RemoteDiscoveryEventTest.class.getName()).log(Level.SEVERE, null, ex);
+	} catch (ClassNotFoundException ex) {
+	    Logger.getLogger(RemoteDiscoveryEventTest.class.getName()).log(Level.SEVERE, null, ex);
+	} finally {
+	    try {
+		oos.close();
+	    } catch (IOException ex) {
+		Logger.getLogger(RemoteDiscoveryEventTest.class.getName()).log(Level.SEVERE, null, ex);
+	    }
+	}
+    }
+    
+
+}
\ No newline at end of file

Propchange: incubator/river/jtsk/trunk/test/src/net/jini/discovery/RemoteDiscoveryEventTest.java
------------------------------------------------------------------------------
    svn:eol-style = native