1
10package client;
11
12import java.rmi.Remote;
13import java.rmi.RemoteException;
14import java.math.BigDecimal;
15import java.util.Iterator;
16import org.jstk.example.bank.Exceptions;
17import org.jstk.example.bank.BankIntf;
18import org.jstk.example.bank.AccountIntf;
19import common.RemoteBank;
20import common.RemoteAccount;
21
22public class BankProxy implements BankIntf {
23 private RemoteBank rb;
24 public BankProxy(RemoteBank rb){
25 this.rb = rb;
26 }
27 public AccountIntf openAccount(BigDecimal initialDeposit){
28 try {
29 return new AccountProxy(rb.openAccount(initialDeposit));
30 } catch (RemoteException re){
31 throw new RuntimeException(re);
32 }
33 }
34 public void closeAccount(String acctNo) throws Exceptions.AccountNotFound,
35 Exceptions.AccountClosed {
36 try {
37 rb.closeAccount(acctNo);
38 } catch (RemoteException re){
39 throw new RuntimeException(re);
40 }
41 }
42 public AccountIntf getAccount(String acctNo) throws Exceptions.AccountNotFound {
43 try {
44 return new AccountProxy(rb.getAccount(acctNo));
45 } catch (RemoteException re){
46 throw new RuntimeException(re);
47 }
48 }
49 public Iterator accounts() {
50 try {
51 return new IteratorProxy(rb.accounts());
52 } catch (RemoteException re){
53 throw new RuntimeException(re);
54 }
55 }
56}
57