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/framework/src/java/org/apache/myrmidon/framework AbstractContainerTask.java AbstractFacadeTask.java TaskList.java TypeInstanceTask.java
Date Sun, 21 Apr 2002 01:58:52 GMT
donaldp     02/04/20 18:58:52

  Modified:    framework/src/java/org/apache/myrmidon/framework
                        AbstractContainerTask.java AbstractFacadeTask.java
                        TaskList.java TypeInstanceTask.java
  Log:
  Configuration --> ModelElement
  
  Revision  Changes    Path
  1.2       +26 -23    jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java
  
  Index: AbstractContainerTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractContainerTask.java	14 Apr 2002 09:30:13 -0000	1.1
  +++ AbstractContainerTask.java	21 Apr 2002 01:58:52 -0000	1.2
  @@ -11,11 +11,11 @@
   import org.apache.aut.converter.ConverterException;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.myrmidon.api.AbstractTask;
   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.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.executor.Executor;
  @@ -29,7 +29,7 @@
    * This is the class that Task writers should extend to provide custom tasks.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/14 09:30:13 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/21 01:58:52 $
    */
   public abstract class AbstractContainerTask
       extends AbstractTask
  @@ -68,10 +68,10 @@
        * @param to type to convert object to
        * @param object the object to convert
        * @return the converted object
  -     * @exception ConfigurationException if an error occurs
  +     * @exception ModelException if an error occurs
        */
       protected final Object convert( final Class to, final Object object )
  -        throws ConfigurationException
  +        throws ModelException
       {
           try
           {
  @@ -80,7 +80,7 @@
           catch( final ConverterException ce )
           {
               final String message = REZ.getString( "container.bad-config.error" );
  -            throw new ConfigurationException( message, ce );
  +            throw new ModelException( message, ce );
           }
       }
   
  @@ -89,27 +89,27 @@
        *
        * @param object the object
        * @param element the configuration element
  -     * @exception ConfigurationException if an error occurs
  +     * @exception ModelException if an error occurs
        */
       protected final void configureElement( final Object object,
  -                                           final Configuration element )
  -        throws ConfigurationException
  +                                           final ModelElement element )
  +        throws ModelException
       {
           m_configurer.configureElement( object, element, getContext() );
       }
   
       /**
  -     * Configure an object using specific configuration element.
  +     * Configure an object using specific ModelElement.
        *
        * @param object the object
        * @param clazz the class to use when configuring element
  -     * @param element the configuration element
  -     * @exception ConfigurationException if an error occurs
  +     * @param element the ModelElement
  +     * @exception ModelException if an error occurs
        */
       protected final void configureElement( final Object object,
                                              final Class clazz,
  -                                           final Configuration element )
  -        throws ConfigurationException
  +                                           final ModelElement element )
  +        throws ModelException
       {
           m_configurer.configureElement( object, clazz, element, getContext() );
       }
  @@ -120,10 +120,12 @@
        * @param object the object
        * @param name the attibute name
        * @param value the attibute value
  -     * @exception ConfigurationException if an error occurs
  +     * @exception ModelException if an error occurs
        */
  -    protected final void configureAttribute( final Object object, final String name, final
String value )
  -        throws ConfigurationException
  +    protected final void configureAttribute( final Object object,
  +                                             final String name,
  +                                             final String value )
  +        throws ModelException
       {
           m_configurer.configureAttribute( object, name, value, getContext() );
       }
  @@ -135,12 +137,13 @@
        * @param clazz the class to use when configuring element
        * @param name the attibute name
        * @param value the attibute value
  -     * @exception ConfigurationException if an error occurs
  +     * @exception ModelException if an error occurs
        */
       protected final void configureAttribute( final Object object,
                                                final Class clazz,
  -                                             final String name, final String value )
  -        throws ConfigurationException
  +                                             final String name,
  +                                             final String value )
  +        throws ModelException
       {
           m_configurer.configureAttribute( object, clazz, name, value, getContext() );
       }
  @@ -148,12 +151,12 @@
       /**
        * Utility method to execute specified tasks in current ExecutionFrame.
        */
  -    protected final void executeTasks( final Configuration[] tasks )
  +    protected final void executeTasks( final ModelElement[] tasks )
           throws TaskException
       {
           for( int i = 0; i < tasks.length; i++ )
           {
  -            final Configuration task = tasks[ i ];
  +            final ModelElement task = tasks[ i ];
               executeTask( task );
           }
       }
  @@ -161,7 +164,7 @@
       /**
        * Utility method to execute specified task in current ExecutionFrame.
        */
  -    protected final void executeTask( final Configuration task )
  +    protected final void executeTask( final ModelElement task )
           throws TaskException
       {
           m_executor.execute( task, m_frame );
  
  
  
  1.2       +34 -27    jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/AbstractFacadeTask.java
  
  Index: AbstractFacadeTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/AbstractFacadeTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractFacadeTask.java	14 Apr 2002 09:30:13 -0000	1.1
  +++ AbstractFacadeTask.java	21 Apr 2002 01:58:52 -0000	1.2
  @@ -9,22 +9,21 @@
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.configuration.DefaultConfiguration;
   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;
   
   /**
    * Abstract task used to write tasks that delegate to facades
    * such as Javac, Jspc and so forth.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/14 09:30:13 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/21 01:58:52 $
    */
   public abstract class AbstractFacadeTask
       extends AbstractContainerTask
  -    implements Configurable
  +    implements Modeller
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( AbstractFacadeTask.class );
  @@ -49,7 +48,7 @@
       /**
        * The configuration used to configure the facade implementation.
        */
  -    private Configuration m_configuration;
  +    private ModelElement m_model;
   
       /**
        * Create the facade task that works with specified facade class,
  @@ -68,10 +67,10 @@
       /**
        * Supply the configuration for this task.
        */
  -    public void configure( final Configuration configuration )
  -        throws ConfigurationException
  +    public void model( final ModelElement model )
  +        throws ModelException
       {
  -        m_configuration = configuration;
  +        m_model = model;
       }
   
       /**
  @@ -95,19 +94,19 @@
       protected void configureFacade( final Object facade )
           throws TaskException
       {
  -        Configuration configuration = m_configuration;
  +        ModelElement model = m_model;
   
           if( null != m_selector &&
  -            null != m_configuration.getAttribute( m_selector, null ) )
  +            null != m_model.getAttribute( m_selector ) )
           {
  -            configuration = rebuildConfiguration( m_configuration, m_selector );
  +            model = rebuildConfiguration( m_model, m_selector );
           }
   
           try
           {
  -            configureElement( facade, m_facadeType, configuration );
  +            configureElement( facade, m_facadeType, model );
           }
  -        catch( final ConfigurationException ce )
  +        catch( final ModelException ce )
           {
               throw new TaskException( ce.getMessage(), ce );
           }
  @@ -117,35 +116,35 @@
        * Rebuild the configuration tree with the attribute with specified
        * name removed from top-level element.
        */
  -    private Configuration rebuildConfiguration( final Configuration configuration,
  -                                                final String attribute )
  +    private ModelElement rebuildConfiguration( final ModelElement element,
  +                                               final String attribute )
       {
  -        final DefaultConfiguration newConfiguration =
  -            new DefaultConfiguration( configuration.getName(),
  -                                      configuration.getLocation() );
  +        final ModelElement newElement =
  +            new ModelElement( element.getName(),
  +                              element.getLocation() );
   
           //Add all the attributes from old configuration except the one
           //that was used to select the particular implementation
  -        final String[] names = configuration.getAttributeNames();
  +        final String[] names = element.getAttributeNames();
           for( int i = 0; i < names.length; i++ )
           {
               final String name = names[ i ];
               if( !name.equals( attribute ) )
               {
  -                final String value = configuration.getAttribute( name, null );
  -                newConfiguration.setAttribute( name, value );
  +                final String value = element.getAttribute( name );
  +                newElement.setAttribute( name, value );
               }
           }
   
           //Add all elements to new configuration element in the
           //correct order
  -        final Configuration[] children = configuration.getChildren();
  +        final ModelElement[] children = element.getChildren();
           for( int i = 0; i < children.length; i++ )
           {
  -            newConfiguration.addChild( children[ i ] );
  +            newElement.addChild( children[ i ] );
           }
   
  -        return newConfiguration;
  +        return newElement;
       }
   
       /**
  @@ -177,7 +176,15 @@
       {
           if( null != m_selector )
           {
  -            return m_configuration.getAttribute( m_selector, m_defaultName );
  +            final String implName = m_model.getAttribute( m_selector );
  +            if( null == implName )
  +            {
  +                return m_defaultName;
  +            }
  +            else
  +            {
  +                return implName;
  +            }
           }
           else
           {
  
  
  
  1.2       +5 -5      jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/TaskList.java
  
  Index: TaskList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/TaskList.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TaskList.java	14 Apr 2002 09:30:13 -0000	1.1
  +++ TaskList.java	21 Apr 2002 01:58:52 -0000	1.2
  @@ -8,25 +8,25 @@
   package org.apache.myrmidon.framework;
   
   import java.util.ArrayList;
  -import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   
   /**
    * This object contains an ordered list of tasks.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/14 09:30:13 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/21 01:58:52 $
    */
   public class TaskList
   {
       private ArrayList m_tasks = new ArrayList();
   
  -    public void add( final Configuration task )
  +    public void add( final ModelElement task )
       {
           m_tasks.add( task );
       }
   
  -    public Configuration[] getTasks()
  +    public ModelElement[] getTasks()
       {
  -        return (Configuration[])m_tasks.toArray( new Configuration[ m_tasks.size() ] );
  +        return (ModelElement[])m_tasks.toArray( new ModelElement[ m_tasks.size() ] );
       }
   }
  
  
  
  1.2       +20 -18    jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/TypeInstanceTask.java
  
  Index: TypeInstanceTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/TypeInstanceTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypeInstanceTask.java	14 Apr 2002 09:30:13 -0000	1.1
  +++ TypeInstanceTask.java	21 Apr 2002 01:58:52 -0000	1.2
  @@ -9,21 +9,20 @@
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.configuration.DefaultConfiguration;
   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;
   
   /**
    * This is the property "task" to declare a binding of a datatype to a name.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/14 09:30:13 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/21 01:58:52 $
    */
   public class TypeInstanceTask
       extends AbstractContainerTask
  -    implements Configurable
  +    implements Modeller
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( TypeInstanceTask.class );
  @@ -31,17 +30,17 @@
       private String m_id;
       private Object m_value;
   
  -    public void configure( final Configuration configuration )
  -        throws ConfigurationException
  +    public void model( final ModelElement model )
  +        throws ModelException
       {
  -        final DefaultConfiguration newConfiguration =
  -            new DefaultConfiguration( configuration.getName(), configuration.getLocation()
);
  +        final ModelElement newElement =
  +            new ModelElement( model.getName(), model.getLocation() );
   
  -        final String[] attributes = configuration.getAttributeNames();
  +        final String[] attributes = model.getAttributeNames();
           for( int i = 0; i < attributes.length; i++ )
           {
               final String name = attributes[ i ];
  -            final String value = configuration.getAttribute( name );
  +            final String value = model.getAttribute( name );
   
               if( name.equals( "id" ) || name.equals( "local-scope" ) )
               {
  @@ -49,27 +48,30 @@
               }
               else
               {
  -                newConfiguration.setAttribute( name, value );
  +                newElement.setAttribute( name, value );
               }
           }
   
  -        final Configuration[] children = configuration.getChildren();
  +        final ModelElement[] children = model.getChildren();
           for( int i = 0; i < children.length; i++ )
           {
  -            newConfiguration.addChild( children[ i ] );
  +            newElement.addChild( children[ i ] );
           }
   
           try
           {
  -            m_value = newInstance( DataType.ROLE, configuration.getName() );
  +            m_value = newInstance( DataType.ROLE, model.getName() );
           }
           catch( final Exception e )
           {
               final String message = REZ.getString( "type.no-create.error" );
  -            throw new ConfigurationException( message, e );
  +            throw new ModelException( message, e );
           }
   
  -        configureElement( m_value, newConfiguration );
  +        //Make sure we make the element read only prior
  +        //to configuration
  +        newElement.makeReadOnly();
  +        configureElement( m_value, newElement );
       }
   
       public void setId( final String id )
  
  
  

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