CoCoME TestDriver for Reference Implementation

org.cocome.tradingsystem.testdriver
Class Bank

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by org.cocome.tradingsystem.testdriver.Bank
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, org.cocome.tradingsystem.external.Bank, org.cocome.tradingsystem.systests.interfaces.IBank

public class Bank
extends java.rmi.server.UnicastRemoteObject
implements org.cocome.tradingsystem.systests.interfaces.IBank, org.cocome.tradingsystem.external.Bank

Implementation of a bank that we can control (as opposed to the bank coming with the implementation).

Version:
$Rev: 63 $
Author:
Benjamin Hummel, $Author: hummel $
See Also:
Serialized Form

Nested Class Summary
private static class Bank.CreditCard
          Data storage for credit card.
 
Field Summary
private  java.util.Map<java.lang.Integer,Bank.CreditCard> creditCards
          All available credit cards.
private static long serialVersionUID
          ID for serialization in the RMI context.
private static int TID_OFFSET
          The offset added to create a transaction ID from a card number.
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
protected Bank()
          Create a new Bank.
 
Method Summary
 void createCreditCard(int cardNumber, int pinNumber, int availableMoney)
          
 org.cocome.tradingsystem.external.Debit debitCard(org.cocome.tradingsystem.external.TransactionID id)
          
 void deleteCreditCard(int cardNumber)
          
private  int findCardFromTID(org.cocome.tradingsystem.external.TransactionID id)
          Extract the card number from a transaction ID.
 int getAvailableMoney(int cardNumber)
          
private  void register()
          Register at RMI.
 void unregister()
          Unregister from RMI.
 org.cocome.tradingsystem.external.TransactionID validateCard(java.lang.String cardInformation, int pinnumber)
          
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TID_OFFSET

private static final int TID_OFFSET
The offset added to create a transaction ID from a card number.

See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
ID for serialization in the RMI context.

See Also:
Constant Field Values

creditCards

private final java.util.Map<java.lang.Integer,Bank.CreditCard> creditCards
All available credit cards.

Constructor Detail

Bank

protected Bank()
        throws java.rmi.RemoteException
Create a new Bank.

Throws:
java.rmi.RemoteException
Method Detail

register

private void register()
               throws java.rmi.AccessException,
                      java.rmi.RemoteException
Register at RMI.

Throws:
java.rmi.AccessException
java.rmi.RemoteException

unregister

public void unregister()
                throws java.rmi.AccessException,
                       java.rmi.RemoteException,
                       java.rmi.NotBoundException
Unregister from RMI.

Throws:
java.rmi.AccessException
java.rmi.RemoteException
java.rmi.NotBoundException

createCreditCard

public void createCreditCard(int cardNumber,
                             int pinNumber,
                             int availableMoney)

Specified by:
createCreditCard in interface org.cocome.tradingsystem.systests.interfaces.IBank

deleteCreditCard

public void deleteCreditCard(int cardNumber)

Specified by:
deleteCreditCard in interface org.cocome.tradingsystem.systests.interfaces.IBank

getAvailableMoney

public int getAvailableMoney(int cardNumber)

Specified by:
getAvailableMoney in interface org.cocome.tradingsystem.systests.interfaces.IBank

debitCard

public org.cocome.tradingsystem.external.Debit debitCard(org.cocome.tradingsystem.external.TransactionID id)
                                                  throws java.rmi.RemoteException

Specified by:
debitCard in interface org.cocome.tradingsystem.external.Bank
Throws:
java.rmi.RemoteException

findCardFromTID

private int findCardFromTID(org.cocome.tradingsystem.external.TransactionID id)
Extract the card number from a transaction ID. This is not an efficient method, but the TransactionID class does not provide any access to its internals and also does not implement hashCode (although it should, when overriding equals).

Returns:
the number of the credit card contained in this TID, or -1 if no matching card was found.

validateCard

public org.cocome.tradingsystem.external.TransactionID validateCard(java.lang.String cardInformation,
                                                                    int pinnumber)
                                                             throws java.rmi.RemoteException

Specified by:
validateCard in interface org.cocome.tradingsystem.external.Bank
Throws:
java.rmi.RemoteException

CoCoME TestDriver for Reference Implementation

CoCoME TestDriver for Reference Implementation - 0.1