cscie160.project.atm
Class ATMImpl

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--cscie160.project.atm.ATMImpl
All Implemented Interfaces:
ATM, java.rmi.Remote, java.io.Serializable

public class ATMImpl
extends java.rmi.server.UnicastRemoteObject
implements ATM

By David Cheung

CSCIE160 Project

05-16-2001

ATMImpl implements ATM. At init time it will bind to Bank and Security interface. Also, it will create a vector to store callback objects.

To do (from specs in project): 1)notify all registered listeners of the transaction.

2) use security service to authenticate account info.

3) use security service to authorize operation on account.

4) Use bank to obtain account references

5) Use account references to perform transaction

See Also:
Serialized Form

Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
ATMImpl()
          Constructor: creates a linkedlist and 3 accounts.
 
Method Summary
 void addCallBack(ATMListener aListener)
          Adds call back.
 void deposit(AccountInfo anAccount, float amount)
          Deposit
 float getBalance(AccountInfo anAccount)
          getBalance
 void notifyAll(java.lang.String message)
          Sends notification method: when this is called, it will take in a TransactionNotification object and send it to everyone in the list.
 void transfer(AccountInfo fromAccount, AccountInfo toAccount, float amount)
          transfer
 void withdraw(AccountInfo anAccount, float amount)
          withdraw
 
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
 

Constructor Detail

ATMImpl

public ATMImpl()
        throws java.rmi.RemoteException
Constructor: creates a linkedlist and 3 accounts.
Method Detail

addCallBack

public void addCallBack(ATMListener aListener)
                 throws java.rmi.RemoteException
Adds call back.
Specified by:
addCallBack in interface ATM

notifyAll

public void notifyAll(java.lang.String message)
Sends notification method: when this is called, it will take in a TransactionNotification object and send it to everyone in the list. It will pick up the ATMListener client and invoke the getNotify method. The getNotify method basically prints out the message.

deposit

public void deposit(AccountInfo anAccount,
                    float amount)
             throws java.rmi.RemoteException,
                    UnpermittedTransactionException,
                    SecurityInvalidPinException
Deposit

Deposits money unto the account.

List of things to do: 1)notify all registered listeners of the transaction.

2) use security service to authenticate account info

3) use security service to authorize operation on account.

4) Use bank to obtain account references.

5) Use account references to perform transaction

6) catch throws various exceptions when neccessary.

Specified by:
deposit in interface ATM
Parameters:
userNum: - account number
amount: - amount to deposit

withdraw

public void withdraw(AccountInfo anAccount,
                     float amount)
              throws java.rmi.RemoteException,
                     UnpermittedTransactionException,
                     OverdrawnException,
                     SecurityInvalidPinException
withdraw

Withdraws money from a particular account

This will do:

1)notify all registered listeners of the transaction.

2) use security service to authenticate account info

3) use security service to authorize operation on account.

4) Use bank to obtain account references

5) Use account references to perform transaction

6) Throws exceptioni if neccessary

Specified by:
withdraw in interface ATM
Parameters:
AccountInfo: - account number and a PIn.
amount: - amount to withdraw.

getBalance

public float getBalance(AccountInfo anAccount)
                 throws java.rmi.RemoteException,
                        UnpermittedTransactionException,
                        SecurityInvalidPinException
getBalance

Returns the balance of the account.

Specified by:
getBalance in interface ATM
Parameters:
userNum: - AccountInfo

transfer

public void transfer(AccountInfo fromAccount,
                     AccountInfo toAccount,
                     float amount)
              throws java.rmi.RemoteException,
                     UnpermittedTransactionException,
                     OverdrawnException,
                     SecurityInvalidPinException
transfer

Withdraws money from the fromAccount and deposits it to the toAccount.

This will do:

1)notify all registered listeners of the transaction.

2) use security service to authenticate account info

3) use security service to authorize operation on account.

4) Use bank to obtain account references

5) Use account references to perform transaction

6) Throws exceptioni if neccessary

Specified by:
transfer in interface ATM
Parameters:
AccountInfo: - account number and a Pin of from account.
AccountInfo: - account number and pin of to account.
amount: - amount to transfer.