Java Reference
In-Depth Information
Example 16−1: Bank.java (continued)
/**
* This class is a placeholder that simply contains other classes and
* for interfaces remote banking.
**/
public class Bank {
/**
* This is the interface that defines the exported methods of the
* bank server.
**/
public interface RemoteBank extends Remote {
/** Open a new account, with the specified name and password */
public void openAccount(String name, String password)
throws RemoteException, BankingException;
/** Close the named account */
public FunnyMoney closeAccount(String name, String password)
throws RemoteException, BankingException;
/** Deposit money into the named account */
public void deposit(String name, String password, FunnyMoney money)
throws RemoteException, BankingException;
/** Withdraw the specified amount of money from the named account */
public FunnyMoney withdraw(String name, String password, int amount)
throws RemoteException, BankingException;
/** Return the amount of money in the named account */
public int getBalance(String name, String password)
throws RemoteException, BankingException;
/**
* Return a List of Strings that list the transaction history
* of the named account
**/
public List getTransactionHistory(String name, String password)
throws RemoteException, BankingException;
}
/**
* This simple class represents a monetary amount. This implementation
* is really nothing more than a wrapper around an integer. It is a useful
* to demonstrate that RMI can accept arbitrary non-String objects as
* arguments and return them as values, as long as they are Serializable.
* A more complete implementation of this FunnyMoney class might bear
* a serial number, a digital signature, and other security features to
* ensure that it is unique and non-forgeable.
**/
public static class FunnyMoney implements java.io.Serializable {
public int amount;
public FunnyMoney(int amount) { this.amount = amount; }
}
/**
* This is a type of exception used to represent exceptional conditions
* related to banking, such as "Insufficient Funds" and "Invalid Password"
**/
public static class BankingException extends Exception {
public BankingException(String msg) { super(msg); }
Search WWH ::




Custom Search