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 Launcher_en.properties
Date Wed, 31 Jul 2002 02:04:48 GMT
patrickl    2002/07/30 19:04:48

  Modified:    daemon/src/java LauncherBootstrap.java
               daemon/src/java/org/apache/commons/launcher LaunchTask.java
                        Launcher.java Launcher_en.properties
  Log:
  Allow scripts to use an XML file other than launcher.xml via new -launchfile option
  
  Revision  Changes    Path
  1.9       +2 -13     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LauncherBootstrap.java	24 Jul 2002 15:44:36 -0000	1.8
  +++ LauncherBootstrap.java	31 Jul 2002 02:04:47 -0000	1.9
  @@ -121,11 +121,6 @@
       public final static String LAUNCHER_MAIN_CLASS_NAME = "org.apache.commons.launcher.Launcher";
   
       /**
  -     * Launcher XML file name
  -     */
  -    public final static String LAUNCHER_XML_FILE_NAME = "launcher.xml";
  -
  -    /**
        * Cached Laucher class.
        */
       private static Class launcherClass = null;
  @@ -150,12 +145,6 @@
               // Coerce the coreURL's directory into a file
               File coreDir = new File(URLDecoder.decode(coreURL.getFile())).getCanonicalFile().getParentFile();
   
  -            // Try to find the LAUNCHER_XML_FILE_NAME file in the same
  -            // directory as this class
  -            File launchFile = new File(coreDir, LauncherBootstrap.LAUNCHER_XML_FILE_NAME);
  -            if (!launchFile.canRead())
  -                throw new FileNotFoundException(launchFile.getPath());
  -
               // Try to find the LAUNCHER_PROPS_FILE_NAME file in the same
               // directory as this class
               File propsFile = new File(coreDir, LauncherBootstrap.LAUNCHER_PROPS_FILE_NAME);
  @@ -192,8 +181,8 @@
               // Invoke the LAUNCHER_MAIN_CLASS_NAME class' start() method.
               // 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 });
  -            int returnValue = ((Integer)startMethod.invoke(null, new Object[]{ args, launchFile
})).intValue();
  +            Method startMethod = launcherClass.getDeclaredMethod("start", new Class[]{
String[].class });
  +            int returnValue = ((Integer)startMethod.invoke(null, new Object[]{ args })).intValue();
               // Always exit cleanly after invoking the start() method
               System.exit(returnValue);
   
  
  
  
  1.23      +1 -1      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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- LaunchTask.java	31 Jul 2002 01:20:09 -0000	1.22
  +++ LaunchTask.java	31 Jul 2002 02:04:48 -0000	1.23
  @@ -724,7 +724,7 @@
       /**
        * Set the useArgs flag. Setting this flag to true will cause this
        * task to append all of the command line arguments used to start the
  -     * {@link Launcher#start(String[], File)} method to the arguments
  +     * {@link Launcher#start(String[])} method to the arguments
        * passed to the child JVM.
        *
        * @param useArgs the useArgs flag
  
  
  
  1.17      +20 -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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Launcher.java	30 Jul 2002 00:29:25 -0000	1.16
  +++ Launcher.java	31 Jul 2002 02:04:48 -0000	1.17
  @@ -129,6 +129,11 @@
       private static String jdbCmd = null;
   
       /**
  +     * Default XML file name
  +     */
  +    private final static String DEFAULT_XML_FILE_NAME = "launcher.xml";
  +
  +    /**
        * Shared lock.
        */
       private static Object lock = new Object();
  @@ -224,15 +229,12 @@
        * application's code.
        *
        * @param args command line arguments
  -     * @param launchFile the XML file to execute
        * @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 int start(String[] args, File launchFile)
  -        throws IllegalArgumentException
  -   {
  +    public static int start(String[] args) throws IllegalArgumentException {
   
           // Check make sure that neither this method or the stop() method is
           // already running since we do not support concurrency
  @@ -296,6 +298,9 @@
               // Parse the arguments
               int currentArg = 0;
   
  +            // Set default XML file
  +            File launchFile = new File(Launcher.getBootstrapDir(), Launcher.DEFAULT_XML_FILE_NAME);
  +
               // Get standard launcher arguments
               for ( ; currentArg < args.length; currentArg++) {
                   // If we find a "-" argument or an argument without a
  @@ -307,6 +312,15 @@
                       break;
                   } else if ("-help".equals(args[currentArg])) {
                       throw new IllegalArgumentException();
  +                } else if ("-launchfile".equals(args[currentArg])) {
  +                    if (currentArg + 1 < args.length){
  +                        String fileArg = args[++currentArg];
  +                        launchFile = new File(fileArg);
  +                        if (!launchFile.isAbsolute())
  +                            launchFile = new File(Launcher.getBootstrapDir(), fileArg);
  +                    } else {
  +                        throw new IllegalArgumentException(args[currentArg] + " " + Launcher.getLocalizedString("missing.arg"));
  +                    }
                   } else if ("-executablename".equals(args[currentArg])) {
                       if (currentArg + 1 < args.length)
                           System.setProperty(ChildMain.EXECUTABLE_PROP_NAME, args[++currentArg]);
  @@ -426,7 +440,7 @@
       }
   
       /**
  -     * Interrupt the {@link #start(String[], File)} method. This is done
  +     * Interrupt the {@link #start(String[])} method. This is done
        * by forcing the current or next scheduled invocation of the
        * {@link LaunchTask#execute()} method to throw an exception. In addition,
        * this method will terminate any synchronous child processes that any
  @@ -437,7 +451,7 @@
        * "waitForChild" attribute to "true" to ensure that the
        * application that you want to control can be terminated via this method.
        * After this method has been executed, it will not return until is safe to
  -     * execute the {@link #start(String[], File)} method.
  +     * execute the {@link #start(String[])} method.
        *
        * @return true if this method completed without error and false if an
        *  error occurred or the launch process is already stopped
  
  
  
  1.4       +1 -0      jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/Launcher_en.properties
  
  Index: Launcher_en.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/Launcher_en.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Launcher_en.properties	11 Jul 2002 21:35:28 -0000	1.3
  +++ Launcher_en.properties	31 Jul 2002 02:04:48 -0000	1.4
  @@ -14,5 +14,6 @@
   usage=Usage: ${launcher.executable.name} [options] [-] target [-D<name>=<value>...]
[-] [application arguments...]${line.separator}\
   where options include:${line.separator}\
   \  -help                   Print this usage statement${line.separator}\
  +\  -launchfile <file>      The XML file to use (the default is "launcher.xml")${line.separator}\
   \  -executablename <name>  The executable name to print in this usage statement${line.separator}\
   \  -verbose                Print stack traces with error messages
  
  
  

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