commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From patri...@apache.org
Subject cvs commit: jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher LaunchCommand.java LaunchTask.java Launcher.java
Date Mon, 22 Jul 2002 05:41:39 GMT
patrickl    2002/07/21 22:41:39

  Modified:    daemon/src/bin launcher.xml
               daemon/src/java/org/apache/commons/launcher
                        LaunchCommand.java LaunchTask.java Launcher.java
  Log:
  Added the "debug" attribute to the <launch> task. This attribute, when set to true,
will run the target application in the JDB debugger.
  
  Revision  Changes    Path
  1.5       +30 -26    jakarta-commons-sandbox/daemon/src/bin/launcher.xml
  
  Index: launcher.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/bin/launcher.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- launcher.xml	20 Jul 2002 15:21:30 -0000	1.4
  +++ launcher.xml	22 Jul 2002 05:41:38 -0000	1.5
  @@ -4,12 +4,17 @@
   
     By default, the sample application will be launched in the background.
     To run it in the foreground, execute the Launcher with a "-Dwait=true"
  -  argument. Also, to run the sample application in JPDA mode, execute the
  -  Launcher with a "-Ddebug=true" argument.
  +  argument.
  +
  +  To run the sample application in the JDB debugger, execute the Launcher with
  +  a "-Ddebug=true" argument.
  +
  +  To run the sample application in JPDA mode, execute the Launcher with a
  +  "-Djpda=true" argument.
   
   -->
   
  -<project name="Launcher Sample" default="all" basedir=".">
  +<project name="Ant Launcher" default="ant" basedir=".">
   
     <!-- Set the application home to the parent directory of this directory -->
     <property name="app.home" location="${basedir}/.."/>
  @@ -24,14 +29,23 @@
       <sysproperty key="ant.home" file="${app.home}"/>
     </syspropertyset>
   
  -  <!-- Build the debug jvmargs -->
  -  <jvmargset id="debug.jvm.args">
  +  <!-- Build the standard jvmargs -->
  +  <jvmargset id="base.jvm.args">
  +    <jvmarg value="-sourcepath" if="jdb"/>
  +    <jvmarg path="${app.home}/../src/java" if="jdb"/>
       <jvmarg value="-Xdebug" if="jpda.settings"/>
       <jvmarg value="-Xrunjdwp:${jpda.settings}" if="jpda.settings"/>
     </jvmargset>
   
  -  <!-- Target that sets JPDA properties when the "debug" property is set -->
  -  <target name="setjpda" description="Set JPDA properties" if="debug">
  +  <!-- Target that sets JDB properties when the "debug" property is set -->
  +  <target name="setjdb" description="Set JDB properties" if="debug">
  +
  +    <property name="jdb" value="true"/>
  +
  +  </target>
  +
  +  <!-- Target that sets JPDA properties when the "jpda" property is set -->
  +  <target name="setjpda" description="Set JPDA properties" if="jpda">
   
       <condition property="jpda.transport" value="dt_shmem">
         <os family="windows"/>
  @@ -56,17 +70,7 @@
   
     <!-- Target that executes Ant -->
     <target name="ant" description="Execute Ant using the Launcher"
  -    depends="setjpda">
  -
  -    <!-- Set the defaults launch settings -->
  -    <property name="wait" value="false"/>
  -    <property name="read.system.in" value="false"/>
  -    <property name="require.tools" value="true"/>
  -    <property name="redirect.output" value="true"/>
  -    <property name="output" location="${app.home}/logs/ant.log"/>
  -    <property name="display.window" value="true"/>
  -    <property name="dispose.window" value="true"/>
  -    <property name="window.title" value="Sample Launcher Application"/>
  +    depends="setjdb,setjpda">
   
       <!--
         Execute Ant in a separate process. Note the use if "if" and "unless"
  @@ -74,14 +78,14 @@
        -->
       <launch classname="org.apache.tools.ant.Main"
         waitforchild="${wait}"
  -      usesystemin="${read.system.in}"
  -      requiretools="${require.tools}"
  -      redirectoutput="${redirect.output}"
  -      output="${output}"
  -      displayMinimizedWindow="${display.window}"
  -      disposeMinimizedWindow="${dispose.window}"
  -      minimizedWindowTitle="${window.title}">
  -        <jvmargset refid="debug.jvm.args"/>
  +      debug="${jdb}"
  +      requiretools="true"
  +      redirectoutput="true"
  +      output="${app.home}/logs/ant.log"
  +      displayMinimizedWindow="true"
  +      disposeMinimizedWindow="true"
  +      minimizedWindowTitle="Ant">
  +        <jvmargset refid="base.jvm.args"/>
           <syspropertyset refid="base.sys.properties"/>
           <classpath refid="base.class.path"/>
       </launch>
  
  
  
  1.4       +54 -0     jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchCommand.java
  
  Index: LaunchCommand.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchCommand.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LaunchCommand.java	20 Jul 2002 15:21:30 -0000	1.3
  +++ LaunchCommand.java	22 Jul 2002 05:41:39 -0000	1.4
  @@ -83,6 +83,11 @@
       private String classpath = null;
   
       /**
  +     * Cached debug flag.
  +     */
  +    private boolean debug = false;
  +
  +    /**
        * Cached displayMinimizedWindow flag.
        */
       private boolean displayMinimizedWindow = false;
  @@ -93,6 +98,11 @@
       private boolean disposeMinimizedWindow = true;
   
       /**
  +     * Cached failOnError flag.
  +     */
  +    private boolean failOnError = true;
  +
  +    /**
        * Cached main class name.
        */
       private String mainClassName = null;
  @@ -167,6 +177,17 @@
       }
   
       /**
  +     * Get the debug flag.
  +     *
  +     * @return the debug flag
  +     */
  +    public boolean getDebug() {
  +
  +        return debug;
  +
  +    }
  +
  +    /**
        * Get the displayMinimizedWindow flag.
        *
        * @return the displayMinimizedWindow flag
  @@ -189,6 +210,17 @@
       }
   
       /**
  +     * Get the failOnError flag.
  +     *
  +     * @return the failOnError flag
  +     */
  +    public boolean getFailonerror() {
  +
  +        return failOnError;
  +
  +    }
  +
  +    /**
        * Get the title for the minimized window that will be displayed in the
        * Windows taskbar.
        *
  @@ -357,6 +389,17 @@
       }
   
       /**
  +     * Set the debug flag.
  +     *
  +     * @param debug the debug flag 
  +     */
  +    public void setDebug(boolean debug) {
  +
  +        this.debug = debug;
  +
  +    }
  +
  +    /**
        * Set the displayMinimizedWindow flag. Note that this flag has no effect
        * on non-Windows platforms. On Windows platform, setting this flag to true
        * will cause a minimized window to be displayed in the Windows task bar
  @@ -392,6 +435,17 @@
       public void setDisposeminimizedwindow(boolean disposeMinimizedWindow) {
   
           this.disposeMinimizedWindow = displayMinimizedWindow;
  +
  +    }
  +
  +    /**
  +     * Set the failOnError flag.
  +     *
  +     * @param failOnError the failOnError flag 
  +     */
  +    public void setFailonerror(boolean failOnError) {
  +
  +        this.failOnError = failOnError;
   
       }
   
  
  
  
  1.18      +33 -2     jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchTask.java
  
  Index: LaunchTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchTask.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- LaunchTask.java	22 Jul 2002 04:59:06 -0000	1.17
  +++ LaunchTask.java	22 Jul 2002 05:41:39 -0000	1.18
  @@ -136,6 +136,11 @@
       private Path classpath = null;
   
       /**
  +     * Cached debug flag.
  +     */
  +    private boolean debug = false;
  +
  +    /**
        * Cached displayMinimizedWindow flag.
        */
       private boolean displayMinimizedWindow = false;
  @@ -426,8 +431,10 @@
               boolean filteredRedirect = redirect;
               File filteredOutputFile = outputFile;
               boolean filteredAppendOutput = appendOutput;
  +            boolean filteredDebug = debug;
               boolean filteredDisplayMinimizedWindow = displayMinimizedWindow;
               boolean filteredDisposeMinimizedWindow = disposeMinimizedWindow;
  +            boolean filteredFailOnError = failOnError;
               String filteredMinimizedWindowTitle = minimizedWindowTitle;
               File filteredMinimizedWindowIcon = minimizedWindowIcon;
               boolean filteredUseSystemIn = useSystemIn;
  @@ -460,8 +467,10 @@
                            command.setRedirectoutput(filteredRedirect);
                            command.setOutput(filteredOutputFile);
                            command.setAppendoutput(filteredAppendOutput);
  +                         command.setDebug(filteredDebug);
                            command.setDisplayminimizedwindow(filteredDisplayMinimizedWindow);
                            command.setDisposeminimizedwindow(filteredDisposeMinimizedWindow);
  +                         command.setFailonerror(filteredFailOnError);
                            command.setMinimizedwindowtitle(filteredMinimizedWindowTitle);
                            command.setMinimizedwindowicon(filteredMinimizedWindowIcon);
                            command.setUsesystemin(filteredUseSystemIn);
  @@ -475,8 +484,10 @@
                            filteredRedirect = command.getRedirectoutput();
                            filteredOutputFile = command.getOutput();
                            filteredAppendOutput = command.getAppendoutput();
  +                         filteredDebug = command.getDebug();
                            filteredDisplayMinimizedWindow = command.getDisplayminimizedwindow();
                            filteredDisposeMinimizedWindow = command.getDisposeminimizedwindow();
  +                         filteredFailOnError = command.getFailonerror();
                            filteredMinimizedWindowTitle = command.getMinimizedwindowtitle();
                            filteredMinimizedWindowIcon = command.getMinimizedwindowicon();
                            filteredUseSystemIn = command.getUsesystemin();
  @@ -500,6 +511,11 @@
                    }
               }
   
  +            // Force child JVM into foreground if running using JDB
  +            if (filteredDebug) {
  +                filteredWaitForChild = true;
  +                filteredUseSystemIn = true;
  +            }
   
               // Prepend this package's classpath
               if (filteredClasspath != null) {
  @@ -572,7 +588,10 @@
               // Assemble child command
               String[] cmd = new String[5 + jvmArgs.size() + sysProps.size() + appArgs.size()];
               int nextCmdArg = 0;
  -            cmd[nextCmdArg++] = Launcher.getJavaCommand();
  +            if (filteredDebug)
  +                cmd[nextCmdArg++] = Launcher.getJDBCommand();
  +            else
  +                cmd[nextCmdArg++] = Launcher.getJavaCommand();
               // Add jvmArgs to command
               for (int i = 0; i < jvmArgs.size(); i++)
                   cmd[nextCmdArg++] = (String)jvmArgs.get(i);
  @@ -628,7 +647,7 @@
                   stdout.join();
                   stderr.join();
                   int exitValue = proc.exitValue();
  -                if (failOnError && exitValue != 0)
  +                if (filteredFailOnError && exitValue != 0)
                       throw new BuildException(Launcher.getLocalizedString("child.failed",
this.getClass().getName()) + " " + exitValue);
               }
               // Need to check if the launching process has stopped because
  @@ -730,6 +749,18 @@
       public void setClasspathref(Reference ref) {
   
           createClasspath().setRefid(ref);
  +
  +    }
  +
  +    /**
  +     * Set the debug flag. Setting this flag to true will cause this
  +     * task to run the child JVM using the JDB debugger.
  +     *
  +     * @param debug the debug flag
  +     */
  +    public void setDebug(boolean debug) {
  +
  +        this.debug = debug;
   
       }
   
  
  
  
  1.13      +28 -0     jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/Launcher.java
  
  Index: Launcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/Launcher.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Launcher.java	22 Jul 2002 04:59:06 -0000	1.12
  +++ Launcher.java	22 Jul 2002 05:41:39 -0000	1.13
  @@ -123,6 +123,11 @@
       private static String javaCmd = null;
   
       /**
  +     * Cached JDB command
  +     */
  +    private static String jdbCmd = null;
  +
  +    /**
        * Shared lock.
        */
       private static Object lock = new Object();
  @@ -606,6 +611,29 @@
           }
   
           return javaCmd;
  +
  +    }
  +
  +    /**
  +     * Get the full path of the JDB command to execute.
  +     *
  +     * @return a string suitable for executing a child JDB debugger
  +     */
  +    public static synchronized String getJDBCommand() {
  +
  +        if (jdbCmd == null) {
  +
  +            String osname = System.getProperty("os.name").toLowerCase();
  +            String commandName = null;
  +            if (osname.indexOf("windows") >= 0)
  +                commandName = "jdb.exe";
  +            else
  +                commandName = "jdb";
  +            jdbCmd = new File(System.getProperty("java.home")).getParent() + File.separator
+ "bin" + File.separator + commandName;
  +
  +        }
  +
  +        return jdbCmd;
   
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message