ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/taskdefs AbstractAnt1AntTask.java Ant.java CallTarget.java
Date Sun, 21 Apr 2002 02:03:04 GMT
donaldp     02/04/20 19:03:04

  Modified:    ant1compat/src/java/org/apache/tools/ant
                        Ant1CompatConfigurer.java
                        Ant1CompatTaskAdapter.java
                        Ant1CompatTypeInstanceTask.java Task.java
               ant1compat/src/java/org/apache/tools/ant/taskdefs
                        AbstractAnt1AntTask.java Ant.java CallTarget.java
  Log:
  Update the ant1compat library to use ModelELement rather than Configuration.
  
  Revision  Changes    Path
  1.2       +21 -17    jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/Ant1CompatConfigurer.java
  
  Index: Ant1CompatConfigurer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/Ant1CompatConfigurer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Ant1CompatConfigurer.java	14 Apr 2002 12:38:40 -0000	1.1
  +++ Ant1CompatConfigurer.java	21 Apr 2002 02:03:04 -0000	1.2
  @@ -8,22 +8,22 @@
   package org.apache.tools.ant;
   
   import java.util.Locale;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.myrmidon.api.metadata.ModelElement;
  +import org.apache.myrmidon.api.metadata.ModelException;
   
   /**
    * A helper class which uses reflection to configure any Object,
    * with the help of the Ant1 IntrospectionHelper.
  - * This aims to mimic (to some extent) the Ant1-style configuration rules
  + * This aims to mimic (to some extent) the Ant1-style ModelElement rules
    * implemented by ProjectHelperImpl.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/14 12:38:40 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/21 02:03:04 $
    */
   class Ant1CompatConfigurer
   {
       private final Object m_configuredObject;
  -    private Configuration m_configuration;
  +    private ModelElement m_modelElement;
       private final Project m_project;
       private final IntrospectionHelper m_helper;
   
  @@ -32,11 +32,11 @@
       private String[] m_childNames;
   
       Ant1CompatConfigurer( Object configuredObject,
  -                          Configuration config,
  +                          ModelElement config,
                             Project project )
       {
           m_configuredObject = configuredObject;
  -        m_configuration = config;
  +        m_modelElement = config;
           m_project = project;
           m_helper = IntrospectionHelper.getHelper( m_configuredObject.getClass() );
       }
  @@ -44,9 +44,10 @@
       /**
        * Create all child elements, recursively.
        */
  -    void createChildren() throws ConfigurationException
  +    void createChildren()
  +        throws ModelException
       {
  -        Configuration[] childConfigs = m_configuration.getChildren();
  +        ModelElement[] childConfigs = m_modelElement.getChildren();
   
           m_childObjects = new Object[ childConfigs.length ];
           m_childConfigurers = new Ant1CompatConfigurer[ childConfigs.length ];
  @@ -54,7 +55,7 @@
   
           for( int i = 0; i < childConfigs.length; i++ )
           {
  -            Configuration childConfig = childConfigs[ i ];
  +            ModelElement childConfig = childConfigs[ i ];
               String name = childConfig.getName();
               Object childObject =
                   m_helper.createElement( m_project, m_configuredObject, name );
  @@ -73,15 +74,16 @@
       /**
        * Configure attributes and text, recursively.
        */
  -    void configure() throws ConfigurationException
  +    void configure()
  +        throws ModelException
       {
           // Configure the attributes.
  -        final String[] attribs = m_configuration.getAttributeNames();
  +        final String[] attribs = m_modelElement.getAttributeNames();
           for( int i = 0; i < attribs.length; i++ )
           {
               final String name = attribs[ i ];
               final String value =
  -                m_project.replaceProperties( m_configuration.getAttribute( name ) );
  +                m_project.replaceProperties( m_modelElement.getAttribute( name ) );
               try
               {
                   m_helper.setAttribute( m_project, m_configuredObject,
  @@ -98,7 +100,7 @@
           }
   
           // Configure the text content.
  -        String text = m_configuration.getValue( null );
  +        String text = m_modelElement.getContent();
           if( text != null )
           {
               m_helper.addText( m_project, m_configuredObject, text );
  @@ -110,12 +112,14 @@
               m_childConfigurers[ i ].configure();
   
               // Store child if neccessary (addConfigured)
  -            m_helper.storeElement( m_project, m_configuredObject,
  -                                   m_childObjects[ i ], m_childNames[ i ] );
  +            m_helper.storeElement( m_project,
  +                                   m_configuredObject,
  +                                   m_childObjects[ i ],
  +                                   m_childNames[ i ] );
           }
   
           // Set the reference, if id was specified.
  -        String id = m_configuration.getAttribute( "id", null );
  +        String id = m_modelElement.getAttribute( "id" );
           if( id != null )
           {
               m_project.addReference( id, m_configuredObject );
  
  
  
  1.2       +13 -13    jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/Ant1CompatTaskAdapter.java
  
  Index: Ant1CompatTaskAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/Ant1CompatTaskAdapter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Ant1CompatTaskAdapter.java	14 Apr 2002 12:38:40 -0000	1.1
  +++ Ant1CompatTaskAdapter.java	21 Apr 2002 02:03:04 -0000	1.2
  @@ -7,16 +7,16 @@
    */
   package org.apache.tools.ant;
   
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.myrmidon.api.metadata.ModelElement;
  +import org.apache.myrmidon.api.metadata.ModelException;
   
   /**
    * An adapter for running (in Myrmidon) Ant1 tasks which do not extend Task
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/14 12:38:40 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/21 02:03:04 $
    */
   public class Ant1CompatTaskAdapter
       extends TaskAdapter
  @@ -28,23 +28,23 @@
        * Gets the adapted task name from the configuration, and looks up the
        * Class for the adapted task. The adapted task is then instantiated and
        * configured.
  -     * @param configuration The Task Model
  -     * @throws ConfigurationException If the configuration is invalid.
  +     * @param element The Task Model
  +     * @throws ModelException If the configuration is invalid.
        */
  -    public void configure( Configuration configuration )
  -        throws ConfigurationException
  +    public void model( final ModelElement element )
  +        throws ModelException
       {
           // Create a new instance of the proxy object,
           // and configure it.
  -        String taskName = getAnt1Name( configuration.getName() );
  +        String taskName = getAnt1Name( element.getName() );
   
           Class taskClass = (Class)project.getTaskDefinitions().get( taskName );
   
           if( taskClass == null )
           {
  -            String message =
  +            final String message =
                   REZ.getString( "taskadapter.invalid-task-name.error", taskName );
  -            throw new ConfigurationException( message );
  +            throw new ModelException( message );
           }
   
           Object adaptedTask = null;
  @@ -54,12 +54,12 @@
           }
           catch( Exception e )
           {
  -            String message =
  +            final String message =
                   REZ.getString( "taskadapter.no-create.error", taskClass.getName() );
  -            throw new ConfigurationException( message );
  +            throw new ModelException( message );
           }
   
  -        configure( adaptedTask, configuration );
  +        model( adaptedTask, element );
   
           setProxy( adaptedTask );
       }
  
  
  
  1.2       +10 -8     jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/Ant1CompatTypeInstanceTask.java
  
  Index: Ant1CompatTypeInstanceTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/Ant1CompatTypeInstanceTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Ant1CompatTypeInstanceTask.java	14 Apr 2002 12:38:40 -0000	1.1
  +++ Ant1CompatTypeInstanceTask.java	21 Apr 2002 02:03:04 -0000	1.2
  @@ -7,16 +7,17 @@
    */
   package org.apache.tools.ant;
   
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.myrmidon.api.metadata.ModelElement;
  +import org.apache.myrmidon.api.metadata.ModelException;
  +import org.apache.myrmidon.api.metadata.Modeller;
   
   /**
    * A task for instantiating Ant1 datatypes.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/14 12:38:40 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/21 02:03:04 $
    */
   public class Ant1CompatTypeInstanceTask
       extends Task
  @@ -24,20 +25,21 @@
       private static final Resources REZ =
           ResourceManager.getPackageResources( Ant1CompatTypeInstanceTask.class );
   
  -    public void configure( Configuration configuration ) throws ConfigurationException
  +    public void model( ModelElement element )
  +        throws ModelException
       {
  -        if( configuration.getAttribute( "id", null ) == null )
  +        if( null == element.getAttribute( "id" ) )
           {
               final String message = REZ.getString( "type.no-id.error" );
  -            throw new ConfigurationException( message );
  +            throw new ModelException( message );
           }
   
  -        String typeName = configuration.getName();
  +        String typeName = element.getName();
           Object datatype = project.createDataType( getAnt1Name( typeName ) );
   
           // Configure the datatype. The type is added to the project
           // as a reference during configuration.
  -        configure( datatype, configuration );
  +        model( datatype, element );
       }
   
       /**
  
  
  
  1.2       +22 -19    jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/Task.java
  
  Index: Task.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/Task.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Task.java	14 Apr 2002 12:38:40 -0000	1.1
  +++ Task.java	21 Apr 2002 02:03:04 -0000	1.2
  @@ -7,12 +7,11 @@
    */
   package org.apache.tools.ant;
   
  -import java.util.Locale;
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.api.metadata.ModelElement;
  +import org.apache.myrmidon.api.metadata.ModelException;
  +import org.apache.myrmidon.api.metadata.Modeller;
   
   /**
    * Ant1 Task proxy for Myrmidon.
  @@ -22,10 +21,11 @@
    * all of the Myrmidon-specific adaptations.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/14 12:38:40 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/21 02:03:04 $
    */
  -public class Task extends OriginalAnt1Task
  -    implements org.apache.myrmidon.api.Task, Configurable
  +public class Task
  +    extends OriginalAnt1Task
  +    implements org.apache.myrmidon.api.Task, Modeller
   {
       protected TaskContext m_context;
   
  @@ -70,35 +70,38 @@
       }
   
       /**
  -     * Uses the task Configuration to perform Ant1-style configuration
  +     * Uses the task ModelElement to perform Ant1-style ModelElement
        * on the Ant1 task. This method configures *all* tasks the way Ant1
        * configures tasks inside a target.
        *
  -     * @param configuration The TaskModel for this Ant1 Task.
  -     * @throws ConfigurationException if the Configuration supplied is not valid
  +     * @param ModelElement The TaskModel for this Ant1 Task.
  +     * @throws ModelException if the ModelElement supplied is not valid
        */
  -    public void configure( Configuration configuration ) throws ConfigurationException
  +    public void model( final ModelElement ModelElement )
  +        throws ModelException
       {
  -        configure( this, configuration );
  +        model( this, ModelElement );
       }
   
       /**
        * Uses reflection to configure any Object, with the help of the Ant1
        * IntrospectionHelper. using . This aims to mimic (to some extent) the
  -     * Ant1-style configuration rules implemented by ProjectHelperImpl.
  +     * Ant1-style ModelElement rules implemented by ProjectHelperImpl.
        * @param target
        *          The object to be configured.
  -     * @param configuration
  +     * @param modelElement
        *          The data to configure the object with.
  -     * @throws ConfigurationException
  -     *          If the Configuration is not valid for the configured object
  +     * @throws ModelException
  +     *          If the ModelElement is not valid for the configured object
        */
  -    protected void configure( Object target, Configuration configuration ) throws ConfigurationException
  +    protected void model( final Object target,
  +                          final ModelElement modelElement )
  +        throws ModelException
       {
  -        //TODO Maybe provide different configuration order for tasks not in a target,
  +        //TODO Maybe provide different ModelElement order for tasks not in a target,
           // elements in a TaskContainer etc...
           Ant1CompatConfigurer configurer =
  -            new Ant1CompatConfigurer( target, configuration, project );
  +            new Ant1CompatConfigurer( target, modelElement, project );
           configurer.createChildren();
           configurer.configure();
           this.init();
  
  
  
  1.2       +13 -12    jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/taskdefs/AbstractAnt1AntTask.java
  
  Index: AbstractAnt1AntTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/taskdefs/AbstractAnt1AntTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractAnt1AntTask.java	14 Apr 2002 12:38:41 -0000	1.1
  +++ AbstractAnt1AntTask.java	21 Apr 2002 02:03:04 -0000	1.2
  @@ -9,9 +9,8 @@
   
   import java.util.Iterator;
   import java.util.Vector;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.executor.Executor;
   import org.apache.tools.ant.Ant1CompatProject;
  @@ -23,7 +22,7 @@
    * which delegate to the Myrmidon versions of these tasks.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/14 12:38:41 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/21 02:03:04 $
    */
   public abstract class AbstractAnt1AntTask
       extends Task
  @@ -112,8 +111,7 @@
   
           try
           {
  -            Configuration antConfig = constructTaskModel();
  -
  +            final ModelElement antConfig = constructTaskModel();
               executeTask( antConfig );
           }
           finally
  @@ -124,9 +122,10 @@
   
       /**
        * Executes the Myrmidon task detailed in the TaskModel provided.
  +     *
        * @param taskModel the TaskModel for the task to execute.
        */
  -    private void executeTask( Configuration taskModel )
  +    private void executeTask( final ModelElement taskModel )
       {
           try
           {
  @@ -182,11 +181,12 @@
   
       /**
        * Builds the TaskModel for executing the Myrmidon version of a task.
  +     *
        * @return a Configuration containing the TaskModel
        */
  -    protected Configuration constructTaskModel()
  +    protected ModelElement constructTaskModel()
       {
  -        DefaultConfiguration antConfig = buildTaskModel();
  +        ModelElement antConfig = buildTaskModel();
   
           antConfig.setAttribute( "inherit-all", String.valueOf( inheritAll ) );
   
  @@ -206,19 +206,19 @@
       /**
        * Create the Myrmidon TaskModel, and configure with subclass-specific config.
        */
  -    protected abstract DefaultConfiguration buildTaskModel();
  +    protected abstract ModelElement buildTaskModel();
   
       /**
        * Adds all defined properties to the supplied Task model.
        * @param taskModel
        */
  -    protected void addProperties( DefaultConfiguration taskModel )
  +    protected void addProperties( final ModelElement taskModel )
       {
           // Add all of the properties.
           Iterator iter = properties.iterator();
           while( iter.hasNext() )
           {
  -            DefaultConfiguration param = new DefaultConfiguration( "param", "" );
  +            ModelElement param = new ModelElement( "param", "" );
               Property property = (Property)iter.next();
               param.setAttribute( "name", property.getName() );
               param.setAttribute( "value", property.getValue() );
  @@ -228,9 +228,10 @@
   
       /**
        * Adds all defined references to the supplied Task model.
  +     *
        * @param taskModel
        */
  -    protected void addReferences( DefaultConfiguration taskModel )
  +    protected void addReferences( ModelElement taskModel )
       {
           // TODO: Handle references.
       }
  
  
  
  1.2       +3 -3      jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/taskdefs/Ant.java
  
  Index: Ant.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/taskdefs/Ant.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Ant.java	14 Apr 2002 12:38:41 -0000	1.1
  +++ Ant.java	21 Apr 2002 02:03:04 -0000	1.2
  @@ -55,8 +55,8 @@
   package org.apache.tools.ant.taskdefs;
   
   import java.io.File;
  -import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.tools.ant.util.FileUtils;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   
   /**
    * Ant1Compat version of &lt;ant&gt;, which delegates to the Myrmidon version.
  @@ -127,9 +127,9 @@
        * with sub-class specific values (antfile).
        * @return the TaskModel
        */
  -    protected DefaultConfiguration buildTaskModel()
  +    protected ModelElement buildTaskModel()
       {
  -        DefaultConfiguration antConfig = new DefaultConfiguration( "ant", "" );
  +        final ModelElement antConfig = new ModelElement( "ant", "" );
   
           // Get the "file" value.
           if( antFile == null )
  
  
  
  1.2       +4 -4      jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/taskdefs/CallTarget.java
  
  Index: CallTarget.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/taskdefs/CallTarget.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CallTarget.java	14 Apr 2002 12:38:41 -0000	1.1
  +++ CallTarget.java	21 Apr 2002 02:03:04 -0000	1.2
  @@ -7,14 +7,14 @@
    */
   package org.apache.tools.ant.taskdefs;
   
  -import org.apache.avalon.framework.configuration.DefaultConfiguration;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   
   /**
    * The Ant1Compat version of the &lt;antcall&gt; task, which delegates to the
    * Myrmidon version.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/14 12:38:41 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/21 02:03:04 $
    */
   public class CallTarget extends AbstractAnt1AntTask
   {
  @@ -29,8 +29,8 @@
       /**
        * The only configuration not done by base class is the task name.
        */
  -    protected DefaultConfiguration buildTaskModel()
  +    protected ModelElement buildTaskModel()
       {
  -        return new DefaultConfiguration( "ant-call", "" );
  +        return new ModelElement( "ant-call", "" );
       }
   }
  
  
  

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


Mime
View raw message