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/types ArgumentSet.java ArgumentSet_en.properties ConditionalArgumentSet.java JVMArgumentSet.java JVMArgumentSet_en.properties ConditionalArgument.java ConditionalVariable.java ConditionalVariableSet.java SysPropertySet.java
Date Tue, 16 Jul 2002 06:42:29 GMT
patrickl    2002/07/15 23:42:28

  Modified:    daemon/src/bin launcher.xml
               daemon/src/java/org/apache/commons/launcher LaunchTask.java
                        Launcher.java
               daemon/src/java/org/apache/commons/launcher/types
                        ConditionalArgument.java ConditionalVariable.java
                        ConditionalVariableSet.java SysPropertySet.java
  Added:       daemon/src/java/org/apache/commons/launcher/types
                        ArgumentSet.java ArgumentSet_en.properties
                        ConditionalArgumentSet.java JVMArgumentSet.java
                        JVMArgumentSet_en.properties
  Log:
  Add support for <jvmargset> and <argset> data types to match the existing <syspropertyset>
data type. Also, fixed bug where the properties in nested elements would not get resolved
properly if the property is set in a line after the nested element in the XML file.
  
  Revision  Changes    Path
  1.3       +7 -2      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- launcher.xml	12 Jul 2002 22:56:45 -0000	1.2
  +++ launcher.xml	16 Jul 2002 06:42:28 -0000	1.3
  @@ -24,6 +24,12 @@
       <sysproperty key="ant.home" file="${app.home}"/>
     </syspropertyset>
   
  +  <!-- Build the debug jvmargs -->
  +  <jvmargset id="debug.jvm.args">
  +    <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">
   
  @@ -73,8 +79,7 @@
         displayMinimizedWindow="${display.window}"
         disposeMinimizedWindow="${dispose.window}"
         minimizedWindowTitle="${window.title}">
  -        <jvmarg value="-Xdebug" if="jpda.settings"/>
  -        <jvmarg value="-Xrunjdwp:${jpda.settings}" if="jpda.settings"/>
  +        <jvmargset refid="debug.jvm.args"/>
           <syspropertyset refid="base.sys.properties"/>
           <classpath refid="base.class.path"/>
       </launch>
  
  
  
  1.9       +44 -25    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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LaunchTask.java	15 Jul 2002 19:58:58 -0000	1.8
  +++ LaunchTask.java	16 Jul 2002 06:42:28 -0000	1.9
  @@ -65,12 +65,12 @@
   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Iterator;
  +import org.apache.commons.launcher.types.ArgumentSet;
   import org.apache.commons.launcher.types.ConditionalArgument;
   import org.apache.commons.launcher.types.ConditionalVariable;
  +import org.apache.commons.launcher.types.JVMArgumentSet;
   import org.apache.commons.launcher.types.SysPropertySet;
   import org.apache.tools.ant.BuildException;
  -import org.apache.tools.ant.Project;
  -import org.apache.tools.ant.ProjectHelper;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.types.Reference;
  @@ -207,12 +207,12 @@
       /**
        * Cached arg elements
        */
  -    private ArrayList taskArguments = new ArrayList();
  +    private ArgumentSet taskArgumentSet = new ArgumentSet();
   
       /**
        * Cached jvmarg elements
        */
  -    private ArrayList taskJVMArguments = new ArrayList();
  +    private JVMArgumentSet taskJVMArgumentSet = new JVMArgumentSet();
   
       /**
        * Cached sysproperty elements
  @@ -254,7 +254,18 @@
        */
       public void addArg(ConditionalArgument arg) {
   
  -        taskArguments.add(arg);
  +        taskArgumentSet.addArg(arg);
  +
  +    }
  +
  +    /**
  +     * Add a nested argset element.
  +     *
  +     * @param set the argset element
  +     */
  +    public void addArgset(ArgumentSet set) {
  +
  +        taskArgumentSet.addArgset(set);
   
       }
   
  @@ -268,7 +279,18 @@
        */
       public void addJvmarg(ConditionalArgument jvmArg) {
   
  -        taskJVMArguments.add(jvmArg);
  +        taskJVMArgumentSet.addJvmarg(jvmArg);
  +
  +    }
  +
  +    /**
  +     * Add a nested jvmargset element.
  +     *
  +     * @param set the jvmargset element
  +     */
  +    public void addJvmargset(JVMArgumentSet set) {
  +
  +        taskJVMArgumentSet.addJvmargset(set);
   
       }
   
  @@ -305,7 +327,7 @@
       public Path createClasspath() {
   
           if (classpath == null)
  -            classpath = new Path(getProject());
  +            classpath = new Path(project);
           return classpath;
   
       }
  @@ -319,7 +341,7 @@
       public Path createFilterclasspath() {
   
           if (filterClasspath == null)
  -            filterClasspath = new Path(getProject());
  +            filterClasspath = new Path(project);
           return filterClasspath;
   
       }
  @@ -468,7 +490,7 @@
        */
       public ArrayList getArgs() {
   
  -        return taskArguments;
  +        return taskArgumentSet.getList();
   
       }
   
  @@ -479,7 +501,7 @@
        */
       public ArrayList getJvmargs() {
   
  -        return taskJVMArguments;
  +        return taskJVMArgumentSet.getList();
   
       }
   
  @@ -490,7 +512,7 @@
        */
       public ArrayList getSysproperties() {
   
  -        return taskSysPropertySet.getSysproperties();
  +        return taskSysPropertySet.getList();
   
       }
   
  @@ -557,9 +579,10 @@
               }
   
               // Copy all of the nested jvmarg elements into the jvmArgs object
  -            ArrayList jvmArgs = new ArrayList(taskJVMArguments.size());
  -            for (int i = 0; i < taskArguments.size(); i++) {
  -                ConditionalArgument value = (ConditionalArgument)taskJVMArguments.get(i);
  +            ArrayList taskJVMArgs = taskJVMArgumentSet.getList();
  +            ArrayList jvmArgs = new ArrayList(taskJVMArgs.size());
  +            for (int i = 0; i < taskJVMArgs.size(); i++) {
  +                ConditionalArgument value = (ConditionalArgument)taskJVMArgs.get(i);
                   // Test "if" and "unless" conditions
                   if (testIfCondition(value.getIf()) && testUnlessCondition(value.getUnless()))
                       jvmArgs.add(value.getValue());
  @@ -567,7 +590,7 @@
   
               // Copy all of the nested sysproperty elements into the sysProps
               // object
  -            ArrayList taskSysProps = taskSysPropertySet.getSysproperties();
  +            ArrayList taskSysProps = taskSysPropertySet.getList();
               HashMap sysProps = new HashMap(taskSysProps.size());
               for (int i = 0; i < taskSysProps.size(); i++) {
                   ConditionalVariable variable = (ConditionalVariable)taskSysProps.get(i);
  @@ -639,9 +662,10 @@
               }
   
               // Copy all of the nested arg elements into the appArgs object
  -            ArrayList appArgs = new ArrayList(taskArguments.size());
  -            for (int i = 0; i < taskArguments.size(); i++) {
  -                ConditionalArgument value = (ConditionalArgument)taskArguments.get(i);
  +            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());
  @@ -650,7 +674,6 @@
               // Add the Launcher's command line arguments to the appArgs object
               if (useArgs) {
                   int currentArg = 0;
  -                Project project = getProject();
                   String arg = null;
                   while ((arg = project.getUserProperty(LaunchTask.ARG_PROP_NAME + Integer.toString(currentArg++)))
!= null)
                       appArgs.add(arg);
  @@ -948,9 +971,7 @@
   
           if (ifCondition == null || "".equals(ifCondition))
               return true;
  -        Project project = getProject();
  -        String ifProperty = ProjectHelper.replaceProperties(project, ifCondition, project.getProperties());
  -        return project.getProperty(ifProperty) != null;
  +        return project.getProperty(ifCondition) != null;
   
       }
   
  @@ -966,9 +987,7 @@
   
           if (unlessCondition == null || "".equals(unlessCondition))
               return true;
  -        Project project = getProject();
  -        String unlessProperty = ProjectHelper.replaceProperties(project, unlessCondition,
project.getProperties());
  -        return project.getProperty(unlessProperty) == null;
  +        return project.getProperty(unlessCondition) == null;
   
       }
   
  
  
  
  1.10      +7 -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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Launcher.java	15 Jul 2002 19:58:58 -0000	1.9
  +++ Launcher.java	16 Jul 2002 06:42:28 -0000	1.10
  @@ -63,6 +63,8 @@
   import java.net.URL;
   import java.net.URLClassLoader;
   import java.util.ResourceBundle;
  +import org.apache.commons.launcher.types.ArgumentSet;
  +import org.apache.commons.launcher.types.JVMArgumentSet;
   import org.apache.commons.launcher.types.SysPropertySet;
   import org.apache.tools.ant.Main;
   import org.apache.tools.ant.Project;
  @@ -200,18 +202,23 @@
        * List of supported Ant tasks.
        */
       public final static Object[] SUPPORTED_ANT_TASKS = new Object[] {
  +            LaunchTask.TASK_NAME, LaunchTask.class,
               "ant", Ant.class,
               "antcall", CallTarget.class,
               "available", Available.class,
               "condition", ConditionTask.class,
               "fail", Exit.class,
               "property", Property.class
  +
           };
   
       /**
        * List of supported Ant types.
        */
       public final static Object[] SUPPORTED_ANT_TYPES = new Object[] {
  +            ArgumentSet.TYPE_NAME, ArgumentSet.class,
  +            JVMArgumentSet.TYPE_NAME, JVMArgumentSet.class,
  +            SysPropertySet.TYPE_NAME, SysPropertySet.class,
               "description", Description.class,
               "fileset", FileSet.class,
               "filelist", FileList.class,
  @@ -352,12 +359,6 @@
                   Class typeClass = (Class)Launcher.SUPPORTED_ANT_TYPES[++i];
                   project.addDataTypeDefinition(typeName, typeClass);
               }
  -
  -            // Define the LaunchTask.TASK_NAME task
  -            project.addTaskDefinition(LaunchTask.TASK_NAME, LaunchTask.class);
  -
  -            // Define the SysPropertySet.TYPE_NAME data type 
  -            project.addDataTypeDefinition(SysPropertySet.TYPE_NAME, SysPropertySet.class);
   
               // Parse the arguments
               int currentArg = 0;
  
  
  
  1.3       +9 -7      jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/ConditionalArgument.java
  
  Index: ConditionalArgument.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/ConditionalArgument.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConditionalArgument.java	13 Jul 2002 20:12:34 -0000	1.2
  +++ ConditionalArgument.java	16 Jul 2002 06:42:28 -0000	1.3
  @@ -58,7 +58,9 @@
   package org.apache.commons.launcher.types;
   
   import java.io.File;
  +import org.apache.tools.ant.ProjectHelper;
   import org.apache.tools.ant.Task;
  +import org.apache.tools.ant.types.DataType;
   import org.apache.tools.ant.types.Path;
   
   /**
  @@ -69,22 +71,22 @@
    *
    * @author Patrick Luby
    */
  -public class ConditionalArgument {
  +public class ConditionalArgument extends DataType {
   
       //------------------------------------------------------------------ Fields
   
       /**
  -     * Cached "if" condition flag
  +     * Cached "if" condition flag.
        */
       private String ifCondition = null;
   
       /**
  -     * Cached "unless" condition flag
  +     * Cached "unless" condition flag.
        */
       private String unlessCondition = null;
   
       /**
  -     * Cached command line argument
  +     * Cached command line argument.
        */
       private String value = null;
   
  @@ -97,7 +99,7 @@
        */
       public String getIf() {
    
  -        return ifCondition;
  +        return ProjectHelper.replaceProperties(project, ifCondition, project.getProperties());
   
       }
   
  @@ -108,7 +110,7 @@
        */
       public String getUnless() {
    
  -        return unlessCondition;
  +        return ProjectHelper.replaceProperties(project, unlessCondition, project.getProperties());
   
       }
   
  @@ -119,7 +121,7 @@
        */
       public String getValue() {
   
  -        return value;
  +        return ProjectHelper.replaceProperties(project, value, project.getProperties());
   
       }
   
  
  
  
  1.3       +85 -7     jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/ConditionalVariable.java
  
  Index: ConditionalVariable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/ConditionalVariable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConditionalVariable.java	13 Jul 2002 20:12:34 -0000	1.2
  +++ ConditionalVariable.java	16 Jul 2002 06:42:28 -0000	1.3
  @@ -57,8 +57,10 @@
   
   package org.apache.commons.launcher.types;
   
  +import java.io.File;
  +import org.apache.tools.ant.ProjectHelper;
   import org.apache.tools.ant.Task;
  -import org.apache.tools.ant.types.Environment;
  +import org.apache.tools.ant.types.DataType;
   import org.apache.tools.ant.types.Path;
   
   /**
  @@ -69,20 +71,30 @@
    *
    * @author Patrick Luby
    */
  -public class ConditionalVariable extends Environment.Variable {
  +public class ConditionalVariable extends DataType {
   
       //------------------------------------------------------------------ Fields
   
       /**
  -     * Cached "if" condition flag
  +     * Cached "if" condition flag.
        */
       private String ifCondition = null;
   
       /**
  -     * Cached "unless" condition flag
  +     * Cached key.
  +     */
  +    private String key = null;
  +
  +    /**
  +     * Cached "unless" condition flag.
        */
       private String unlessCondition = null;
   
  +    /**
  +     * Cached value.
  +     */
  +    private String value = null;
  +
       //----------------------------------------------------------------- Methods
   
       /**
  @@ -91,8 +103,19 @@
        * @return the "if" condition flag
        */
       public String getIf() {
  - 
  -        return ifCondition;
  +
  +        return ProjectHelper.replaceProperties(project, ifCondition, project.getProperties());
  +
  +    }
  +
  +    /**
  +     * Get the key.
  +     *
  +     * @return the key for this variable
  +     */
  +    public String getKey() {
  +
  +        return ProjectHelper.replaceProperties(project, key, project.getProperties());
   
       }
   
  @@ -103,7 +126,29 @@
        */
       public String getUnless() {
    
  -        return unlessCondition;
  +        return ProjectHelper.replaceProperties(project, unlessCondition, project.getProperties());
  +
  +    }
  +
  +    /**
  +     * Get the value.
  +     *
  +     * @return the value for this variable
  +     */
  +    public String getValue() {
  +
  +        return ProjectHelper.replaceProperties(project, value, project.getProperties());
  +
  +    }
  +
  +    /**
  +     * Set the value to a {@link File}.
  +     *
  +     * @param value the {@link File} for this variable
  +     */
  +    public void setFile(File file) {
  +
  +        this.value = file.getAbsolutePath();
   
       }
   
  @@ -126,6 +171,28 @@
       }
   
       /**
  +     * Set the key.
  +     *
  +     * @param key the key for this variable
  +     */
  +    public void setKey(String key) {
  +
  +        this.key = key;
  +
  +    }
  +
  +    /**
  +     * Set the value to a {@link Path}.
  +     *
  +     * @param value the {@link Path} for this variable
  +     */
  +    public void setFile(Path path) {
  +
  +        this.value = path.toString();
  +
  +    }
  +
  +    /**
        * Set the "unless" condition. Tasks that nest this class as an element
        * should evaluate this flag in their {@link Task#execute()} method. If the
        * following conditions are true, the task should ignore this element:
  @@ -140,6 +207,17 @@
       public void setUnless(String property) {
    
           this.unlessCondition = property;
  +
  +    }
  +
  +    /**
  +     * Set the value.
  +     *
  +     * @param value the value for this variable
  +     */
  +    public void setValue(String value) {
  +
  +        this.value = value;
   
       }
   
  
  
  
  1.3       +2 -2      jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/ConditionalVariableSet.java
  
  Index: ConditionalVariableSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/ConditionalVariableSet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConditionalVariableSet.java	15 Jul 2002 19:58:58 -0000	1.2
  +++ ConditionalVariableSet.java	16 Jul 2002 06:42:28 -0000	1.3
  @@ -113,7 +113,7 @@
        *
        * @return the {@link ConditionalVariable} instances
        */
  -    protected ArrayList getConditionalvariables() {
  +    public ArrayList getList() {
   
           // Make sure we don't have a circular reference to this instance
           if (!checked) {
  @@ -142,7 +142,7 @@
                   throw new BuildException(Launcher.getLocalizedString("cannot.nest", this.getClass().getName()));
               }
               if (nestedSet != null)
  -                mergedList.addAll(nestedSet.getConditionalvariables());
  +                mergedList.addAll(nestedSet.getList());
           }
   
           return mergedList;
  
  
  
  1.5       +0 -11     jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/SysPropertySet.java
  
  Index: SysPropertySet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/SysPropertySet.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SysPropertySet.java	15 Jul 2002 19:58:58 -0000	1.4
  +++ SysPropertySet.java	16 Jul 2002 06:42:28 -0000	1.5
  @@ -98,15 +98,4 @@
   
       }
   
  -    /**
  -     * Get {@link ConditionalVariable} instances.
  -     *
  -     * @return the {@link ConditionalVariable} instances
  -     */
  -    public ArrayList getSysproperties() {
  -
  -        return getConditionalvariables();
  -
  -    }
  -
   }
  
  
  
  1.1                  jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/ArgumentSet.java
  
  Index: ArgumentSet.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.types;
  
  import java.util.ArrayList;
  
  /**
   * A class that represents a set of nested <arg> elements.
   *
   * @author Patrick Luby
   */
  public class ArgumentSet extends ConditionalArgumentSet {
  
      //----------------------------------------------------------- Static Fields
  
      /**
       * The name of this data type.
       */
      public final static String TYPE_NAME = "argset";
  
      //----------------------------------------------------------------- Methods
  
      /**
       * Add a {@link ConditionalArgument}.
       *
       * @param argument the {@link ConditionalArgument} to be
       *  added
       */
      public void addArg(ConditionalArgument argument) {
  
          addConditionalargument(argument);
  
      }
  
      /**
       * Add a {@link ArgumentSet}.
       *
       * @param set the {@link ArgumentSet} to be added
       */
      public void addArgset(ArgumentSet set) {
  
          addConditionalargumentset(set);
  
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/ArgumentSet_en.properties
  
  Index: ArgumentSet_en.properties
  ===================================================================
  #
  # Localized strings for ArgumentSet class
  #
  cannot.nest=Only <arg> and <argset> elements can be nested
  cannot.reference=Only <argset> elements can be referenced
  
  
  
  1.1                  jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/ConditionalArgumentSet.java
  
  Index: ConditionalArgumentSet.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.types;
  
  import java.util.ArrayList;
  import java.util.Stack;
  import org.apache.commons.launcher.Launcher;
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.types.DataType;
  import org.apache.tools.ant.types.Reference;
  
  /**
   * A class that represents a set of nested elements of
   * {@link ConditionalArgument} objects.
   *
   * @author Patrick Luby
   */
  public class ConditionalArgumentSet extends DataType {
  
      //------------------------------------------------------------------ Fields
  
      /**
       * Cached arguments and nested ConditionalArgumentSet objects
       */
      private ArrayList list = new ArrayList();
  
      //----------------------------------------------------------------- Methods
  
      /**
       * Add a {@link ConditionalArgument}.
       *
       * @param argument the {@link ConditionalArgument} to be
       *  added
       */
      protected void addConditionalargument(ConditionalArgument argument) {
  
          if (isReference())
              throw noChildrenAllowed();
          list.add(argument);
  
      }
  
      /**
       * Add a {@link ConditionalArgumentSet}.
       *
       * @param set the {@link ConditionalArgumentSet} to be added
       */
      protected void addConditionalargumentset(ConditionalArgumentSet set) {
  
          if (isReference())
              throw noChildrenAllowed();
          list.add(set);
  
      }
  
      /**
       * Get {@link ConditionalArgument} instances.
       *
       * @return the {@link ConditionalArgument} instances
       */
      public ArrayList getList() {
  
          // Make sure we don't have a circular reference to this instance
          if (!checked) {
              Stack stk = new Stack();
              stk.push(this);
              dieOnCircularReference(stk, project);
          }
  
          // Recursively work through the tree of ConditionalArgumentSet objects
          // and accumulate the list of ConditionalArgument objects.
          ArrayList mergedList = new ArrayList(list.size());
          for (int i = 0; i < list.size(); i++) {
              Object o = list.get(i);
              ConditionalArgumentSet nestedSet = null;
              if (o instanceof Reference) {
                  o = ((Reference)o).getReferencedObject(project);
                  // Only references to this class are allowed
                  if (!o.getClass().isInstance(this))
                      throw new BuildException(Launcher.getLocalizedString("cannot.reference",
this.getClass().getName()));
                  nestedSet = (ConditionalArgumentSet)o;
              } else if (o.getClass().isInstance(this)) {
                  nestedSet = (ConditionalArgumentSet)o;
              } else if (o instanceof ConditionalArgument) {
                  mergedList.add(o);
              } else {
                  throw new BuildException(Launcher.getLocalizedString("cannot.nest", this.getClass().getName()));
              }
              if (nestedSet != null)
                  mergedList.addAll(nestedSet.getList());
          }
  
          return mergedList;
  
      }
  
      /**
       * Makes this instance a reference to another instance. You must not
       * set another attribute or nest elements inside this element if you
       * make it a reference.
       *
       * @param r the reference to another {@link ConditionalArgumentSet}
       *  instance
       */
      public void setRefid(Reference r) throws BuildException {
  
          if (!list.isEmpty())
              throw tooManyAttributes();
          list.add(r);
          super.setRefid(r);
  
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/JVMArgumentSet.java
  
  Index: JVMArgumentSet.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.types;
  
  import java.util.ArrayList;
  
  /**
   * A class that represents a set of nested <jvmarg> elements.
   *
   * @author Patrick Luby
   */
  public class JVMArgumentSet extends ConditionalArgumentSet {
  
      //----------------------------------------------------------- Static Fields
  
      /**
       * The name of this data type.
       */
      public final static String TYPE_NAME = "jvmargset";
  
      //----------------------------------------------------------------- Methods
  
      /**
       * Add a {@link ConditionalArgument}.
       *
       * @param argument the {@link ConditionalArgument} to be
       *  added
       */
      public void addJvmarg(ConditionalArgument argument) {
  
          addConditionalargument(argument);
  
      }
  
      /**
       * Add a {@link JVMArgumentSet}.
       *
       * @param set the {@link JVMArgumentSet} to be added
       */
      public void addJvmargset(JVMArgumentSet set) {
  
          addConditionalargumentset(set);
  
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/types/JVMArgumentSet_en.properties
  
  Index: JVMArgumentSet_en.properties
  ===================================================================
  #
  # Localized strings for JVMArgumentSet class
  #
  cannot.nest=Only <jvmarg> and <jvmargset> elements can be nested
  cannot.reference=Only <jvmargset> elements can be referenced
  
  
  

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