Ignore:
Timestamp:
12/05/11 14:49:53 (12 years ago)
Author:
sherbold
Message:
  • JFCMonitor now writes to a logfile jfcmonitor.log located in the working directory.
  • logged information now includes the symbolic name of the GUI components (optional, may be null)
  • code documentation and formatting
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JFCMonitor/src/de/ugoe/cs/eventbench/jfcmonitor/Runner.java

    r268 r271  
    11package de.ugoe.cs.eventbench.jfcmonitor; 
     2 
    23import java.awt.AWTEvent; 
    34import java.awt.Toolkit; 
    45import java.awt.event.AWTEventListener; 
     6import java.io.FileWriter; 
     7import java.io.IOException; 
    58import java.io.OutputStreamWriter; 
    69import java.util.Arrays; 
    710 
    8  
     11/** 
     12 * <p> 
     13 * Start-up class of the application. 
     14 * </p> 
     15 * <p> 
     16 * Launches the application under test in the same JVM. 
     17 * </p> 
     18 *  
     19 * @author Steffen Herbold 
     20 * @version 1.0 
     21 */ 
    922public class Runner { 
    1023 
    11         public static void main(String[] args) throws Exception { 
    12                 AWTEventListener listener = new JFCListener(new OutputStreamWriter(System.out)); 
    13                  
    14                 Toolkit.getDefaultToolkit().addAWTEventListener(listener, 
     24        /** 
     25         * <p> 
     26         * Name of the log file. 
     27         * </p> 
     28         */ 
     29        private final static String logfileName = "jfcmonitor.log"; 
     30 
     31        /** 
     32         * <p> 
     33         * Debugging variable. If set to true, the logging is also written to the 
     34         * console. 
     35         * </p> 
     36         */ 
     37        private final static boolean stdOutputWrite = true; 
     38 
     39        /** 
     40         * <p> 
     41         * Main method of the application. 
     42         * </p> 
     43         *  
     44         * @param args 
     45         *            the first parameter defines the Jar file that contains the 
     46         *            start-up information of the application under test. The 
     47         *            remaining parameters are passed on the toe application under 
     48         *            test. 
     49         */ 
     50        public static void main(String[] args) { 
     51                FileWriter writer; 
     52                try { 
     53                        // the writer is not closed explicitly! 
     54                        writer = new FileWriter(logfileName, true); 
     55                        writer.write("<newsession />"); 
     56                } catch (IOException e) { 
     57                        System.err.println("JFCMONITOR -- failure opening logfile: " 
     58                                        + e.getMessage()); 
     59                        return; 
     60                } 
     61 
     62                AWTEventListener listenerFile = new JFCListener(writer); 
     63                Toolkit.getDefaultToolkit().addAWTEventListener(listenerFile, 
    1564                                AWTEvent.KEY_EVENT_MASK); 
    16                 Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK); 
    17                  
    18                 JarLauncher launcher = new JarLauncher(args[0], Arrays.copyOfRange(args, 1, args.length)); 
     65                Toolkit.getDefaultToolkit().addAWTEventListener(listenerFile, 
     66                                AWTEvent.MOUSE_EVENT_MASK); 
     67 
     68                if (stdOutputWrite) { 
     69                        AWTEventListener listenerStdOut = new JFCListener( 
     70                                        new OutputStreamWriter(System.out)); 
     71                        Toolkit.getDefaultToolkit().addAWTEventListener(listenerStdOut, 
     72                                        AWTEvent.KEY_EVENT_MASK); 
     73                        Toolkit.getDefaultToolkit().addAWTEventListener(listenerStdOut, 
     74                                        AWTEvent.MOUSE_EVENT_MASK); 
     75                } 
     76 
     77                JarLauncher launcher = new JarLauncher(args[0], Arrays.copyOfRange( 
     78                                args, 1, args.length)); 
    1979                launcher.exec(); 
    2080        } 
Note: See TracChangeset for help on using the changeset viewer.