jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r365458 [1/2] - in /incubator/jackrabbit/trunk/contrib/jcr-rmi: ./ src/java/org/apache/jackrabbit/rmi/client/ src/java/org/apache/jackrabbit/rmi/client/iterator/ src/java/org/apache/jackrabbit/rmi/iterator/ src/java/org/apache/jackrabbit/rm...
Date Mon, 02 Jan 2006 23:19:30 GMT
Author: jukka
Date: Mon Jan  2 15:18:30 2006
New Revision: 365458

URL: http://svn.apache.org/viewcvs?rev=365458&view=rev
Log:
JCR-RMI: Use remote iterators instead of arrays to avoid memory and network problems with large result sets.

Added:
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeTypeIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientPropertyIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientRowIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientVersionIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/package.html   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/ArrayIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/BufferIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/iterator/
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/iterator/ServerIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/iterator/ServerNodeIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/iterator/ServerNodeTypeIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/iterator/ServerPropertyIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/iterator/ServerRowIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/iterator/ServerVersionIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/iterator/package.html   (with props)
Removed:
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayNodeIterator.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayNodeTypeIterator.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayPropertyIterator.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayRowIterator.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayVersionIterator.java
Modified:
    incubator/jackrabbit/trunk/contrib/jcr-rmi/maven.xml
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeType.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeTypeManager.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObject.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryResult.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersion.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersionHistory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/LocalAdapterFactory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNodeTypeManager.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryResult.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersionHistory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerNode.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerNodeType.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerNodeTypeManager.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerObject.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerQueryResult.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersion.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerVersionHistory.java
    incubator/jackrabbit/trunk/contrib/jcr-rmi/src/test/org/apache/jackrabbit/test/rmi/RemoteAdapterTest.java

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/maven.xml?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/maven.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/maven.xml Mon Jan  2 15:18:30 2006
@@ -23,7 +23,7 @@
    <!-- Compile the RMI stubs for the JCR-RMI server classes. -->
    <postGoal name="java:compile">
       <rmic base="${maven.build.dest}" verify="true"
-            includes="org/apache/jackrabbit/rmi/server/Server*.class"
+            includes="org/apache/jackrabbit/rmi/server/**/Server*.class"
             classpathref="maven.dependency.classpath"/>
    </postGoal>
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java Mon Jan  2 15:18:30 2006
@@ -19,12 +19,15 @@
 import javax.jcr.Item;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.Node;
+import javax.jcr.NodeIterator;
 import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
 import javax.jcr.Repository;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
 import javax.jcr.lock.Lock;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.ItemDefinition;
 import javax.jcr.nodetype.NodeDefinition;
@@ -34,11 +37,19 @@
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
+import javax.jcr.version.VersionIterator;
 
+import org.apache.jackrabbit.rmi.client.iterator.ClientNodeIterator;
+import org.apache.jackrabbit.rmi.client.iterator.ClientNodeTypeIterator;
+import org.apache.jackrabbit.rmi.client.iterator.ClientPropertyIterator;
+import org.apache.jackrabbit.rmi.client.iterator.ClientRowIterator;
+import org.apache.jackrabbit.rmi.client.iterator.ClientVersionIterator;
 import org.apache.jackrabbit.rmi.remote.RemoteItem;
 import org.apache.jackrabbit.rmi.remote.RemoteItemDefinition;
+import org.apache.jackrabbit.rmi.remote.RemoteIterator;
 import org.apache.jackrabbit.rmi.remote.RemoteLock;
 import org.apache.jackrabbit.rmi.remote.RemoteNamespaceRegistry;
 import org.apache.jackrabbit.rmi.remote.RemoteNode;
@@ -260,4 +271,48 @@
     public Row getRow(RemoteRow remote) {
         return new ClientRow(remote);
     }
+
+    /**
+     * Creates and returns a {@link ClientNodeIterator} instance.
+     * {@inheritDoc}
+     */
+    public NodeIterator getNodeIterator(
+            Session session, RemoteIterator remote) {
+        return new ClientNodeIterator(remote, session, this);
+    }
+
+    /**
+     * Creates and returns a {@link ClientPropertyIterator} instance.
+     * {@inheritDoc}
+     */
+    public PropertyIterator getPropertyIterator(
+            Session session, RemoteIterator remote) {
+        return new ClientPropertyIterator(remote, session, this);
+    }
+
+    /**
+     * Creates and returns a {@link ClientVersionIterator} instance.
+     * {@inheritDoc}
+     */
+    public VersionIterator getVersionIterator(
+            Session session, RemoteIterator remote) {
+        return new ClientVersionIterator(remote, session, this);
+    }
+
+    /**
+     * Creates and returns a {@link ClientNodeTypeIterator} instance.
+     * {@inheritDoc}
+     */
+    public NodeTypeIterator getNodeTypeIterator(RemoteIterator remote) {
+        return new ClientNodeTypeIterator(remote, this);
+    }
+
+    /**
+     * Creates and returns a {@link ClientRowIterator} instance.
+     * {@inheritDoc}
+     */
+    public RowIterator getRowIterator(RemoteIterator remote) {
+        return new ClientRowIterator(remote, this);
+    }
+
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNode.java Mon Jan  2 15:18:30 2006
@@ -204,7 +204,7 @@
     /** {@inheritDoc} */
     public NodeIterator getNodes() throws RepositoryException {
         try {
-            return getNodeIterator(getSession(), remote.getNodes());
+            return getFactory().getNodeIterator(getSession(), remote.getNodes());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -213,7 +213,7 @@
     /** {@inheritDoc} */
     public NodeIterator getNodes(String pattern) throws RepositoryException {
         try {
-            return getNodeIterator(getSession(), remote.getNodes(pattern));
+            return getFactory().getNodeIterator(getSession(), remote.getNodes(pattern));
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -232,7 +232,7 @@
     /** {@inheritDoc} */
     public PropertyIterator getProperties() throws RepositoryException {
         try {
-            return getPropertyIterator(getSession(), remote.getProperties());
+            return getFactory().getPropertyIterator(getSession(), remote.getProperties());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -242,8 +242,7 @@
     public PropertyIterator getProperties(String pattern)
             throws RepositoryException {
         try {
-            RemoteProperty[] properties = remote.getProperties(pattern);
-            return getPropertyIterator(getSession(), properties);
+            return getFactory().getPropertyIterator(getSession(), remote.getProperties(pattern));
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -270,7 +269,7 @@
     /** {@inheritDoc} */
     public PropertyIterator getReferences() throws RepositoryException {
         try {
-            return getPropertyIterator(getSession(), remote.getReferences());
+            return getFactory().getPropertyIterator(getSession(), remote.getReferences());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -406,7 +405,7 @@
     public NodeIterator merge(String workspace, boolean bestEffort)
             throws RepositoryException {
         try {
-            return getNodeIterator(getSession(), remote.merge(workspace, bestEffort));
+            return getFactory().getNodeIterator(getSession(), remote.merge(workspace, bestEffort));
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeType.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeType.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeType.java Mon Jan  2 15:18:30 2006
@@ -25,6 +25,7 @@
 
 import org.apache.jackrabbit.rmi.remote.RemoteNodeDefinition;
 import org.apache.jackrabbit.rmi.remote.RemoteNodeType;
+import org.apache.jackrabbit.rmi.remote.RemotePropertyDefinition;
 import org.apache.jackrabbit.rmi.value.SerialValueFactory;
 
 /**
@@ -53,6 +54,51 @@
         this.remote = remote;
     }
 
+    /**
+     * Utility method for creating an array of local node definition
+     * adapters for an array of remote node definitions. The node
+     * definition adapters are created using the local adapter factory.
+     * <p>
+     * A <code>null</code> input is treated as an empty array.
+     *
+     * @param remotes remote node definitions
+     * @return local node definition array
+     */
+    private NodeDefinition[] getNodeDefArray(RemoteNodeDefinition[] remotes) {
+        if (remotes != null) {
+            NodeDefinition[] defs = new NodeDefinition[remotes.length];
+            for (int i = 0; i < remotes.length; i++) {
+                defs[i] = getFactory().getNodeDef(remotes[i]);
+            }
+            return defs;
+        } else {
+            return new NodeDefinition[0]; // for safety
+        }
+    }
+
+    /**
+     * Utility method for creating an array of local property definition
+     * adapters for an array of remote property definitions. The property
+     * definition adapters are created using the local adapter factory.
+     * <p>
+     * A <code>null</code> input is treated as an empty array.
+     *
+     * @param remotes remote property definitions
+     * @return local property definition array
+     */
+    protected PropertyDefinition[] getPropertyDefArray(
+            RemotePropertyDefinition[] remotes) {
+        if (remotes != null) {
+            PropertyDefinition[] defs = new PropertyDefinition[remotes.length];
+            for (int i = 0; i < remotes.length; i++) {
+                defs[i] = getFactory().getPropertyDef(remotes[i]);
+            }
+            return defs;
+        } else {
+            return new PropertyDefinition[0]; // for safety
+        }
+    }
+
     /** {@inheritDoc} */
     public String getName() {
         try {
@@ -128,8 +174,7 @@
     /** {@inheritDoc} */
     public NodeDefinition[] getChildNodeDefinitions() {
         try {
-            RemoteNodeDefinition[] defs = remote.getChildNodeDefs();
-            return getNodeDefArray(defs);
+            return getNodeDefArray(remote.getChildNodeDefs());
         } catch (RemoteException ex) {
             throw new RemoteRuntimeException(ex);
         }
@@ -138,8 +183,7 @@
     /** {@inheritDoc} */
     public NodeDefinition[] getDeclaredChildNodeDefinitions() {
         try {
-            RemoteNodeDefinition[] defs = remote.getDeclaredChildNodeDefs();
-            return getNodeDefArray(defs);
+            return getNodeDefArray(remote.getDeclaredChildNodeDefs());
         } catch (RemoteException ex) {
             throw new RemoteRuntimeException(ex);
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeTypeManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeTypeManager.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeTypeManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientNodeTypeManager.java Mon Jan  2 15:18:30 2006
@@ -66,7 +66,7 @@
     /** {@inheritDoc} */
     public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
         try {
-            return getNodeTypeIterator(remote.getAllNodeTypes());
+            return getFactory().getNodeTypeIterator(remote.getAllNodeTypes());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -75,7 +75,7 @@
     /** {@inheritDoc} */
     public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
         try {
-            return getNodeTypeIterator(remote.getPrimaryNodeTypes());
+            return getFactory().getNodeTypeIterator(remote.getPrimaryNodeTypes());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -84,7 +84,7 @@
     /** {@inheritDoc} */
     public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
         try {
-            return getNodeTypeIterator(remote.getMixinNodeTypes());
+            return getFactory().getNodeTypeIterator(remote.getMixinNodeTypes());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObject.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObject.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObject.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObject.java Mon Jan  2 15:18:30 2006
@@ -18,27 +18,13 @@
 
 import javax.jcr.Item;
 import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
 import javax.jcr.Session;
-import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
-import javax.jcr.nodetype.NodeTypeIterator;
-import javax.jcr.nodetype.PropertyDefinition;
-import javax.jcr.version.Version;
-import javax.jcr.version.VersionIterator;
 
-import org.apache.jackrabbit.rmi.iterator.ArrayNodeIterator;
-import org.apache.jackrabbit.rmi.iterator.ArrayNodeTypeIterator;
-import org.apache.jackrabbit.rmi.iterator.ArrayPropertyIterator;
-import org.apache.jackrabbit.rmi.iterator.ArrayVersionIterator;
 import org.apache.jackrabbit.rmi.remote.RemoteItem;
 import org.apache.jackrabbit.rmi.remote.RemoteNode;
-import org.apache.jackrabbit.rmi.remote.RemoteNodeDefinition;
 import org.apache.jackrabbit.rmi.remote.RemoteNodeType;
 import org.apache.jackrabbit.rmi.remote.RemoteProperty;
-import org.apache.jackrabbit.rmi.remote.RemotePropertyDefinition;
 import org.apache.jackrabbit.rmi.remote.RemoteVersion;
 import org.apache.jackrabbit.rmi.remote.RemoteVersionHistory;
 
@@ -77,7 +63,7 @@
     /**
      * Utility method to create a local adapter for a remote item.
      * This method introspects the remote reference to determine
-     * whether to instantiate a {@link Property Property},
+     * whether to instantiate a {@link javax.jcr.Property},
      * a {@link Node Node}, or an {@link Item Item} adapter using
      * the local adapter factory.
      * <p>
@@ -121,94 +107,6 @@
     }
 
     /**
-     * Utility method for creating a property iterator for an array
-     * of remote properties. The properties in the returned iterator
-     * are created using the local adapter factory.
-     * <p>
-     * A <code>null</code> input is treated as an empty array.
-     *
-     * @param session current session
-     * @param remotes remote properties
-     * @return local property iterator
-     */
-    protected PropertyIterator getPropertyIterator(
-            Session session, RemoteProperty[] remotes) {
-        if (remotes != null) {
-            Property[] properties = new Property[remotes.length];
-            for (int i = 0; i < remotes.length; i++) {
-                properties[i] = factory.getProperty(session, remotes[i]);
-            }
-            return new ArrayPropertyIterator(properties);
-        } else {
-            return new ArrayPropertyIterator(new Property[0]); // for safety
-        }
-    }
-
-    /**
-     * Utility method for creating a node iterator for an array
-     * of remote nodes. The nodes in the returned iterator
-     * are created using the local adapter factory.
-     * <p>
-     * A <code>null</code> input is treated as an empty array.
-     *
-     * @param session current session
-     * @param remotes remote nodes
-     * @return local node iterator
-     */
-    protected NodeIterator getNodeIterator(
-            Session session, RemoteNode[] remotes) {
-        if (remotes != null) {
-            Node[] nodes = new Node[remotes.length];
-            for (int i = 0; i < remotes.length; i++) {
-                nodes[i] = getNode(session, remotes[i]);
-            }
-            return new ArrayNodeIterator(nodes);
-        } else {
-            return new ArrayNodeIterator(new Node[0]); // for safety
-        }
-    }
-
-    /**
-     * Utility method for creating a version array for an array
-     * of remote versions. The versions in the returned array
-     * are created using the local adapter factory.
-     * <p>
-     * A <code>null</code> input is treated as an empty array.
-     *
-     * @param session current session
-     * @param remotes remote versions
-     * @return local version array
-     */
-    protected Version[] getVersionArray(
-            Session session, RemoteVersion[] remotes) {
-        if (remotes != null) {
-            Version[] versions = new Version[remotes.length];
-            for (int i = 0; i < remotes.length; i++) {
-                versions[i] = factory.getVersion(session, remotes[i]);
-            }
-            return versions;
-        } else {
-            return new Version[0]; // for safety
-        }
-    }
-
-    /**
-     * Utility method for creating a version iterator for an array
-     * of remote versions. The versions in the returned iterator
-     * are created using the local adapter factory.
-     * <p>
-     * A <code>null</code> input is treated as an empty array.
-     *
-     * @param session current session
-     * @param remotes remote versions
-     * @return local version iterator
-     */
-    protected VersionIterator getVersionIterator(
-            Session session, RemoteVersion[] remotes) {
-        return new ArrayVersionIterator(getVersionArray(session, remotes));
-    }
-
-    /**
      * Utility method for creating an array of local node type adapters
      * for an array of remote node types. The node type adapters are created
      * using the local adapter factory.
@@ -227,64 +125,6 @@
             return types;
         } else {
             return new NodeType[0]; // for safety
-        }
-    }
-
-    /**
-     * Utility method for creating an iterator of local node type adapters
-     * for an array of remote node types. The node type adapters are created
-     * using the local adapter factory.
-     * <p>
-     * A <code>null</code> input is treated as an empty array.
-     *
-     * @param remotes remote node types
-     * @return local node type iterator
-     */
-    protected NodeTypeIterator getNodeTypeIterator(RemoteNodeType[] remotes) {
-        return new ArrayNodeTypeIterator(getNodeTypeArray(remotes));
-    }
-
-    /**
-     * Utility method for creating an array of local node definition
-     * adapters for an array of remote node definitions. The node
-     * definition adapters are created using the local adapter factory.
-     * <p>
-     * A <code>null</code> input is treated as an empty array.
-     *
-     * @param remotes remote node definitions
-     * @return local node definition array
-     */
-    protected NodeDefinition[] getNodeDefArray(RemoteNodeDefinition[] remotes) {
-        if (remotes != null) {
-            NodeDefinition[] defs = new NodeDefinition[remotes.length];
-            for (int i = 0; i < remotes.length; i++) {
-                defs[i] = factory.getNodeDef(remotes[i]);
-            }
-            return defs;
-        } else {
-            return new NodeDefinition[0]; // for safety
-        }
-    }
-
-    /**
-     * Utility method for creating an array of local property definition
-     * adapters for an array of remote property definitions. The property
-     * definition adapters are created using the local adapter factory.
-     * <p>
-     * A <code>null</code> input is treated as an empty array.
-     *
-     * @param remotes remote property definitions
-     * @return local property definition array
-     */
-    protected PropertyDefinition[] getPropertyDefArray(RemotePropertyDefinition[] remotes) {
-        if (remotes != null) {
-            PropertyDefinition[] defs = new PropertyDefinition[remotes.length];
-            for (int i = 0; i < remotes.length; i++) {
-                defs[i] = factory.getPropertyDef(remotes[i]);
-            }
-            return defs;
-        } else {
-            return new PropertyDefinition[0]; // for safety
         }
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryResult.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryResult.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryResult.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientQueryResult.java Mon Jan  2 15:18:30 2006
@@ -18,19 +18,13 @@
 
 import java.rmi.RemoteException;
 
-import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.query.QueryResult;
-import javax.jcr.query.Row;
 import javax.jcr.query.RowIterator;
 
-import org.apache.jackrabbit.rmi.iterator.ArrayNodeIterator;
-import org.apache.jackrabbit.rmi.iterator.ArrayRowIterator;
-import org.apache.jackrabbit.rmi.remote.RemoteNode;
 import org.apache.jackrabbit.rmi.remote.RemoteQueryResult;
-import org.apache.jackrabbit.rmi.remote.RemoteRow;
 
 /**
  * Local adapter for the JCR-RMI
@@ -77,16 +71,7 @@
     /** {@inheritDoc} */
     public RowIterator getRows() throws RepositoryException {
         try {
-            RemoteRow[] remotes =  remote.getRows();
-            if (remotes != null) {
-                Row[] rows = new Row[remotes.length];
-                for (int i = 0; i < rows.length; i++) {
-                    rows[i] = getFactory().getRow(remotes[i]);
-                }
-                return new ArrayRowIterator(rows);
-            } else {
-                return new ArrayRowIterator(new Row[0]);
-            }
+            return getFactory().getRowIterator(remote.getRows());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -95,18 +80,9 @@
     /** {@inheritDoc} */
     public NodeIterator getNodes() throws RepositoryException {
         try {
-            RemoteNode[] remotes = remote.getNodes();
-            if (remotes != null) {
-                Node[] nodes = new Node[remotes.length];
-                for (int i = 0; i < nodes.length; i++) {
-                    nodes[i] = getNode(session, remotes[i]);
-                }
-                return new ArrayNodeIterator(nodes);
-            } else {
-                return new ArrayNodeIterator(new Node[0]);
-            }
-        } catch (RemoteException ex) {
-            throw new RemoteRepositoryException(ex);
+            return getFactory().getNodeIterator(session, remote.getNodes());
+        } catch (RemoteException e) {
+            throw new RemoteRepositoryException(e);
         }
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersion.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersion.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersion.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersion.java Mon Jan  2 15:18:30 2006
@@ -54,6 +54,29 @@
         this.remote = remote;
     }
 
+    /**
+     * Utility method for creating a version array for an array
+     * of remote versions. The versions in the returned array
+     * are created using the local adapter factory.
+     * <p>
+     * A <code>null</code> input is treated as an empty array.
+     *
+     * @param remotes remote versions
+     * @return local version array
+     */
+    private Version[] getVersionArray(RemoteVersion[] remotes) {
+        if (remotes != null) {
+            Version[] versions = new Version[remotes.length];
+            for (int i = 0; i < remotes.length; i++) {
+                versions[i] = getFactory().getVersion(getSession(), remotes[i]);
+            }
+            return versions;
+        } else {
+            return new Version[0]; // for safety
+        }
+    }
+
+
     /** {@inheritDoc} */
     public Calendar getCreated() throws RepositoryException {
         try {
@@ -66,7 +89,7 @@
     /** {@inheritDoc} */
     public Version[] getSuccessors() throws RepositoryException {
         try {
-            return getVersionArray(getSession(), remote.getSuccessors());
+            return getVersionArray(remote.getSuccessors());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }
@@ -75,7 +98,7 @@
     /** {@inheritDoc} */
     public Version[] getPredecessors() throws RepositoryException {
         try {
-            return getVersionArray(getSession(), remote.getPredecessors());
+            return getVersionArray(remote.getPredecessors());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersionHistory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersionHistory.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersionHistory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientVersionHistory.java Mon Jan  2 15:18:30 2006
@@ -68,7 +68,8 @@
     /** {@inheritDoc} */
     public VersionIterator getAllVersions() throws RepositoryException {
         try {
-            return getVersionIterator(getSession(), remote.getAllVersions());
+            return getFactory().getVersionIterator(
+                    getSession(), remote.getAllVersions());
         } catch (RemoteException ex) {
             throw new RemoteRepositoryException(ex);
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/LocalAdapterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/LocalAdapterFactory.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/LocalAdapterFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/LocalAdapterFactory.java Mon Jan  2 15:18:30 2006
@@ -19,7 +19,9 @@
 import javax.jcr.Item;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.Node;
+import javax.jcr.NodeIterator;
 import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
 import javax.jcr.Repository;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
@@ -27,6 +29,7 @@
 import javax.jcr.nodetype.ItemDefinition;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.observation.ObservationManager;
@@ -34,11 +37,14 @@
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
+import javax.jcr.version.VersionIterator;
 
 import org.apache.jackrabbit.rmi.remote.RemoteItem;
 import org.apache.jackrabbit.rmi.remote.RemoteItemDefinition;
+import org.apache.jackrabbit.rmi.remote.RemoteIterator;
 import org.apache.jackrabbit.rmi.remote.RemoteLock;
 import org.apache.jackrabbit.rmi.remote.RemoteNamespaceRegistry;
 import org.apache.jackrabbit.rmi.remote.RemoteNode;
@@ -268,5 +274,49 @@
      * @return local query row adapter
      */
     Row getRow(RemoteRow remote);
+
+    /**
+     * Factory method for creating a local adapter for a remote node iterator.
+     *
+     * @param session current session
+     * @param remote remote node iterator
+     * @return local node iterator adapter
+     */
+    NodeIterator getNodeIterator(Session session, RemoteIterator remote);
+
+    /**
+     * Factory method for creating a local adapter for a remote property iterator.
+     *
+     * @param session current session
+     * @param remote remote property iterator
+     * @return local property iterator adapter
+     */
+    PropertyIterator getPropertyIterator(Session session, RemoteIterator remote);
+
+    /**
+     * Factory method for creating a local adapter for a remote version iterator.
+     *
+     * @param session current session
+     * @param remote remote version iterator
+     * @return local version iterator adapter
+     */
+    VersionIterator getVersionIterator(Session session, RemoteIterator remote);
+
+    /**
+     * Factory method for creating a local adapter for a remote
+     * node type iterator.
+     *
+     * @param remote remote node type iterator
+     * @return local node type iterator adapter
+     */
+    NodeTypeIterator getNodeTypeIterator(RemoteIterator remote);
+
+    /**
+     * Factory method for creating a local adapter for a remote row iterator.
+     *
+     * @param remote remote row iterator
+     * @return local row iterator adapter
+     */
+    RowIterator getRowIterator(RemoteIterator remote);
 
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientIterator.java?rev=365458&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientIterator.java Mon Jan  2 15:18:30 2006
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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 org.apache.jackrabbit.rmi.client.iterator;
+
+import java.rmi.RemoteException;
+import java.util.NoSuchElementException;
+
+import javax.jcr.RangeIterator;
+
+import org.apache.jackrabbit.rmi.client.ClientObject;
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+import org.apache.jackrabbit.rmi.client.RemoteRuntimeException;
+import org.apache.jackrabbit.rmi.remote.RemoteIterator;
+
+/**
+ * A buffering local adapter for the JCR-RMI {@link RemoteIterator}
+ * interface. This class makes the remote iterator locally available
+ * using the JCR {@link RangeIterator} interface. The element arrays
+ * returned by the remote iterator are buffered locally.
+ * <p>
+ * See the subclasses for type-specific versions of this abstract class.
+ */
+public abstract class ClientIterator extends ClientObject
+        implements RangeIterator {
+
+    /** The adapted remote iterator. */
+    private final RemoteIterator remote;
+
+    /**
+     * The cached number of elements in the iterator, -1 if the iterator
+     * size is unknown, or -2 if the size has not been retrieved from the
+     * remote iterator.
+     */
+    private long size;
+
+    /** The position of the buffer within the iteration. */
+    private long positionOfBuffer;
+
+    /** The position within the buffer of the iteration. */
+    private int positionInBuffer;
+
+    /**
+     * The element buffer. Set to <code>null</code> when the end of the
+     * iteration has been reached.
+     */
+    private Object[] buffer;
+
+    /**
+     * Creates a local adapter for the given remote iterator. The element
+     * buffer is initially empty.
+     *
+     * @param remote        remote iterator
+     * @param factory       local adapter factory
+     */
+    public ClientIterator(RemoteIterator remote, LocalAdapterFactory factory) {
+        super(factory);
+        this.remote = remote;
+        this.size = -2;
+        this.positionOfBuffer = 0;
+        this.positionInBuffer = 0;
+        this.buffer = new Object[0];
+    }
+
+    /**
+     * Returns the current position within the iterator.
+     *
+     * @return current position
+     * @see RangeIterator#getPosition()
+     */
+    public long getPosition() {
+        return positionOfBuffer + positionInBuffer;
+    }
+
+    /**
+     * Returns the size (the total number of elements) of this iteration.
+     * Returns <code>-1</code> if the size is unknown.
+     * <p>
+     * To minimize the number of remote method calls, the size is retrieved
+     * when this method is first called and cached for subsequent invocations.
+     *
+     * @return number of elements in the iteration, or <code>-1</code>
+     * @throws RemoteRuntimeException on RMI errors
+     * @see RangeIterator#getSize()
+     */
+    public long getSize() throws RemoteRuntimeException {
+        if (size == -2) {
+            try {
+                size = remote.getSize();
+            } catch (RemoteException e) {
+                throw new RemoteRuntimeException(e);
+            }
+        }
+        return size;
+    }
+
+    /**
+     * Skips the given number of elements in this iteration.
+     * <p>
+     * The elements in the local element buffer are skipped first, and
+     * a remote skip method call is made only if more elements are being
+     * skipped than remain in the local buffer.
+     *
+     * @param skipNum the number of elements to skip
+     * @throws NoSuchElementException if skipped past the last element
+     * @throws RemoteRuntimeException on RMI errors
+     * @see RangeIterator#skip(long)
+     */
+    public void skip(long skipNum)
+            throws NoSuchElementException, RemoteRuntimeException {
+        if (skipNum < 0) {
+            throw new IllegalArgumentException("Negative skip is not allowed");
+        } else if (buffer == null && skipNum > 0) {
+            throw new NoSuchElementException("Skipped past the last element");
+        } else if (positionInBuffer + skipNum < buffer.length) {
+            positionInBuffer += skipNum;
+        } else {
+            try {
+                remote.skip(skipNum - (buffer.length - positionInBuffer));
+                positionInBuffer = buffer.length;
+            } catch (RemoteException e) {
+                throw new RemoteRuntimeException(e);
+            } catch (NoSuchElementException e) {
+                buffer = null; // End of iterator reached
+                throw e;
+            }
+        }
+    }
+
+    /**
+     * Advances the element buffer if there are no more elements in it. The
+     * element buffer is set to <code>null</code> if the end of the iteration
+     * has been reached.
+     *
+     * @throws RemoteException on RMI errors
+     */
+    private void advance() throws RemoteException {
+        if (buffer != null && positionInBuffer == buffer.length) {
+            positionOfBuffer += buffer.length;
+            positionInBuffer = 0;
+            buffer = remote.nextObjects();
+            if (buffer == null) {
+                size = positionOfBuffer;
+            }
+        }
+    }
+
+    /**
+     * Checks if there are more elements in this iteration.
+     *
+     * @return <code>true</code> if there are more elements,
+     *         <code>false</code> otherwise
+     * @throws RemoteRuntimeException on RMI errors
+     * @see Iterator#hasNext()
+     */
+    public boolean hasNext() throws RemoteRuntimeException {
+        try {
+            advance();
+            return buffer != null;
+        } catch (RemoteException e) {
+            throw new RemoteRuntimeException(e);
+        }
+    }
+
+    /**
+     * Returns a local adapter for the given remote object. This abstract
+     * method is used by {@link #next()} to convert the remote references
+     * returned by the remote iterator to local adapters.
+     * <p>
+     * Subclasses should implement this method to use the local adapter
+     * factory to create local adapters of the specific element type.
+     *
+     * @param remote remote object
+     * @return local adapter
+     */
+    protected abstract Object getObject(Object remote);
+
+    /**
+     * Returns the next element in this iteration.
+     *
+     * @return next element
+     * @throws NoSuchElementException if there are no more elements
+     * @throws RemoteRuntimeException on RMI errors
+     * @see Iterator#next()
+     */
+    public Object next() throws NoSuchElementException, RemoteRuntimeException {
+        try {
+            advance();
+            if (buffer == null) {
+                throw new NoSuchElementException("End of iterator reached");
+            } else {
+                return getObject(buffer[positionInBuffer++]);
+            }
+        } catch (RemoteException e) {
+            throw new RemoteRuntimeException(e);
+        }
+    }
+
+    /**
+     * Not supported.
+     *
+     * @throws UnsupportedOperationException always thrown
+     * @see Iterator#remove()
+     */
+    public void remove() throws UnsupportedOperationException {
+        throw new UnsupportedOperationException();
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeIterator.java?rev=365458&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeIterator.java Mon Jan  2 15:18:30 2006
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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 org.apache.jackrabbit.rmi.client.iterator;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteIterator;
+import org.apache.jackrabbit.rmi.remote.RemoteNode;
+
+/**
+ * A ClientIterator for iterating remote nodes.
+ */
+public class ClientNodeIterator extends ClientIterator implements NodeIterator {
+
+    /** The current session. */
+    private final Session session;
+
+    /**
+     * Creates a ClientNodeIterator instance.
+     *
+     * @param iterator      remote iterator
+     * @param session       current session
+     * @param factory       local adapter factory
+     */
+    public ClientNodeIterator(
+            RemoteIterator iterator, Session session,
+            LocalAdapterFactory factory) {
+        super(iterator, factory);
+        this.session = session;
+    }
+
+    /**
+     * Creates and returns a local adapter for the given remote node.
+     *
+     * @param remote remote referecne
+     * @return local adapter
+     * @see ClientIterator#getObject(Object)
+     */
+    protected Object getObject(Object remote) {
+        return getNode(session, (RemoteNode) remote);
+    }
+
+    /**
+     * Returns the next node in this iteration.
+     *
+     * @return next node
+     * @see NodeIterator#nextNode()
+     */
+    public Node nextNode() {
+        return (Node) next();
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeTypeIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeTypeIterator.java?rev=365458&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeTypeIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeTypeIterator.java Mon Jan  2 15:18:30 2006
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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 org.apache.jackrabbit.rmi.client.iterator;
+
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
+
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteIterator;
+import org.apache.jackrabbit.rmi.remote.RemoteNodeType;
+
+/**
+ * A ClientIterator for iterating remote node types.
+ */
+public class ClientNodeTypeIterator extends ClientIterator
+        implements NodeTypeIterator {
+
+    /**
+     * Creates a ClientNodeTypeIterator instance.
+     *
+     * @param iterator      remote iterator
+     * @param factory       local adapter factory
+     */
+    public ClientNodeTypeIterator(
+            RemoteIterator iterator, LocalAdapterFactory factory) {
+        super(iterator, factory);
+    }
+
+    /**
+     * Creates and returns a local adapter for the given remote node.
+     *
+     * @param remote remote referecne
+     * @return local adapter
+     * @see ClientIterator#getObject(Object)
+     */
+    protected Object getObject(Object remote) {
+        return getFactory().getNodeType((RemoteNodeType) remote);
+    }
+
+    /**
+     * Returns the next node type in this iteration.
+     *
+     * @return next node type
+     * @see NodeTypeIterator#nextNodeType()
+     */
+    public NodeType nextNodeType() {
+        return (NodeType) next();
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientNodeTypeIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientPropertyIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientPropertyIterator.java?rev=365458&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientPropertyIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientPropertyIterator.java Mon Jan  2 15:18:30 2006
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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 org.apache.jackrabbit.rmi.client.iterator;
+
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteIterator;
+import org.apache.jackrabbit.rmi.remote.RemoteProperty;
+
+/**
+ * A ClientIterator for iterating remote properties.
+ */
+public class ClientPropertyIterator extends ClientIterator
+        implements PropertyIterator {
+
+    /** The current session. */
+    private final Session session;
+
+    /**
+     * Creates a ClientPropertyIterator instance.
+     *
+     * @param iterator      remote iterator
+     * @param session       current session
+     * @param factory       local adapter factory
+     */
+    public ClientPropertyIterator(
+            RemoteIterator iterator, Session session,
+            LocalAdapterFactory factory) {
+        super(iterator, factory);
+        this.session = session;
+    }
+
+    /**
+     * Creates and returns a local adapter for the given remote property.
+     *
+     * @param remote remote referecne
+     * @return local adapter
+     * @see ClientIterator#getObject(Object)
+     */
+    protected Object getObject(Object remote) {
+        return getFactory().getProperty(session, (RemoteProperty) remote);
+    }
+
+    /**
+     * Returns the next property in this iteration.
+     *
+     * @return next property
+     * @see PropertyIterator#nextProperty()
+     */
+    public Property nextProperty() {
+        return (Property) next();
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientPropertyIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientRowIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientRowIterator.java?rev=365458&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientRowIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientRowIterator.java Mon Jan  2 15:18:30 2006
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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 org.apache.jackrabbit.rmi.client.iterator;
+
+import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
+
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteIterator;
+import org.apache.jackrabbit.rmi.remote.RemoteRow;
+
+/**
+ * A ClientIterator for iterating remote rows.
+ */
+public class ClientRowIterator extends ClientIterator implements RowIterator {
+
+    /**
+     * Creates a ClientRowIterator instance.
+     *
+     * @param iterator      remote iterator
+     * @param factory       local adapter factory
+     */
+    public ClientRowIterator(
+            RemoteIterator iterator, LocalAdapterFactory factory) {
+        super(iterator, factory);
+    }
+
+    /**
+     * Creates and returns a local adapter for the given remote row.
+     *
+     * @param remote remote reference
+     * @return local adapter
+     * @see ClientIterator#getObject(Object)
+     */
+    protected Object getObject(Object remote) {
+        return getFactory().getRow((RemoteRow) remote);
+    }
+
+    /**
+     * Returns the next row in this iteration.
+     *
+     * @return next row
+     * @see RowIterator#nextRow()
+     */
+    public Row nextRow() {
+        return (Row) next();
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientRowIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientVersionIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientVersionIterator.java?rev=365458&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientVersionIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientVersionIterator.java Mon Jan  2 15:18:30 2006
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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 org.apache.jackrabbit.rmi.client.iterator;
+
+import javax.jcr.Session;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionIterator;
+
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteIterator;
+import org.apache.jackrabbit.rmi.remote.RemoteVersion;
+
+/**
+ * A ClientIterator for iterating remote versions.
+ */
+public class ClientVersionIterator extends ClientIterator
+        implements VersionIterator {
+
+    /** The current session. */
+    private final Session session;
+
+    /**
+     * Creates a ClientVersionIterator instance.
+     *
+     * @param iterator      remote iterator
+     * @param session       current session
+     * @param factory       local adapter factory
+     */
+    public ClientVersionIterator(
+            RemoteIterator iterator, Session session,
+            LocalAdapterFactory factory) {
+        super(iterator, factory);
+        this.session = session;
+    }
+
+    /**
+     * Creates and returns a local adapter for the given remote version.
+     *
+     * @param remote remote referecne
+     * @return local adapter
+     * @see ClientIterator#getObject(Object)
+     */
+    protected Object getObject(Object remote) {
+        return getFactory().getVersion(session, (RemoteVersion) remote);
+    }
+
+    /**
+     * Returns the next version in this iteration.
+     *
+     * @return next version
+     * @see VersionIterator#nextVersion()
+     */
+    public Version nextVersion() {
+        return (Version) next();
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/ClientVersionIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/package.html?rev=365458&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/package.html (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/package.html Mon Jan  2 15:18:30 2006
@@ -0,0 +1,3 @@
+<body>
+Local adapters for remote iterators.
+</body>

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/iterator/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/ArrayIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/ArrayIterator.java?rev=365458&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/ArrayIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/ArrayIterator.java Mon Jan  2 15:18:30 2006
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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 org.apache.jackrabbit.rmi.remote;
+
+import java.io.Serializable;
+import java.util.NoSuchElementException;
+
+/**
+ * A simple array-based remote iterator. Used when the iteration is
+ * short enough for all the elements to be sent over the network in
+ * one go.
+ */
+public class ArrayIterator implements RemoteIterator, Serializable {
+
+    /**
+     * The elements in this iterator. Set to <code>null</code> when
+     * all elements have been iterated.
+     */
+    private Object[] elements;
+
+    /**
+     * The position of this iterator. Set to the size of the iterator
+     * when all elements have been iterated.
+     */
+    private int position;
+
+    /**
+     * Creates an array-based remote iterator from the given array
+     * of remote references or serializable objects.
+     *
+     * @param elements elements of the iteration
+     */
+    public ArrayIterator(Object[] elements) {
+        this.elements = elements;
+        this.position = 0;
+    }
+
+    /**
+     * Returns the size of the iterator.
+     *
+     * @return length of the iterator
+     * @see RemoteIterator#getSize()
+     */
+    public long getSize() {
+        if (elements == null) {
+            return position;
+        } else {
+            return elements.length;
+        }
+    }
+
+    /**
+     * Skips the first <code>items</code> elements in the array.
+     * {@inheritDoc}
+     */
+    public void skip(long items)
+            throws IllegalArgumentException, NoSuchElementException {
+        if (items < 0) {
+            throw new IllegalArgumentException("Negative skip is not allowed");
+        } else if (elements == null || items > elements.length) {
+            throw new NoSuchElementException("Skipped past the last element");
+        } else {
+            Object[] tmp = new Object[elements.length - (int) items];
+            System.arraycopy(elements, (int) items, tmp, 0, tmp.length);
+            elements = tmp;
+            position += items;
+        }
+    }
+
+    /**
+     * Returns the underlying array.
+     * {@inheritDoc}
+     */
+    public Object[] nextObjects() throws IllegalArgumentException {
+        if (elements == null) {
+            return null;
+        } else {
+            Object[] tmp = elements;
+            position += elements.length;
+            elements = null;
+            return tmp;
+        }
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/ArrayIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/BufferIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/BufferIterator.java?rev=365458&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/BufferIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/BufferIterator.java Mon Jan  2 15:18:30 2006
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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 org.apache.jackrabbit.rmi.remote;
+
+import java.io.Serializable;
+import java.rmi.RemoteException;
+import java.util.NoSuchElementException;
+
+/**
+ * A buffered remote iterator. Used to transfer a remote iterator reference
+ * along with a buffer of the first few iterator elements in one network
+ * transmission.
+ */
+public class BufferIterator implements RemoteIterator, Serializable {
+
+    /** The element buffer. Set to <code>null</code> when the iterator ends. */
+    private Object[] buffer;
+
+    /** Cached size of the iterator. */
+    private final long size;
+
+    /** Remote iterator reference. */
+    private final RemoteIterator remote;
+
+    /**
+     * Creates a new buffered remote iterator.
+     *
+     * @param buffer first elements in the iterator
+     * @param size   total iterator size
+     * @param remote reference to the remaining iterator
+     */
+    public BufferIterator(Object[] buffer, long size, RemoteIterator remote) {
+        this.buffer = buffer;
+        this.size = size;
+        this.remote = remote;
+    }
+
+    /**
+     * Returns the cached size of the iterator.
+     *
+     * @return iterator size, or <code>-1</code> if unknown
+     * @see RemoteIterator#getSize()
+     */
+    public long getSize() {
+        return size;
+    }
+
+    /**
+     * Skips the given number of elements. First discards elements from the
+     * element buffer and only then contacts the remote iterator.
+     *
+     * @param items number of items to skip
+     * @throws IllegalArgumentException if <code>items</code> is negative
+     * @throws NoSuchElementException if skipped past the last element
+     * @throws RemoteException on RMI errors
+     * @see RemoteIterator#skip(long)
+     */
+    public void skip(long items)
+            throws IllegalArgumentException, NoSuchElementException,
+            RemoteException {
+        if (items < 0) {
+            throw new IllegalArgumentException("Negative skip is not allowed");
+        } else if (buffer == null && items > 0) {
+            throw new NoSuchElementException("Skipped past the last element");
+        } else if (items > buffer.length) {
+            remote.skip(items - buffer.length);
+            buffer = remote.nextObjects();
+        } else {
+            Object[] tmp = new Object[buffer.length - (int) items];
+            System.arraycopy(buffer, (int) items, tmp, 0, tmp.length);
+            buffer = tmp;
+        }
+    }
+
+    /**
+     * Returns the currently buffered elements and fills in the buffer
+     * with next elements.
+     *
+     * @return buffered elements, or <code>null</code> if the iterator has ended
+     * @throws RemoteException on RMI errors
+     * @see RemoteIterator#nextObjects()
+     */
+    public Object[] nextObjects() throws RemoteException {
+        if (buffer == null) {
+            return null;
+        } else {
+            Object[] tmp = buffer;
+            buffer = remote.nextObjects();
+            return tmp;
+        }
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/BufferIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteIterator.java?rev=365458&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteIterator.java Mon Jan  2 15:18:30 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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 org.apache.jackrabbit.rmi.remote;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.NoSuchElementException;
+
+/**
+ * Remote version of the JCR {@link javax.jcr.RangeIterator} interface.
+ * Used by the {@link org.apache.jackrabbit.rmi.server.iterator.ServerIterator} and
+ * {@link org.apache.jackrabbit.rmi.client.iterator.ClientIterator} classes to
+ * provide transparent RMI access to remote iterators.
+ * <p>
+ * This interface allows both the client and server side to control the
+ * amount of buffering used to increase performance.
+ */
+public interface RemoteIterator extends Remote {
+
+    /**
+     * Returns the size of the iteration, or <code>-1</code> if the
+     * size is unknown.
+     *
+     * @return size of the iteration, or <code>-1</code> if unknown
+     * @throws RemoteException on RMI errors
+     * @see javax.jcr.RangeIterator#getSize()
+     */
+    long getSize() throws RemoteException;
+
+    /**
+     * Skips the given number of elements in this iteration.
+     *
+     * @param items number of elements to skip
+     * @throws NoSuchElementException if skipped past the last element
+     * @throws RemoteException on RMI errors
+     * @see javax.jcr.RangeIterator#skip(long)
+     */
+    void skip(long items) throws NoSuchElementException, RemoteException;
+
+    /**
+     * Returns an array of remote references to the next elements in this
+     * iterator. Returns <code>null</code> if the end of this iteration has
+     * been reached.
+     * <p>
+     * To reduce the amount of remote method calls, this method returns an
+     * array of one or more elements in this iteration.
+     *
+     * @return array of remote references, or <code>null</code>
+     * @throws IllegalArgumentException if <code>maxItems</code> is not positive
+     * @throws RemoteException on RMI errors
+     * @see java.util.Iterator#next()
+     */
+    Object[] nextObjects() throws IllegalArgumentException, RemoteException;
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNode.java Mon Jan  2 15:18:30 2006
@@ -98,8 +98,7 @@
      * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    RemoteProperty[] getProperties()
-            throws RepositoryException, RemoteException;
+    RemoteIterator getProperties() throws RepositoryException, RemoteException;
 
     /**
      * Remote version of the
@@ -111,7 +110,7 @@
      * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    RemoteProperty[] getProperties(String pattern)
+    RemoteIterator getProperties(String pattern)
             throws RepositoryException, RemoteException;
 
     /**
@@ -142,8 +141,7 @@
      * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    RemoteProperty[] getReferences()
-            throws RepositoryException, RemoteException;
+    RemoteIterator getReferences() throws RepositoryException, RemoteException;
 
     /**
      * Remote version of the
@@ -153,7 +151,7 @@
      * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    RemoteNode[] getNodes() throws RepositoryException, RemoteException;
+    RemoteIterator getNodes() throws RepositoryException, RemoteException;
 
     /**
      * Remote version of the
@@ -164,7 +162,7 @@
      * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    RemoteNode[] getNodes(String pattern)
+    RemoteIterator getNodes(String pattern)
             throws RepositoryException, RemoteException;
 
     /**
@@ -402,7 +400,7 @@
      * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    RemoteNode[] merge(String workspace, boolean bestEffort)
+    RemoteIterator merge(String workspace, boolean bestEffort)
             throws RepositoryException, RemoteException;
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNodeTypeManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNodeTypeManager.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNodeTypeManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteNodeTypeManager.java Mon Jan  2 15:18:30 2006
@@ -69,7 +69,7 @@
      * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    RemoteNodeType[] getAllNodeTypes()
+    RemoteIterator getAllNodeTypes()
             throws RepositoryException, RemoteException;
 
     /**
@@ -81,7 +81,7 @@
      * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    RemoteNodeType[] getPrimaryNodeTypes()
+    RemoteIterator getPrimaryNodeTypes()
             throws RepositoryException, RemoteException;
 
     /**
@@ -93,7 +93,7 @@
      * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    RemoteNodeType[] getMixinNodeTypes()
+    RemoteIterator getMixinNodeTypes()
             throws RepositoryException, RemoteException;
 
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryResult.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryResult.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryResult.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryResult.java Mon Jan  2 15:18:30 2006
@@ -51,15 +51,15 @@
      * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    RemoteRow[] getRows() throws RepositoryException, RemoteException;
+    RemoteIterator getRows() throws RepositoryException, RemoteException;
 
     /**
      * @see javax.jcr.query.QueryResult#getNodes()
      *
-     * @return a <code>NodeIterator</code>
+     * @return a remote node iterator
      * @throws RepositoryException on repository errors
      * @throws RemoteException on RMI errors
      */
-    RemoteNode[] getNodes() throws RepositoryException, RemoteException;
+    RemoteIterator getNodes() throws RepositoryException, RemoteException;
 
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersionHistory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersionHistory.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersionHistory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteVersionHistory.java Mon Jan  2 15:18:30 2006
@@ -72,12 +72,11 @@
      * {@link javax.jcr.version.VersionHistory#getAllVersions() VersionHistory.getAllVersions()}
      * method.
      *
-     * @return a <code>VersionIterator</code> object.
+     * @return remote versions
      * @throws RepositoryException if an error occurs.
      * @throws RemoteException on RMI errors
      */
-    RemoteVersion[] getAllVersions()
-            throws RepositoryException, RemoteException;
+    RemoteIterator getAllVersions() throws RepositoryException, RemoteException;
 
     /**
      * Remote version of the

Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java?rev=365458&r1=365457&r2=365458&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java Mon Jan  2 15:18:30 2006
@@ -21,12 +21,15 @@
 import javax.jcr.Item;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.Node;
+import javax.jcr.NodeIterator;
 import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
 import javax.jcr.Repository;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
 import javax.jcr.lock.Lock;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.PropertyDefinition;
@@ -37,12 +40,15 @@
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
+import javax.jcr.version.VersionIterator;
 
 import org.apache.jackrabbit.rmi.remote.RemoteEventCollection;
 import org.apache.jackrabbit.rmi.remote.RemoteItem;
 import org.apache.jackrabbit.rmi.remote.RemoteItemDefinition;
+import org.apache.jackrabbit.rmi.remote.RemoteIterator;
 import org.apache.jackrabbit.rmi.remote.RemoteLock;
 import org.apache.jackrabbit.rmi.remote.RemoteNamespaceRegistry;
 import org.apache.jackrabbit.rmi.remote.RemoteNode;
@@ -294,4 +300,56 @@
      */
     RemoteEventCollection getRemoteEvent(long listenerId, EventIterator events)
         throws RemoteException;
+
+
+    /**
+     * Returns a remote adapter for the given local node iterator.
+     *
+     * @param iterator local node iterator
+     * @return remote iterator adapter
+     * @throws RemoteException on RMI errors
+     */
+    RemoteIterator getRemoteNodeIterator(NodeIterator iterator)
+        throws RemoteException;
+
+    /**
+     * Returns a remote adapter for the given local property iterator.
+     *
+     * @param iterator local property iterator
+     * @return remote iterator adapter
+     * @throws RemoteException on RMI errors
+     */
+    RemoteIterator getRemotePropertyIterator(PropertyIterator iterator)
+        throws RemoteException;
+
+    /**
+     * Returns a remote adapter for the given local version iterator.
+     *
+     * @param iterator local version iterator
+     * @return remote iterator adapter
+     * @throws RemoteException on RMI errors
+     */
+    RemoteIterator getRemoteVersionIterator(VersionIterator iterator)
+        throws RemoteException;
+
+    /**
+     * Returns a remote adapter for the given local node type iterator.
+     *
+     * @param iterator local node type iterator
+     * @return remote iterator adapter
+     * @throws RemoteException on RMI errors
+     */
+    RemoteIterator getRemoteNodeTypeIterator(NodeTypeIterator iterator)
+        throws RemoteException;
+
+    /**
+     * Returns a remote adapter for the given local row iterator.
+     *
+     * @param iterator local row iterator
+     * @return remote iterator adapter
+     * @throws RemoteException on RMI errors
+     */
+    RemoteIterator getRemoteRowIterator(RowIterator iterator)
+        throws RemoteException;
+
 }



Mime
View raw message