throws Exception
{
TellerHome home = (TellerHome)PortableRemoteObject.narrow(
getInitialContext().lookup(TellerHome.JNDI_NAME),
TellerHome.class);
Teller teller = home.create();
BankHome bankHome = (BankHome)PortableRemoteObject.narrow(
getInitialContext().lookup(BankHome.JNDI_NAME),
BankHome.class);
Bank bank = bankHome.create();
getLog().debug("Acquire customers");
Customer marc = teller.getCustomer("Marc");
Customer rickard = teller.getCustomer("Rickard");
getLog().debug("Acquire accounts");
Account from = teller.getAccount(marc, 200);
Account to = teller.getAccount(rickard, 200);
getLog().debug("Show balance");
getLog().debug(from.getPrimaryKey()+":"+from.getBalance());
getLog().debug(to.getPrimaryKey()+":"+to.getBalance());
getLog().debug("Transfer money");
long start = System.currentTimeMillis();
int iter = 10;
for (int i = 0; i < iter; i++)
teller.transfer(from, to, 50);
long end = System.currentTimeMillis();
getLog().info("Average call time: "+((end - start) / (iter*6)));
getLog().debug("Show balance");
AccountHome accountHome = (AccountHome)PortableRemoteObject.narrow(
getInitialContext().lookup(AccountHome.JNDI_NAME),
AccountHome.class);
Collection accts = accountHome.findAll();
Iterator i = accts.iterator();
while(i.hasNext())
{
Account acct = (Account)PortableRemoteObject.narrow(i.next(),
Account.class);
AccountData data = acct.getData();
getLog().debug(data.getId()+"("+data.getOwner().getName()+"):"+data.getBalance());
acct.withdraw(data.getBalance()); // Clear
}
teller.remove();
}