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/04/29 03:00:18 UTC

svn commit: r939155 - in /incubator/river/jtsk/trunk/src/net/jini: core/lookup/MarshalledServiceItem.java core/lookup/ResultStream.java core/lookup/ServiceItemUnmarshaller.java core/lookup/StreamServiceRegistrar.java lookup/ServiceResultStreamFilter.java

Author: peter_firmstone
Date: Thu Apr 29 01:00:18 2010
New Revision: 939155

URL: http://svn.apache.org/viewvc?rev=939155&view=rev
Log:
This is very experimental please comment, suggest improvements etc, where new classes should go etc.

Note changes to follow for methods signatures as per Chris Dolan's suggestions.

Also please check for backward compatibility issues.

Added:
    incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceItemUnmarshaller.java   (with props)
Modified:
    incubator/river/jtsk/trunk/src/net/jini/core/lookup/MarshalledServiceItem.java
    incubator/river/jtsk/trunk/src/net/jini/core/lookup/ResultStream.java
    incubator/river/jtsk/trunk/src/net/jini/core/lookup/StreamServiceRegistrar.java
    incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceResultStreamFilter.java

Modified: incubator/river/jtsk/trunk/src/net/jini/core/lookup/MarshalledServiceItem.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/core/lookup/MarshalledServiceItem.java?rev=939155&r1=939154&r2=939155&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/core/lookup/MarshalledServiceItem.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/core/lookup/MarshalledServiceItem.java Thu Apr 29 01:00:18 2010
@@ -5,7 +5,6 @@
 
 package net.jini.core.lookup;
 
-import java.io.IOException;
 import net.jini.core.entry.Entry;
 
 /**
@@ -36,17 +35,13 @@ public abstract class MarshalledServiceI
         super(id, (Object) null, unmarshalledEntries);
     }
     /**
-     * Unmarshall the service proxy.
-     * @return the service proxy.
-     * @throws java.io.IOException
-     * @throws java.lang.ClassNotFoundException 
+     * Unmarshall the service proxy. 
+     * @return the service proxy, null if class not found.
      */
-    public abstract Object getService() throws IOException, ClassNotFoundException;
+    public abstract Object getService();
     /**
      * Unmarshall the Entry's
-     * @return array of Entry's
-     * @throws java.io.IOException
-     * @throws java.lang.ClassNotFoundException
+     * @return array of Entry's, null entry in array for any class not found.
      */
-    public abstract Entry[] getEntries() throws IOException, ClassNotFoundException;
+    public abstract Entry[] getEntries();
 }

Modified: incubator/river/jtsk/trunk/src/net/jini/core/lookup/ResultStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/core/lookup/ResultStream.java?rev=939155&r1=939154&r2=939155&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/core/lookup/ResultStream.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/core/lookup/ResultStream.java Thu Apr 29 01:00:18 2010
@@ -15,5 +15,14 @@ package net.jini.core.lookup;
  * @author Peter Firmstone
  */
 public interface ResultStream<T> {
+    /**
+     * Get next T, call from a loop until T is null;
+     * @return T unless end of stream in which case null is returned.
+     */
     public T get();
+    /**
+     * Close the result stream, this allows the implementer to close any
+     * resources prior to deleting reference.
+     */
+    public void close();
 }

Added: incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceItemUnmarshaller.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceItemUnmarshaller.java?rev=939155&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceItemUnmarshaller.java (added)
+++ incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceItemUnmarshaller.java Thu Apr 29 01:00:18 2010
@@ -0,0 +1,43 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package net.jini.core.lookup;
+
+/**
+ * Add this to the ResultStream filter chain
+ * {@link StreamServiceRegistrar#lookup(ServiceTemplate, Class[], int)}
+ * to unmarshall any MarshalledServiceItem's in the stream, prior to 
+ * proxy verification, or applying constraints.
+ * 
+ * @author Peter Firmstone.
+ * @see MarshalledServiceItem.
+ * @see StreamServiceRegistrar
+ */
+public class ServiceItemUnmarshaller implements ResultStream<ServiceItem> {
+    ResultStream<ServiceItem> input;
+    
+    public ServiceItemUnmarshaller(ResultStream<ServiceItem> rs){
+        input = rs;
+    }
+
+    public ServiceItem get() {
+        for(ServiceItem item = input.get(); item != null; 
+                item = input.get()) {
+            if (item instanceof MarshalledServiceItem){
+                MarshalledServiceItem msi = (MarshalledServiceItem) item;
+                ServiceItem it = new ServiceItem(msi.serviceID, msi.getService(),
+                        msi.getEntries());
+                item = it;
+            }
+            return item;
+        }//end item loop
+        return null; // Our stream terminated item was null;
+    }
+
+    public void close() {
+        input.close();
+    }
+
+}

Propchange: incubator/river/jtsk/trunk/src/net/jini/core/lookup/ServiceItemUnmarshaller.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=939155&r1=939154&r2=939155&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 Thu Apr 29 01:00:18 2010
@@ -101,7 +101,7 @@ public interface StreamServiceRegistrar 
      * designed to allow both the caller and the implementer to deal with very
      * large result sets in an incremental fashion.
      * 
-     * It is absolutely essential that the caller deletes any references to
+     * It is absolutely essential that the caller closes and deletes any references to
      * the returned result stream as soon as it is no longer requried.
      *
      * @param tmpl template to match
@@ -117,6 +117,7 @@ public interface StreamServiceRegistrar 
      * @see ServiceItem
      * @see ResultStream
      * @see ServiceResultStreamFilter
+     * @see ResultStreamUnmarshaller
      * @since 2.2.0
      */
     ResultStream<MarshalledServiceItem> lookup(ServiceTemplate tmpl, 

Modified: incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceResultStreamFilter.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceResultStreamFilter.java?rev=939155&r1=939154&r2=939155&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceResultStreamFilter.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/lookup/ServiceResultStreamFilter.java Thu Apr 29 01:00:18 2010
@@ -47,4 +47,8 @@ public class ServiceResultStreamFilter i
         }//end item loop
         return null; // Our stream terminated item was null;
     }
+
+    public void close() {
+        inputResultStream.close();
+    }
 }