FileDocCategorySizeDatePackage
LoggingImplLauncher.javaAPI DocExample3642Thu Nov 08 00:23:02 GMT 2001com.ora.rmibook.chapter16

LoggingImplLauncher

public class LoggingImplLauncher extends Object

Fields Summary
Constructors Summary
Methods Summary
private static java.util.CollectiongetNameBalancePairs(java.lang.String[] args)

        int i;
        ArrayList returnValue = new ArrayList();

        for (i = 0; i < args.length; i += 2) {
            NameBalancePair nextNameBalancePair = new NameBalancePair();

            nextNameBalancePair.name = args[i];
            int cents = (new Integer(args[i + 1])).intValue();

            nextNameBalancePair.balance = new Money(cents);
            returnValue.add(nextNameBalancePair);
        }
        return returnValue;
    
private static voidlaunchServer(com.ora.rmibook.chapter16.LoggingImplLauncher$NameBalancePair serverDescription)

        try {
            Account_Impl newAccount = new Account_Impl(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)

        setLogFiles();
        setLogProperties();
        Collection nameBalancePairs = getNameBalancePairs(args);
        Iterator i = nameBalancePairs.iterator();

        while (i.hasNext()) {
            NameBalancePair nextNameBalancePair = (NameBalancePair) i.next();

            launchServer(nextNameBalancePair);
        }
    
private static voidsetLogFiles()

        try {
            FileOutputStream transportLogFile = new FileOutputStream("C:\\temp\\transportLogFile");
            FileOutputStream proxyLogFile = new FileOutputStream("C:\\temp\\proxyLogFile");
            FileOutputStream tcpLogFile = new FileOutputStream("C:\\temp\\tcpLogFile");
            FileOutputStream dgcLogFile = new FileOutputStream("C:\\temp\\dgcLogFile");
            FileOutputStream loaderLogFile = new FileOutputStream("C:\\temp\\loaderLogFile");
            FileOutputStream systemDotErr = new FileOutputStream("C:\\temp\\systemDotErr");

            LogStream.log("transport").setOutputStream(transportLogFile);
            LogStream.log("proxy").setOutputStream(proxyLogFile);
            LogStream.log("tcp").setOutputStream(tcpLogFile);
            LogStream.log("dgc").setOutputStream(dgcLogFile);
            LogStream.log("loader").setOutputStream(loaderLogFile);
            FileOutputStream logFile = new FileOutputStream("C:\\temp\\foo");

            RemoteServer.setLog(logFile);
            System.setErr(new PrintStream(systemDotErr));
        } catch (Exception e) {
            System.out.println("Failed to open log files");
        }
    
private static voidsetLogProperties()

        System.getProperties().put("java.rmi.server.logCalls", "true");
        System.getProperties().put("sun.rmi.log.debug", "true");
        System.getProperties().put("sun.rmi.dgc.logLevel", "verbose");
        System.getProperties().put("sun.rmi.server.logLevel", "verbose");
        System.getProperties().put("sun.rmi.loader.logLevel", "verbose");
        System.getProperties().put("sun.rmi.transport.logLevel", "verbose");
        System.getProperties().put("sun.rmi.transport.proxy.logLevel", "verbose");
        System.getProperties().put("sun.rmi.transport.tcp.logLevel", "verbose");