FileDocCategorySizeDatePackage
ActivationLauncher.javaAPI DocExample2521Thu Nov 08 00:23:04 GMT 2001com.ora.rmibook.chapter17.activation.applications

ActivationLauncher

public class ActivationLauncher extends Object

Fields Summary
Constructors Summary
Methods Summary
private static ActivationDesccreateActivationDesc(java.lang.String owner, Money moneyToStart)

        return new ActivationDesc("com.ora.rmibook.chapter17.activation.Account_Impl", "file:/D:/Classes/",
                new MarshalledObject(moneyToStart));
    
private static ActivationGroupcreateActivationGroup()

        Properties pList = new Properties();

        pList.put("java.security.policy", "d:\\java.policy");
        ActivationGroupDesc.CommandEnvironment configInfo = null;
        ActivationGroupDesc description = new ActivationGroupDesc(pList, configInfo);
        ActivationGroupID id = (ActivationGroup.getSystem()).registerGroup(description);

        return ActivationGroup.createGroup(id, description, 0);
    
private static voidcreateBankAccount(java.lang.String owner, Money money)

        try {
            ActivationDesc aD = createActivationDesc(owner, money);
            Account account = (Account) Account_Impl.register(aD);

            Naming.rebind(owner, account);
        } catch (Exception e) {
            System.out.println("Failed to create account for " + owner);
            e.printStackTrace();
        }
    
private static voidcreateBankAccounts()

        createBankAccount("Bob", getRandomMoney());
        createBankAccount("Tom", getRandomMoney());
        createBankAccount("Hans", getRandomMoney());
        createBankAccount("Bill", getRandomMoney());
        createBankAccount("Yolanda", getRandomMoney());
        createBankAccount("Dave", getRandomMoney());
    
private static MoneygetRandomMoney()

        int cents = (int) (Math.random() * 100000);

        return new Money(cents);
    
public static voidmain(java.lang.String[] args)

        try {
            ActivationGroup activationGroup = createActivationGroup();
        } catch (Exception e) {
            System.out.println("Utter Failure.");
            e.printStackTrace();
            System.exit(0);
        }
        createBankAccounts();
        System.exit(0);