1
10package server;
11
12import java.rmi.Remote;
13import java.rmi.RemoteException;
14import java.rmi.server.UnicastRemoteObject;
15import java.math.BigDecimal;
16import org.jstk.example.bank.Exceptions;
17import org.jstk.example.bank.BankIntf;
18import common.RemoteBank;
19import common.RemoteAccount;
20import common.RemoteIterator;
21
22public class RemoteBankImpl extends UnicastRemoteObject implements RemoteBank {
23 private BankIntf bi;
24 public RemoteBankImpl(BankIntf bi) throws RemoteException {
25 this.bi = bi;
26 }
27 public RemoteAccount openAccount(BigDecimal initialDeposit) throws RemoteException {
28 return new RemoteAccountImpl(bi.openAccount(initialDeposit));
29 }
30 public void closeAccount(String acctNo) throws Exceptions.AccountNotFound,
31 Exceptions.AccountClosed, RemoteException {
32 bi.closeAccount(acctNo);
33 }
34 public RemoteAccount getAccount(String acctNo) throws Exceptions.AccountNotFound, RemoteException {
35 return new RemoteAccountImpl(bi.getAccount(acctNo));
36 }
37 public RemoteIterator accounts() throws RemoteException {
38 return new RemoteIteratorImpl(bi);
39 }
40}
41