1
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