ArrayList returnValue = new ArrayList(); Iterator i = nameRepository.getAllNames(); while (i.hasNext()) { NameBalancePair nextNameBalancePair = new NameBalancePair(); nextNameBalancePair.name = (String) i.next(); int cents = (int) (Math.random() * 100000); nextNameBalancePair.balance = new Money(cents); returnValue.add(nextNameBalancePair); } return returnValue;
try { Account3_Impl2 newAccount = new Account3_Impl2(serverDescription.balance); Naming.rebind(serverDescription.name, newAccount); System.out.println("Account " + serverDescription.name + " successfully launched."); } catch (Exception e) { }
int numberOfServers = (Integer.valueOf(args[0])).intValue(); NameRepository nameRepository = new NameRepository(numberOfServers); Collection nameBalancePairs = getNameBalancePairs(nameRepository); Iterator i = nameBalancePairs.iterator(); while (i.hasNext()) { NameBalancePair nextNameBalancePair = (NameBalancePair) i.next(); launchServer(nextNameBalancePair); }