FileDocCategorySizeDatePackage
SecondLauncher.javaAPI DocExample2735Thu Nov 08 00:23:16 GMT 2001com.ora.rmibook.chapter18.activation.applications

SecondLauncher

public class SecondLauncher extends Object

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

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

        ActivationGroupID oldID = ActivationGroup.currentGroupID();
        Properties pList = new Properties();

        pList.put("sun.rmi.transport.connectionTimeout", "30000");
        pList.put("java.security.policy", "d:\\java.policy");
        pList.put(USE_MONITORING_SOCKETS_PROPERTY, USE_MONITORING_SOCKETS_VALUE);
        ActivationGroupDesc.CommandEnvironment configInfo = null;
        ActivationGroupDesc description = new ActivationGroupDesc(pList, configInfo);
        ActivationGroupID id = (ActivationGroup.getSystem()).registerGroup(description);

        ActivationGroup.createGroup(id, description, 0);
        return;
    
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()

        createActivationGroup();
        createBankAccount("Jim", getRandomMoney());
        createBankAccount("Jack", getRandomMoney());
        createBankAccount("Julia", getRandomMoney());
    
private static MoneygetRandomMoney()

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

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

         
        try {
            createBankAccounts();
        } catch (Exception e) {
            System.out.println("Launch Failure.");
            e.printStackTrace();
        }
        System.exit(0);