com.imaginary.util
Interface DistributedIterator

All Known Implementing Classes:
DistributedIteratorImpl

public abstract interface DistributedIterator
extends java.rmi.Remote

Wraps an Iterator so that it can act as a distributed iterator. A distributed iterator is an iterator where the collection is stored on a server and elements are transmitted across the network one element at a time on demand. This contrasts with serialization of the collection, where the entire collection is transmitted across the network at once.

If you have a collection whose elements you want to make available across the network using the distributed iterator paradigm, you retrieve an iterator for the collection and wrap it with a DistributedIterator implementation. You then pass the distributed iterator to a ClientIterator and pass that across the network. Consider the following RMI method that returns a distributed iterator for its remote method cats():

 private ArrayList cats;
 
 public Iterator cats() throws RemoteException {
     DistributedIterator dist = new DistributedIteratorImpl(cats.iterator());
     ClientIterator it = new ClientIterator(dist);

     return it;
 }
 
The result of this method is that an empty iterator is sent across the network to the client. That empty iterator knows how to retrieve each cat from the cats ArrayList from the server on demand as the client application calls for them. If the client only asks for the first cat, only the first cat is ever sent across the network. If the collection of cats contains 1 million cats, the client does not need to wait on that entire collection to be transmitted across the network before it can access the first cat.
Last modified $Date: 1999/11/06 19:50:50 $


Method Summary
 boolean hasNext()
           
 java.lang.Object next()
           
 void remove()
          This operation is unsupported in this implementation.
 

Method Detail

hasNext

public boolean hasNext()
                throws java.rmi.RemoteException
Returns:
true if more elements are available in the iterator

next

public java.lang.Object next()
                      throws java.rmi.RemoteException
Returns:
the next element in the iterator

remove

public void remove()
            throws java.rmi.RemoteException
This operation is unsupported in this implementation.
Throws:
java.lang.UnsupportedOperationException - always thrown