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 LaunchTask.java Launcher.java
Date Wed, 24 Jul 2002 15:44:37 GMT
patrickl    2002/07/24 08:44:37

  Modified:    daemon/src/java LauncherBootstrap.java
               daemon/src/java/org/apache/commons/launcher LaunchTask.java
                        Launcher.java
  Log:
  Have the Launcher.start() method and System.exit() in LauncherBootstrap return the exit
value of the last synchronous child JVM executed.
  
  Revision  Changes    Path
  1.8       +3 -4      jakarta-commons-sandbox/daemon/src/java/LauncherBootstrap.java
  
  Index: LauncherBootstrap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/LauncherBootstrap.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LauncherBootstrap.java	23 Jul 2002 23:32:23 -0000	1.7
  +++ LauncherBootstrap.java	24 Jul 2002 15:44:36 -0000	1.8
  @@ -193,7 +193,9 @@
               // If the ant.class.path property is not set correctly in the 
               // LAUNCHER_PROPS_FILE_NAME, this will throw an exception.
               Method startMethod = launcherClass.getDeclaredMethod("start", new Class[]{
String[].class, File.class });
  -            startMethod.invoke(null, new Object[]{ args, launchFile });
  +            int returnValue = ((Integer)startMethod.invoke(null, new Object[]{ args, launchFile
})).intValue();
  +            // Always exit cleanly after invoking the start() method
  +            System.exit(returnValue);
   
          } catch (Throwable t) {
   
  @@ -201,9 +203,6 @@
              System.exit(1);
   
           }
  -
  -        // Always exit cleanly
  -        System.exit(0);
   
       }
   
  
  
  
  1.20      +1 -9      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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- LaunchTask.java	24 Jul 2002 01:42:26 -0000	1.19
  +++ LaunchTask.java	24 Jul 2002 15:44:36 -0000	1.20
  @@ -627,7 +627,7 @@
                   // Add the synchronous child process
                   if (filteredWaitForChild) {
                       childProc = proc;
  -                    LaunchTask.childProcesses.add(childProc);
  +                    LaunchTask.childProcesses.add(proc);
                   }
               }
               if (filteredWaitForChild) {
  @@ -662,14 +662,6 @@
                   throw new BuildException(Launcher.getLocalizedString("launch.task.stopped",
this.getClass().getName()));
               else 
                   throw new BuildException(e);
  -        } finally {
  -            // Remove the synchronous child process
  -            synchronized (LaunchTask.childProcesses) {
  -                if (childProc != null) {
  -                    LaunchTask.childProcesses.remove(childProc);
  -                    childProc = null;
  -                }
  -            }
           }
   
       }
  
  
  
  1.15      +11 -6     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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Launcher.java	23 Jul 2002 23:32:23 -0000	1.14
  +++ Launcher.java	24 Jul 2002 15:44:36 -0000	1.15
  @@ -225,12 +225,12 @@
        *
        * @param args command line arguments
        * @param launchFile the XML file to execute
  -     * @return true if this method completed without error and false if an
  -     *  error occurred or this method was stopped
  +     * @return the exit value of the last synchronous child JVM that was
  +     *  launched or 1 if any other error occurs
        * @throws IllegalArgumentException if any error parsing the args parameter
        *  occurs
        */
  -    public static boolean start(String[] args, File launchFile)
  +    public static int start(String[] args, File launchFile)
           throws IllegalArgumentException
      {
   
  @@ -238,11 +238,11 @@
           // already running since we do not support concurrency
           synchronized (Launcher.lock) {
               if (Launcher.isStarted() || Launcher.isStopped())
  -                return false;
  +                return 1;
               Launcher.setStarted(true);
           }
   
  -        boolean returnValue = true;
  +        int returnValue = 0;
           ClassLoader parentLoader = null;
           Thread shutdownHook = new Thread(new Launcher());
           Runtime runtime = Runtime.getRuntime();
  @@ -386,7 +386,7 @@
   
           } catch (Throwable t) {
               // Log any errors
  -            returnValue = false;
  +            returnValue = 1;
               String message = t.getMessage();
               if (t instanceof IllegalArgumentException) {
                   Launcher.error(message, true);
  @@ -412,6 +412,11 @@
                   Launcher.lock.notifyAll();
               }
           }
  +
  +        // Override return value with exit value of last synchronous child JVM
  +        Process[] childProcesses = LaunchTask.getChildProcesses();
  +        if (childProcesses.length > 0)
  +            returnValue = childProcesses[childProcesses.length - 1].exitValue();
   
           return returnValue;
   
  
  
  

--
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