1 /*
2  * @(#) $Id: BankProxy.java,v 1.2 2003/07/08 08:13:52 pankaj Exp $
3  *
4  * Copyright (c) 2002-03 by Pankaj Kumar (http://www.pankaj-k.net). 
5  * All rights reserved.
6  *
7  * The license governing the use of this file can be found in the 
8  * root directory of the containing software.
9  */
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