1 package client;
2
3 import java.rmi.Remote;
4 import java.rmi.RemoteException;
5 import java.math.BigDecimal;
6 import org.jstk.example.bank.Exceptions;
7 import org.jstk.example.bank.AccountIntf;
8 import common.RemoteAccount;
9
10public class AccountProxy implements AccountIntf {
11 private RemoteAccount racct = null;
12
13 public AccountProxy(RemoteAccount racct){
14 this.racct = racct;
15 }
16 public void deposit(BigDecimal amt) throws Exceptions.AccountClosed {
17 try {
18 racct.deposit(amt);
19 } catch (RemoteException re){
20 throw new RuntimeException(re);
21 }
22 }
23 public void withdraw(BigDecimal amt) throws Exceptions.AccountClosed,
24 Exceptions.InsufficientAmount {
25 try {
26 racct.withdraw(amt);
27 } catch (RemoteException re){
28 throw new RuntimeException(re);
29 }
30 }
31 public void close() throws Exceptions.AccountClosed {
32 try {
33 racct.close();
34 } catch (RemoteException re){
35 throw new RuntimeException(re);
36 }
37 }
38 public BigDecimal getBalance() throws Exceptions.AccountClosed {
39 try {
40 return racct.getBalance();
41 } catch (RemoteException re){
42 throw new RuntimeException(re);
43 }
44 }
45 public String getAcctNo(){
46 try {
47 return racct.getAcctNo();
48 } catch (RemoteException re){
49 throw new RuntimeException(re);
50 }
51 }
52 public String getStatement(){
53 try {
54 return racct.getStatement();
55 } catch (RemoteException re){
56 throw new RuntimeException(re);
57 }
58 }
59}
60