1 /*
2  * @(#) $Id: RemoteBankImpl.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 server;
11
12import java.rmi.Remote;
13import java.rmi.RemoteException;
14import java.rmi.server.UnicastRemoteObject;
15import java.math.BigDecimal;
16import org.jstk.example.bank.Exceptions;
17import org.jstk.example.bank.BankIntf;
18import common.RemoteBank;
19import common.RemoteAccount;
20import common.RemoteIterator;
21
22public class RemoteBankImpl extends UnicastRemoteObject implements RemoteBank {
23    private BankIntf bi;
24    public RemoteBankImpl(BankIntf bi) throws RemoteException {
25        this.bi = bi;
26    }
27    public RemoteAccount openAccount(BigDecimal initialDeposit) throws RemoteException {
28        return new RemoteAccountImpl(bi.openAccount(initialDeposit));
29    }
30    public void closeAccount(String acctNo) throws Exceptions.AccountNotFound,
31            Exceptions.AccountClosed, RemoteException {
32        bi.closeAccount(acctNo);
33    }
34    public RemoteAccount getAccount(String acctNo) throws Exceptions.AccountNotFound, RemoteException {
35        return new RemoteAccountImpl(bi.getAccount(acctNo));
36    }
37    public RemoteIterator accounts() throws RemoteException {
38        return new RemoteIteratorImpl(bi);
39    }
40}
41