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 LaunchFilter.java LaunchTask.java LaunchTask_en.properties
Date Fri, 19 Jul 2002 08:05:11 GMT
patrickl    2002/07/19 01:05:11

  Modified:    daemon/src/bin launcher.properties
               daemon/src/java/org/apache/commons/launcher
                        LaunchFilter.java LaunchTask.java
                        LaunchTask_en.properties
  Added:       daemon/src/java/org/apache/commons/launcher
                        LaunchCommand.java
  Log:
  Modify LaunchFilter interface and modify LaunchTask.execute() to use the new LauncherCommand
class to prevent LauncherFilter subclasses from changing the LaunchTask's cached values. With
this change, LauncherFilter subclasses only can change temporary working copies of the cached
values.
  
  Revision  Changes    Path
  1.3       +2 -1      jakarta-commons-sandbox/daemon/src/bin/launcher.properties
  
  Index: launcher.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/bin/launcher.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- launcher.properties	11 Jul 2002 21:35:28 -0000	1.2
  +++ launcher.properties	19 Jul 2002 08:05:11 -0000	1.3
  @@ -12,7 +12,8 @@
   # - URL file fragments are the portions of a URL after the "file:" string.
   #   This means that you must use "/" characters as directory separators on
   #   all platforms. Also, ":" characters in a file fragment, such as in drive
  -#   portion of absolute Windows files, must be URL encoded as "%3A".
  +#   portion of absolute Windows files, must be URL encoded as "%3A". Lastly,
  +#   directories must have a "/" character at the end.
   # - All relative URL file fragments in the above properties will be resolved
   #   using the URL of the directory that the LauncherBootstrap class was
   #   loaded from, not the current working directory. This ensures that the
  
  
  
  1.2       +9 -11     jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchFilter.java
  
  Index: LaunchFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchFilter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LaunchFilter.java	10 Jul 2002 05:27:52 -0000	1.1
  +++ LaunchFilter.java	19 Jul 2002 08:05:11 -0000	1.2
  @@ -82,19 +82,17 @@
       //----------------------------------------------------------------- Methods
   
       /**
  -     * Perform dynamic configuration and error checking of the attributes and
  -     * nested elements in an instance of the {@link LaunchTask} class.
  -     * Implementors of this method will receive an instance of the
  -     * {@link LaunchTask} class that represents a "launch" task in the
  -     * Launcher's XML file. The implementor of this method can then retrieve
  -     * any of the attributes or nested elements of the task via the
  -     * {@link LaunchTask} class' public "get" methods and change any of the
  -     * attributes and nested elements via its public "set", "add", and "create"
  -     *  methods.
  +     * Perform error checking and editing of the JVM command line arguments
  +     * that an instance of the {@link LaunchTask} class has constructed.
  +     * Implementors will receive an instance of the {@link LaunchCommand} from
  +     * the {@link LaunchTask} instance that invokes this method. The
  +     * implementor of this method can then retrieve and edit any of the
  +     * JVM command line arguments via the {@link LaunchCommand} class' public
  +     * methods.
        *
  -     * @param launchTask a configured instance of the {@link LaunchTask} class
  +     * @param launchCommand a configured {@link LaunchCommand} instance
        * @throws BuildException if any errors occur
        */
  -    public void filterTask(LaunchTask launchTask) throws BuildException;
  +    public void filter(LaunchCommand launchCommand) throws BuildException;
   
   }
  
  
  
  1.12      +127 -256  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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- LaunchTask.java	18 Jul 2002 16:38:11 -0000	1.11
  +++ LaunchTask.java	19 Jul 2002 08:05:11 -0000	1.12
  @@ -126,11 +126,6 @@
       private boolean appendOutput = false;
   
       /**
  -     * Cached command line args
  -     */
  -    private String[] args = null;
  -
  -    /**
        * Cached synchronously executing child process.
        */
       private Process childProc = null;
  @@ -164,10 +159,6 @@
        * Cached filterClasspath.
        */
       private Path filterClasspath = null;
  -    /**
  -     * Cached jdb flag.
  -     */
  -    private boolean jdb = false;
   
       /**
        * Cached main class name.
  @@ -200,11 +191,6 @@
       private boolean requireTools = false;
   
       /**
  -     * Cached systemIn flag.
  -     */
  -    private boolean systemIn = true;
  -
  -    /**
        * Cached arg elements
        */
       private ArgumentSet taskArgumentSet = new ArgumentSet();
  @@ -347,176 +333,6 @@
       }
   
       /**
  -     * Get the useArgs flag.
  -     *
  -     * @return the useArgs flag
  -     */
  -    public boolean getUseargs() {
  -
  -        return useArgs;
  -
  -    }
  -
  -    /**
  -     * Get the waitForChild flag.
  -     *
  -     * @return the waitForChild flag
  -     */
  -    public boolean getWaitforchild() {
  -
  -        return waitForChild;
  -
  -    }
  -
  -    /**
  -     * Get the class name.
  -     *
  -     * @return the class to execute <code>main(String[])</code>
  -     */
  -    public String getClassname() {
  -
  -        return mainClassName;
  -
  -    }
  -
  -    /**
  -     * Get the classpath.
  -     *
  -     * @return the classpath
  -     */
  -    public Path getClasspath() {
  -
  -        return classpath;
  -
  -    }
  -
  -    /**
  -     * Get the displayMinimizedWindow flag.
  -     *
  -     * @return the displayMinimizedWindow flag
  -     */
  -    public boolean getDisplayminimizedwindow() {
  -
  -        return displayMinimizedWindow;
  -
  -    }
  -
  -    /**
  -     * Get the disposeMinimizedWindow flag.
  -     *
  -     * @return the disposeMinimizedWindow flag
  -     */
  -    public boolean getDisposeminimizedwindow() {
  -
  -        return disposeMinimizedWindow;
  -
  -    }
  -
  -    /**
  -     * Get the title for the minimized window that will be displayed in the
  -     * Windows taskbar.
  -     *
  -     * @return the title to set for any minimized window that is displayed
  -     *  in the Windows taskbar
  -     */
  -    public String getMinimizedwindowtitle() {
  -
  -        return minimizedWindowTitle;
  -
  -    }
  -
  -    /**
  -     * Get the icon file for the minimized window that will be displayed in the
  -     * Windows taskbar.
  -     *
  -     * @return the icon file to use for any minimized window that is displayed
  -     *  in the Windows taskbar
  -     */
  -    public File getMinimizedwindowicon() {
  -
  -        return minimizedWindowIcon;
  -
  -    }
  -
  -    /**
  -     * Get the file that the child JVM's System.out and System.err will be
  -     * redirected to.
  -     *
  -     * @return the File to redirect System.out and System.err to
  -     */
  -    public File getOutput() {
  -
  -        return outputFile;
  -
  -    }
  -
  -    /**
  -     * Get the appendOutput flag.
  -     *
  -     * @return the appendOutput flag
  -     */
  -    public boolean getAppendOutput() {
  -
  -        return appendOutput;
  -
  -    }
  -
  -    /**
  -     * Get the redirect flag.
  -     *
  -     * @return the redirect flag
  -     */
  -    public boolean getRedirectoutput() {
  -
  -        return redirect;
  -
  -    }
  -
  -    /**
  -     * Get the requireTools flag.
  -     *
  -     * @return the requireTools flag
  -     */
  -    public boolean getRequiretools() {
  -
  -        return requireTools;
  -
  -    }
  -
  -    /**
  -     * Get the list of nested arg elements.
  -     *
  -     * @return a list of ConditionalArgument objects
  -     */
  -    public ArrayList getArgs() {
  -
  -        return taskArgumentSet.getList();
  -
  -    }
  -
  -    /**
  -     * Get the list of nested jvmarg elements.
  -     *
  -     * @return a list of ConditionalArgument objects
  -     */
  -    public ArrayList getJvmargs() {
  -
  -        return taskJVMArgumentSet.getList();
  -
  -    }
  -
  -    /**
  -     * Get the list of nested sysproperty elements.
  -     *
  -     * @return the {@link ConditionalVariable} objects
  -     */
  -    public ArrayList getSysproperties() {
  -
  -        return taskSysPropertySet.getList();
  -
  -    }
  -
  -    /**
        * Construct a Java command and execute it using the settings that Ant
        * parsed from the Launcher's XML file. This method is called by the Ant
        * classes.
  @@ -536,47 +352,15 @@
               if (Launcher.isStopped())
                   throw new BuildException();
   
  -            // If there is a filter in the filterclasname attribute, let it
  -            // evaluate and edit the attributes and nested elements before we
  -            // start evaluating them
  -            if (filterClassName != null) {
  -                 if (filter == null) {
  -                     try {
  -                         ClassLoader loader = this.getClass().getClassLoader();
  -                         if (filterClasspath != null) {
  -                             // Construct a class loader to load the class
  -                             String[] fileList = filterClasspath.list();
  -                             URL[] urls = new URL[fileList.length];
  -                             for (int i = 0; i < fileList.length; i++)
  -                                 urls[i] = new File(fileList[i]).toURL();
  -                             loader = new URLClassLoader(urls, loader);
  -                         }
  -                         Class filterClass = loader.loadClass(filterClassName);
  -                         filter = (LaunchFilter)filterClass.newInstance();
  -                         filter.filterTask(this);
  -                     } catch (BuildException be) {
  -                         throw new BuildException(filterClassName + " " + Launcher.getLocalizedString("filter.exception",
this.getClass().getName()), be);
  -                     } catch (ClassCastException cce) {
  -                         throw new BuildException(filterClassName + " " +Launcher.getLocalizedString("filter.not.filter",
this.getClass().getName()));
  -                     } catch (Exception e) {
  -                         throw new BuildException(filterClassName + " " + Launcher.getLocalizedString("filter.not.found",
this.getClass().getName()));
  -                     }
  -                 }
  -            }
  -
  -            if (mainClassName == null)
  -                throw new BuildException(Launcher.getLocalizedString("classname.null",
this.getClass().getName()));
  -
               // Prepend standard paths to classpath
               StringBuffer fullClasspath = new StringBuffer(Launcher.getBootstrapFile().getPath());
               if (requireTools) {
                   fullClasspath.append(File.pathSeparator);
                   fullClasspath.append(Launcher.getToolsClasspath());
               }
  -            if (classpath != null) {
  -                fullClasspath.append(File.pathSeparator);
  -                fullClasspath.append(classpath.toString());
  -            }
  +
  +            if (mainClassName == null)
  +                throw new BuildException(Launcher.getLocalizedString("classname.null",
this.getClass().getName()));
   
               // Copy all of the nested jvmarg elements into the jvmArgs object
               ArrayList taskJVMArgs = taskJVMArgumentSet.getList();
  @@ -599,9 +383,114 @@
                       sysProps.put(variable.getKey(), variable.getValue());
               }
   
  +            // Copy all of the nested arg elements into the appArgs object
  +            ArrayList taskArgs = taskArgumentSet.getList();
  +            ArrayList appArgs = new ArrayList(taskArgs.size());
  +            for (int i = 0; i < taskArgs.size(); i++) {
  +                ConditionalArgument value = (ConditionalArgument)taskArgs.get(i);
  +                // Test "if" and "unless" conditions
  +                if (testIfCondition(value.getIf()) && testUnlessCondition(value.getUnless()))
  +                    appArgs.add(value.getValue());
  +            }
  +
  +            // Add the Launcher's command line arguments to the appArgs object
  +            if (useArgs) {
  +                int currentArg = 0;
  +                String arg = null;
  +                while ((arg = project.getUserProperty(LaunchTask.ARG_PROP_NAME + Integer.toString(currentArg++)))
!= null)
  +                    appArgs.add(arg);
  +            }
  +
  +            // Make working copies of some of the flags since they may get
  +            // changed by a filter class
  +            String filteredClasspath = null;
  +            if (classpath != null)
  +                filteredClasspath = classpath.toString();
  +            String filteredMainClassName = mainClassName;
  +            boolean filteredRedirect = redirect;
  +            File filteredOutputFile = outputFile;
  +            boolean filteredAppendOutput = appendOutput;
  +            boolean filteredDisplayMinimizedWindow = displayMinimizedWindow;
  +            boolean filteredDisposeMinimizedWindow = disposeMinimizedWindow;
  +            String filteredMinimizedWindowTitle = minimizedWindowTitle;
  +            File filteredMinimizedWindowIcon = minimizedWindowIcon;
  +            boolean filteredWaitForChild = waitForChild;
  +
  +            // If there is a filter in the filterclassname attribute, let it
  +            // evaluate and edit the attributes and nested elements before we
  +            // start evaluating them
  +            if (filterClassName != null) {
  +                 if (filter == null) {
  +                     try {
  +                         ClassLoader loader = this.getClass().getClassLoader();
  +                         if (filterClasspath != null) {
  +                             // Construct a class loader to load the class
  +                             String[] fileList = filterClasspath.list();
  +                             URL[] urls = new URL[fileList.length];
  +                             for (int i = 0; i < fileList.length; i++)
  +                                 urls[i] = new File(fileList[i]).toURL();
  +                             loader = new URLClassLoader(urls, loader);
  +                         }
  +                         Class filterClass = loader.loadClass(filterClassName);
  +                         filter = (LaunchFilter)filterClass.newInstance();
  +                         // Execute filter and save any changes
  +                         LaunchCommand command = new LaunchCommand();
  +                         command.setJvmargs(jvmArgs);
  +                         command.setSysproperties(sysProps);
  +                         command.setArgs(appArgs);
  +                         command.setClasspath(filteredClasspath);
  +                         command.setClassname(filteredMainClassName);
  +                         command.setRedirectoutput(filteredRedirect);
  +                         command.setOutput(filteredOutputFile);
  +                         command.setAppendoutput(filteredAppendOutput);
  +                         command.setDisplayminimizedwindow(filteredDisplayMinimizedWindow);
  +                         command.setDisposeminimizedwindow(filteredDisposeMinimizedWindow);
  +                         command.setMinimizedwindowtitle(filteredMinimizedWindowTitle);
  +                         command.setMinimizedwindowicon(filteredMinimizedWindowIcon);
  +                         command.setWaitforchild(waitForChild);
  +                         filter.filter(command);
  +                         jvmArgs = command.getJvmargs();
  +                         sysProps = command.getSysproperties();
  +                         appArgs = command.getArgs();
  +                         filteredClasspath = command.getClasspath();
  +                         filteredMainClassName = command.getClassname();
  +                         filteredRedirect = command.getRedirectoutput();
  +                         filteredOutputFile = command.getOutput();
  +                         filteredAppendOutput = command.getAppendoutput();
  +                         filteredDisplayMinimizedWindow = command.getDisplayminimizedwindow();
  +                         filteredDisposeMinimizedWindow = command.getDisposeminimizedwindow();
  +                         filteredMinimizedWindowTitle = command.getMinimizedwindowtitle();
  +                         filteredMinimizedWindowIcon = command.getMinimizedwindowicon();
  +                         filteredWaitForChild = command.getWaitforchild();
  +                         // Check changes
  +                         if (filteredMainClassName == null)
  +                             throw new BuildException(Launcher.getLocalizedString("classname.null",
this.getClass().getName()));
  +                         if (jvmArgs == null)
  +                             jvmArgs = new ArrayList();
  +                         if (sysProps == null)
  +                             sysProps = new HashMap();
  +                         if (appArgs == null)
  +                             appArgs = new ArrayList();
  +                     } catch (BuildException be) {
  +                         throw new BuildException(filterClassName + " " + Launcher.getLocalizedString("filter.exception",
this.getClass().getName()), be);
  +                     } catch (ClassCastException cce) {
  +                         throw new BuildException(filterClassName + " " + Launcher.getLocalizedString("filter.not.filter",
this.getClass().getName()));
  +                     } catch (Exception e) {
  +                         throw new BuildException(e);
  +                     }
  +                 }
  +            }
  +
  +
  +            // Prepend this package's classpath
  +            if (filteredClasspath != null) {
  +                fullClasspath.append(File.pathSeparator);
  +                fullClasspath.append(filteredClasspath);
  +            }
  +
               // Set Launcher.WAIT_FOR_CHILD_PROP_NAME property for child JVM
               sysProps.remove(Launcher.WAIT_FOR_CHILD_PROP_NAME);
  -            if (waitForChild)
  +            if (filteredWaitForChild)
                   sysProps.put(Launcher.WAIT_FOR_CHILD_PROP_NAME, "");
   
               // Set minimized window properties for child JVM
  @@ -609,34 +498,34 @@
               sysProps.remove(Launcher.MINIMIZED_WINDOW_TITLE_PROP_NAME);
               sysProps.remove(Launcher.MINIMIZED_WINDOW_ICON_PROP_NAME);
               sysProps.remove(Launcher.DISPOSE_MINIMIZED_WINDOW_PROP_NAME);
  -            if (!waitForChild && displayMinimizedWindow) {
  +            if (!filteredWaitForChild && filteredDisplayMinimizedWindow) {
                   sysProps.put(Launcher.DISPLAY_MINIMIZED_WINDOW_PROP_NAME, "");
  -                if (minimizedWindowTitle != null)
  -                    sysProps.put(Launcher.MINIMIZED_WINDOW_TITLE_PROP_NAME, minimizedWindowTitle);
  +                if (filteredMinimizedWindowTitle != null)
  +                    sysProps.put(Launcher.MINIMIZED_WINDOW_TITLE_PROP_NAME, filteredMinimizedWindowTitle);
                   else
                       sysProps.put(Launcher.MINIMIZED_WINDOW_TITLE_PROP_NAME, getOwningTarget().getName());
  -                if (minimizedWindowIcon != null)
  -                    sysProps.put(Launcher.MINIMIZED_WINDOW_ICON_PROP_NAME, minimizedWindowIcon.getCanonicalPath());
  +                if (filteredMinimizedWindowIcon != null)
  +                    sysProps.put(Launcher.MINIMIZED_WINDOW_ICON_PROP_NAME, filteredMinimizedWindowIcon.getCanonicalPath());
                   // Set Launcher.DISPOSE_MINIMIZED_WINDOW_PROP_NAME property
  -                if (disposeMinimizedWindow)
  +                if (filteredDisposeMinimizedWindow)
                       sysProps.put(Launcher.DISPOSE_MINIMIZED_WINDOW_PROP_NAME, "");
               }
   
               // Set Launcher.OUTPUT_FILE_PROP_NAME property for child JVM
               sysProps.remove(Launcher.OUTPUT_FILE_PROP_NAME);
  -            if (!waitForChild && redirect) {
  -                if (outputFile != null) {
  -                    String outputFilePath = outputFile.getCanonicalPath();
  +            if (!filteredWaitForChild && filteredRedirect) {
  +                if (filteredOutputFile != null) {
  +                    String outputFilePath = filteredOutputFile.getCanonicalPath();
                       // Verify that we can write to the output file
                       try {
  -                        outputFile.createNewFile();
  +                        filteredOutputFile.createNewFile();
                       } catch (IOException ioe) {
                           throw new BuildException(outputFilePath + " " + Launcher.getLocalizedString("output.file.not.creatable",
this.getClass().getName()));
                       }
  -                    if (!outputFile.canWrite())
  +                    if (!filteredOutputFile.canWrite())
                           throw new BuildException(outputFilePath + " " + Launcher.getLocalizedString("output.file.not.writable",
this.getClass().getName()));
                       sysProps.put(Launcher.OUTPUT_FILE_PROP_NAME, outputFilePath);
  -                    if (appendOutput)
  +                    if (filteredAppendOutput)
                           sysProps.put(Launcher.APPEND_OUTPUT_PROP_NAME, "");
                       Launcher.getLog().println(Launcher.getLocalizedString("redirect.notice",
this.getClass().getName()) + " " + outputFilePath);
                   } else {
  @@ -648,7 +537,7 @@
               // ParentListener class on Windows since the entire child JVM
               // process will block on Windows machines using some versions of
               // Unix shells such as MKS, etc.
  -            if (waitForChild) {
  +            if (filteredWaitForChild) {
                   File tmpDir = null;
                   String tmpDirName = (String)sysProps.get("java.io.tmpdir");
                   if (tmpDirName != null)
  @@ -661,24 +550,6 @@
                   sysProps.put(Launcher.HEARTBEAT_FILE_PROP_NAME, heartbeatFile.getCanonicalPath());
               }
   
  -            // Copy all of the nested arg elements into the appArgs object
  -            ArrayList taskArgs = taskArgumentSet.getList();
  -            ArrayList appArgs = new ArrayList(taskArgs.size());
  -            for (int i = 0; i < taskArgs.size(); i++) {
  -                ConditionalArgument value = (ConditionalArgument)taskArgs.get(i);
  -                // Test "if" and "unless" conditions
  -                if (testIfCondition(value.getIf()) && testUnlessCondition(value.getUnless()))
  -                    appArgs.add(value.getValue());
  -            }
  -
  -            // Add the Launcher's command line arguments to the appArgs object
  -            if (useArgs) {
  -                int currentArg = 0;
  -                String arg = null;
  -                while ((arg = project.getUserProperty(LaunchTask.ARG_PROP_NAME + Integer.toString(currentArg++)))
!= null)
  -                    appArgs.add(arg);
  -             }
  -
               // Assemble child command
               String[] cmd = new String[5 + jvmArgs.size() + sysProps.size() + appArgs.size()];
               int nextCmdArg = 0;
  @@ -704,7 +575,7 @@
               cmd[nextCmdArg++] = fullClasspath.toString();
               // Add main class to command
               cmd[nextCmdArg++] = ChildMain.class.getName();
  -            cmd[nextCmdArg++] = mainClassName;
  +            cmd[nextCmdArg++] = filteredMainClassName;
               // Add args to command
               for (int i = 0; i < appArgs.size(); i++)
                   cmd[nextCmdArg++] = (String)appArgs.get(i);
  @@ -716,12 +587,12 @@
               synchronized (LaunchTask.childProcesses) {
                   proc = Runtime.getRuntime().exec(cmd);
                   // Add the synchronous child process
  -                if (waitForChild) {
  +                if (filteredWaitForChild) {
                       childProc = proc;
                       LaunchTask.childProcesses.add(childProc);
                   }
               }
  -            if (waitForChild) {
  +            if (filteredWaitForChild) {
                   new StreamConnector(proc.getInputStream(), System.out).start();
                   new StreamConnector(proc.getErrorStream(), System.err).start();
                   new StreamConnector(System.in, proc.getOutputStream()).start();
  @@ -742,7 +613,7 @@
           } finally {
               // Remove the synchronous child process
               synchronized (LaunchTask.childProcesses) {
  -                if (waitForChild && childProc != null) {
  +                if (childProc != null) {
                       LaunchTask.childProcesses.remove(childProc);
                       childProc = null;
                   }
  @@ -925,7 +796,7 @@
        *
        * @param appendOutput true if output should be appended to the output file
        */
  -    public void setAppendOutput(boolean appendOutput) {
  +    public void setAppendoutput(boolean appendOutput) {
   
           this.appendOutput = appendOutput;
   
  
  
  
  1.2       +0 -1      jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchTask_en.properties
  
  Index: LaunchTask_en.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchTask_en.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LaunchTask_en.properties	10 Jul 2002 05:27:52 -0000	1.1
  +++ LaunchTask_en.properties	19 Jul 2002 08:05:11 -0000	1.2
  @@ -9,5 +9,4 @@
   launch.task.stopped=This task has been stopped
   no.run.standalone=This task can only be used within the Launcher application. It cannot
be used within a regular Ant buildfile.
   filter.not.filter=class does not implement the LaunchFilter interface
  -filter.not.found=filter class was not found
   filter.exception=filter class encountered a problem
  
  
  
  1.1                  jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/LaunchCommand.java
  
  Index: LaunchCommand.java
  ===================================================================
  /* ========================================================================= *
   *                                                                           *
   *                 The Apache Software License,  Version 1.1                 *
   *                                                                           *
   *             Copyright (c) 2002 The Apache Software Foundation.            *
   *                           All rights reserved.                            *
   *                                                                           *
   * ========================================================================= *
   *                                                                           *
   * Redistribution and use in source and binary forms,  with or without modi- *
   * fication, are permitted provided that the following conditions are met:   *
   *                                                                           *
   * 1. Redistributions of source code  must retain the above copyright notice *
   *    notice, this list of conditions and the following disclaimer.          *
   *                                                                           *
   * 2. Redistributions  in binary  form  must  reproduce the  above copyright *
   *    notice,  this list of conditions  and the following  disclaimer in the *
   *    documentation and/or other materials provided with the distribution.   *
   *                                                                           *
   * 3. The end-user documentation  included with the redistribution,  if any, *
   *    must include the following acknowlegement:                             *
   *                                                                           *
   *       "This product includes  software developed  by the Apache  Software *
   *        Foundation <http://www.apache.org/>."                              *
   *                                                                           *
   *    Alternately, this acknowlegement may appear in the software itself, if *
   *    and wherever such third-party acknowlegements normally appear.         *
   *                                                                           *
   * 4. The names  "The Jakarta  Project",  and  "Apache  Software Foundation" *
   *    must not  be used  to endorse  or promote  products derived  from this *
   *    software without  prior written  permission.  For written  permission, *
   *    please contact <apache@apache.org>.                                    *
   *                                                                           *
   * 5. Products derived from this software may not be called "Apache" nor may *
   *    "Apache" appear in their names without prior written permission of the *
   *    Apache Software Foundation.                                            *
   *                                                                           *
   * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES *
   * INCLUDING, BUT NOT LIMITED TO,  THE IMPLIED WARRANTIES OF MERCHANTABILITY *
   * AND FITNESS FOR  A PARTICULAR PURPOSE  ARE DISCLAIMED.  IN NO EVENT SHALL *
   * THE APACHE  SOFTWARE  FOUNDATION OR  ITS CONTRIBUTORS  BE LIABLE  FOR ANY *
   * DIRECT,  INDIRECT,   INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR  CONSEQUENTIAL *
   * DAMAGES (INCLUDING,  BUT NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE GOODS *
   * OR SERVICES;  LOSS OF USE,  DATA,  OR PROFITS;  OR BUSINESS INTERRUPTION) *
   * HOWEVER CAUSED AND  ON ANY  THEORY  OF  LIABILITY,  WHETHER IN  CONTRACT, *
   * STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
   * ANY  WAY  OUT OF  THE  USE OF  THIS  SOFTWARE,  EVEN  IF  ADVISED  OF THE *
   * POSSIBILITY OF SUCH DAMAGE.                                               *
   *                                                                           *
   * ========================================================================= *
   *                                                                           *
   * This software  consists of voluntary  contributions made  by many indivi- *
   * duals on behalf of the  Apache Software Foundation.  For more information *
   * on the Apache Software Foundation, please see <http://www.apache.org/>.   *
   *                                                                           *
   * ========================================================================= */
  
  package org.apache.commons.launcher;
  
  import java.io.File;
  import java.util.ArrayList;
  import java.util.HashMap;
  
  /**
   * A class that represents the holds the various argument types that are used
   * in a Java command. In addition, it holds many of the flags that are used
   * by the {@link LaunchTask} class when executing a JVM process.
   *
   * @author Patrick Luby
   */
  public class LaunchCommand {
  
      //------------------------------------------------------------------ Fields
  
      /**
       * Cached appendOutput flag.
       */
      private boolean appendOutput = false;
  
      /**
       * Cached classpath.
       */
      private String classpath = null;
  
      /**
       * Cached displayMinimizedWindow flag.
       */
      private boolean displayMinimizedWindow = false;
  
      /**
       * Cached disposeMinimizedWindow flag.
       */
      private boolean disposeMinimizedWindow = true;
  
      /**
       * Cached main class name.
       */
      private String mainClassName = null;
  
      /**
       * Cached minimizedWindowIcon.
       */
      private File minimizedWindowIcon = null;
  
      /**
       * Cached minimizedWindowTitle.
       */
      private String minimizedWindowTitle = null;
  
      /**
       * Cached output file.
       */
      private File outputFile = null;
  
      /**
       * Cached redirect flag.
       */
      private boolean redirect = false;
  
      /**
       * Cached arg elements
       */
      private ArrayList args = null;
  
      /**
       * Cached jvmarg elements
       */
      private ArrayList jvmArgs = null;
  
      /**
       * Cached sysproperty elements
       */
      private HashMap sysProperties = null;
  
      /**
       * Cached waitForChild flag.
       */
      private boolean waitForChild = true;
  
      //----------------------------------------------------------------- Methods
  
      /**
       * Get the class name.
       *
       * @return the class to execute <code>main(String[])</code>
       */
      public String getClassname() {
  
          return mainClassName;
  
      }
  
      /**
       * Get the classpath.
       *
       * @return the classpath
       */
      public String getClasspath() {
  
          return classpath;
  
      }
  
      /**
       * Get the displayMinimizedWindow flag.
       *
       * @return the displayMinimizedWindow flag
       */
      public boolean getDisplayminimizedwindow() {
  
          return displayMinimizedWindow;
  
      }
  
      /**
       * Get the disposeMinimizedWindow flag.
       *
       * @return the disposeMinimizedWindow flag
       */
      public boolean getDisposeminimizedwindow() {
  
          return disposeMinimizedWindow;
  
      }
  
      /**
       * Get the title for the minimized window that will be displayed in the
       * Windows taskbar.
       *
       * @return the title to set for any minimized window that is displayed
       *  in the Windows taskbar
       */
      public String getMinimizedwindowtitle() {
  
          return minimizedWindowTitle;
  
      }
  
      /**
       * Get the icon file for the minimized window that will be displayed in the
       * Windows taskbar.
       *
       * @return the icon file to use for any minimized window that is displayed
       *  in the Windows taskbar
       */
      public File getMinimizedwindowicon() {
  
          return minimizedWindowIcon;
  
      }
  
      /**
       * Get the file that the child JVM's System.out and System.err will be
       * redirected to.
       *
       * @return the File to redirect System.out and System.err to
       */
      public File getOutput() {
  
          return outputFile;
  
      }
  
      /**
       * Get the appendOutput flag.
       *
       * @return the appendOutput flag
       */
      public boolean getAppendoutput() {
  
          return appendOutput;
  
      }
  
      /**
       * Get the redirect flag.
       *
       * @return the redirect flag
       */
      public boolean getRedirectoutput() {
  
          return redirect;
  
      }
  
      /**
       * Get the list of nested arg elements.
       *
       * @return the list of {@link String} objects
       */
      public ArrayList getArgs() {
  
          return args;
  
      }
  
      /**
       * Get the list of nested jvmarg elements.
       *
       * @return the list of {@link String} objects
       */
      public ArrayList getJvmargs() {
  
          return jvmArgs;
  
      }
  
      /**
       * Get the list of nested sysproperty elements.
       *
       * @return the {@link String} objects
       */
      public HashMap getSysproperties() {
  
          return sysProperties;
  
      }
  
      /**
       * Get the waitForChild flag.
       *
       * @return the waitForChild flag
       */
      public boolean getWaitforchild() {
  
          return waitForChild;
  
      }
  
      /**
       * Set the waitForChild flag. Setting this flag to true will cause this
       * task to wait for the child JVM to finish executing before the task
       * completes. Setting this flag to false will cause this task to complete
       * immediately after it starts the execution of the child JVM. Setting it
       * false emulates the "&" background operator in most Unix shells and is
       * most of set to false when launching server or GUI applications.
       *
       * @param waitForChild the waitForChild flag
       */
      public void setWaitforchild(boolean waitForChild) {
  
          this.waitForChild = waitForChild;
  
      }
  
      /**
       * Set the class name.
       *
       * @param mainClassName the class to execute <code>main(String[])</code>
       */
      public void setClassname(String mainClassName) {
  
          this.mainClassName = mainClassName;
  
      }
  
      /**
       * Set the classpath.
       *
       * @param classpath the classpath
       */
      public void setClasspath(String classpath) {
  
          this.classpath = classpath;
  
      }
  
      /**
       * 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
       * while the child process is executing. This flag is usually set to true
       * for server applications that also have their "waitForChild" attribute
       * set to false via the {@link #setWaitforchild(boolean)} method.
       *
       * @param displayMinimizedWindow true if a minimized window should be
       *  displayed in the Windows task bar while the child process is executing 
       */
      public void setDisplayminimizedwindow(boolean displayMinimizedWindow) {
  
          this.displayMinimizedWindow = displayMinimizedWindow;
  
      }
  
      /**
       * Set the disposeMinimizedWindow flag. Note that this flag has no effect
       * on non-Windows platforms. On Windows platform, setting this flag to true
       * will cause any minimized window that is display by setting the
       * "displayMinimizedWindow" attribute to true via the
       * {@link #setDisplayminimizedwindow(boolean)} to be automatically
       * disposed of when the child JVM's <code>main(String[])</code> returns.
       * This flag is normally used for applications that don't explicitly call
       * {@link System#exit(int)}. If an application does not explicitly call
       * {@link System#exit(int)}, an minimized windows need to be disposed of
       * for the child JVM to exit.
       *
       * @param disposeMinimizedWindow true if a minimized window in the Windows
       *  taskbar should be automatically disposed of after the child JVM's
       *  <code>main(String[])</code> returns
       */
      public void setDisposeminimizedwindow(boolean disposeMinimizedWindow) {
  
          this.disposeMinimizedWindow = displayMinimizedWindow;
  
      }
  
      /**
       * Set the title for the minimized window that will be displayed in the
       * Windows taskbar. Note that this property has no effect on non-Windows
       * platforms.
       *
       * @param minimizedWindowTitle the title to set for any minimized window
       *  that is displayed in the Windows taskbar
       */
      public void setMinimizedwindowtitle(String minimizedWindowTitle) {
  
          this.minimizedWindowTitle = minimizedWindowTitle;
  
      }
  
      /**
       * Set the icon file for the minimized window that will be displayed in the
       * Windows taskbar. Note that this property has no effect on non-Windows
       * platforms.
       *
       * @param minimizedWindowIcon the icon file to use for any minimized window
       *  that is displayed in the Windows taskbar
       */
      public void setMinimizedwindowicon(File minimizedWindowIcon) {
  
          this.minimizedWindowIcon = minimizedWindowIcon;
  
      }
  
      /**
       * Set the file that the child JVM's System.out and System.err will be
       * redirected to. Output will only be redirected if the redirect flag
       * is set to true via the {@link #setRedirectoutput(boolean)} method.
       *
       * @param outputFile a File to redirect System.out and System.err to
       */
      public void setOutput(File outputFile) {
  
          this.outputFile = outputFile;
  
      }
  
      /**
       * Set the appendOutput flag. Setting this flag to true will cause the child
       * JVM to append System.out and System.err to the file specified by the
       * {@link #setOutput(File)} method. Setting this flag to false will cause
       * the child to overwrite the file.
       *
       * @param appendOutput true if output should be appended to the output file
       */
      public void setAppendoutput(boolean appendOutput) {
  
          this.appendOutput = appendOutput;
  
      }
  
      /**
       * Set the list of nested arg elements.
       *
       * @param args a list of {@link String} objects
       */
      public void setArgs(ArrayList args) {
  
          this.args = args;
  
      }
  
      /**
       * Set the list of nested jvmarg elements.
       *
       * @param jvmArgs a list of {@link String} objects
       */
      public void setJvmargs(ArrayList jvmArgs) {
  
          this.jvmArgs = jvmArgs;
  
      }
  
      /**
       * Set the list of nested sysproperty elements.
       *
       * @param props a map of {@link String} objects
       */
      public void setSysproperties(HashMap props) {
  
          this.sysProperties = sysProperties;
  
      }
  
      /**
       * Set the redirect flag. Setting this flag to true will cause the child
       * JVM's System.out and System.err to be redirected to file set using the
       * {@link #setOutput(File)} method. Setting this flag to false will
       * cause no redirection.
       *
       * @param redirect true if System.out and System.err should be redirected
       */
      public void setRedirectoutput(boolean redirect) {
  
          this.redirect = redirect;
  
      }
  
  }
  
  
  

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