1 /*
2  * @(#) $Id: AccountProxy.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 org.jstk.example.bank.Exceptions;
16import org.jstk.example.bank.AccountIntf;
17import common.RemoteAccount;
18
19public class AccountProxy implements AccountIntf {
20    private RemoteAccount racct = null;
21
22    public AccountProxy(RemoteAccount racct){
23        this.racct = racct;
24    }
25    public void deposit(BigDecimal amt) throws Exceptions.AccountClosed {
26        try {
27            racct.deposit(amt);
28        } catch (RemoteException re){
29            throw new RuntimeException(re);
30        }
31    }
32    public void withdraw(BigDecimal amt) throws Exceptions.AccountClosed,
33            Exceptions.InsufficientAmount {
34        try {
35        racct.withdraw(amt);
36        } catch (RemoteException re){
37            throw new RuntimeException(re);
38        }
39    }
40    public void close() throws Exceptions.AccountClosed {
41        try {
42        racct.close();
43        } catch (RemoteException re){
44            throw new RuntimeException(re);
45        }
46    }
47    public BigDecimal getBalance() throws Exceptions.AccountClosed {
48        try {
49        return racct.getBalance();
50        } catch (RemoteException re){
51            throw new RuntimeException(re);
52        }
53    }
54    public String getAcctNo(){
55        try {
56        return racct.getAcctNo();
57        } catch (RemoteException re){
58            throw new RuntimeException(re);
59        }
60    }
61    public String getStatement(){
62        try {
63        return racct.getStatement();
64        } catch (RemoteException re){
65            throw new RuntimeException(re);
66        }
67    }
68}
69