1 package server;
2
3 import java.rmi.RemoteException;
4 import java.rmi.server.UnicastRemoteObject;
5 import java.util.Iterator;
6 import org.jstk.example.bank.BankIntf;
7 import org.jstk.example.bank.AccountIntf;
8
9 import common.RemoteIterator;
10
11public class RemoteIteratorImpl extends UnicastRemoteObject implements RemoteIterator {
12 private BankIntf bi;
13 private Iterator itr;
14 public RemoteIteratorImpl(BankIntf bi) throws RemoteException {
15 this.bi = bi;
16 itr = bi.accounts();
17 }
18 public RemoteIteratorImpl(BankIntf bi, int port,
19 java.rmi.server.RMIClientSocketFactory clientFactory,
20 java.rmi.server.RMIServerSocketFactory serverFactory) throws java.rmi.RemoteException {
21 super(port, clientFactory, serverFactory);
22 this.bi = bi;
23 itr = bi.accounts();
24 }
25 public boolean hasNext() throws RemoteException {
26 return itr.hasNext();
27 }
28 public Object next() throws RemoteException {
29 return new RemoteAccountImpl((AccountIntf)itr.next());
30 }
31 public void remove() throws RemoteException {
32 itr.remove();
33 }
34}
35