FileDocCategorySizeDatePackage
AccountImplPOA.javaAPI DocExample3782Thu Dec 15 21:48:26 GMT 2005com.oreilly.jent.corba

AccountImplPOA

public class AccountImplPOA extends AccountPOA
AccountImplPOA: Implementation of the Account remote interface, based on the CORBA 2.3 (POA-compliant) version of the IDL-to-Java mapping (introduced in JDK 1.4).

Fields Summary
private float
mBalance
private String
mName
Constructors Summary
public AccountImplPOA(String name)

  // Create a new account with the given name
     
    mName = name;
  
Methods Summary
private booleancheckTransfer(Account src, float amt)

    boolean approved = false;
    if (src.getBalance() >= amt) {
      approved = true;
    }
    return approved;
  
public voiddeposit(float amt)

    mBalance += amt;
    // Log transaction...
    System.out.println("--> Deposited " + amt + " into account " + getName());
    System.out.println("    New balance: " + getBalance());
  
public floatgetBalance()

    return mBalance;
  
public java.lang.StringgetName()

    return mName;
  
public voidtransfer(float amt, Account src)

    if (checkTransfer(src, amt)) {
      src.withdraw(amt);
      this.deposit(amt);
      // Log transaction...
      System.out.println("--> Transferred " + amt + " from account " + getName());
      System.out.println("    New balance: " + getBalance());
    }
    else {
      throw new InsufficientFundsException("Source account balance is less " +
                                           "than the requested transfer.");
    }
  
public voidtransferBatch(float[] amts, Account[] srcs)

    // Iterate through the accounts and the amounts to be
    // transferred from each
    for (int i = 0; i < amts.length; i++) {
      float amt = amts[i];
      Account src = srcs[i];
      // Make the transaction
      this.transfer(amt, src);
    }
  
public voidwithdraw(float amt)

    if (mBalance >= amt) {
      mBalance -= amt;
      // Log transaction...
      System.out.println("--> Withdrew " + amt + " from account " + getName());
      System.out.println("    New balance: " + getBalance());
    }
    else {
      throw new InsufficientFundsException("Withdrawal request of " + amt +
                                           " exceeds balance of " + mBalance);
    }