FileDocCategorySizeDatePackage
ImplLauncher.javaAPI DocExample1801Thu Nov 08 00:22:48 GMT 2001com.ora.rmibook.chapter13.bank.applications

ImplLauncher

public class ImplLauncher extends Object

Fields Summary
Constructors Summary
Methods Summary
private static java.util.CollectiongetNameBalancePairs(NameRepository nameRepository)

        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;
    
private static voidlaunchServer(com.ora.rmibook.chapter13.bank.applications.ImplLauncher$NameBalancePair serverDescription)

        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) {
        }
    
public static voidmain(java.lang.String[] args)

        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);
        }