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/container/src/java/org/apache/myrmidon/components/executor AspectAwareExecutor.java DefaultExecutor.java PrintingExecutor.java
Date Sun, 21 Apr 2002 01:54:29 GMT
donaldp     02/04/20 18:54:29

  Modified:    container/src/java/org/apache/myrmidon/interfaces/executor
                        Executor.java
               container/src/java/org/apache/myrmidon/components/executor
                        AspectAwareExecutor.java DefaultExecutor.java
                        PrintingExecutor.java
  Log:
  Rework code so that tasks should no longer be Configurable but instead Modellers
  
  This means that tasks no longer represented by Avalon Configurations but by ModelElements.
  
  Revision  Changes    Path
  1.9       +3 -3      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/executor/Executor.java
  
  Index: Executor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/executor/Executor.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Executor.java	1 Apr 2002 09:56:27 -0000	1.8
  +++ Executor.java	21 Apr 2002 01:54:28 -0000	1.9
  @@ -7,14 +7,14 @@
    */
   package org.apache.myrmidon.interfaces.executor;
   
  -import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   
   /**
    * Engine inteface that should be implemented by all tasklet engines.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.8 $ $Date: 2002/04/01 09:56:27 $
  + * @version $Revision: 1.9 $ $Date: 2002/04/21 01:54:28 $
    */
   public interface Executor
   {
  @@ -28,6 +28,6 @@
        * @param frame The frame in which the task is executed.
        * @exception TaskException if an error occurs
        */
  -    void execute( Configuration task, ExecutionFrame frame )
  +    void execute( ModelElement task, ExecutionFrame frame )
           throws TaskException;
   }
  
  
  
  1.26      +46 -46    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/AspectAwareExecutor.java
  
  Index: AspectAwareExecutor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/AspectAwareExecutor.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- AspectAwareExecutor.java	9 Apr 2002 02:26:34 -0000	1.25
  +++ AspectAwareExecutor.java	21 Apr 2002 01:54:28 -0000	1.26
  @@ -9,19 +9,17 @@
   
   import java.util.ArrayList;
   import java.util.HashMap;
  +import java.util.Properties;
   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.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.logger.Logger;
  -import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.myrmidon.api.Task;
  -import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.TaskContext;
  +import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.interfaces.aspect.AspectManager;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   
  @@ -30,7 +28,7 @@
    * the aspects helpers.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.25 $ $Date: 2002/04/09 02:26:34 $
  + * @version $Revision: 1.26 $ $Date: 2002/04/21 01:54:28 $
    */
   public class AspectAwareExecutor
       extends DefaultExecutor
  @@ -39,7 +37,7 @@
       private static final Resources REZ =
           ResourceManager.getPackageResources( AspectAwareExecutor.class );
   
  -    private static final Configuration[] EMPTY_ELEMENTS = new Configuration[ 0 ];
  +    private static final ModelElement[] EMPTY_ELEMENTS = new ModelElement[ 0 ];
   
       private AspectManager m_aspectManager;
   
  @@ -55,7 +53,7 @@
           m_aspectManager = (AspectManager)serviceManager.lookup( AspectManager.ROLE );
       }
   
  -    public void execute( final Configuration taskModel, final ExecutionFrame frame )
  +    public void execute( final ModelElement taskModel, final ExecutionFrame frame )
           throws TaskException
       {
           try
  @@ -72,13 +70,13 @@
           }
       }
   
  -    private void executeTask( final Configuration model,
  +    private void executeTask( final ModelElement model,
                                 final ExecutionFrame frame )
           throws TaskException
       {
           try
           {
  -            Configuration taskModel = getAspectManager().preCreate( model );
  +            ModelElement taskModel = getAspectManager().preCreate( model );
               taskModel = prepareAspects( taskModel );
   
               final String taskName = taskModel.getName();
  @@ -113,7 +111,8 @@
           }
       }
   
  -    protected void doExecute( final Configuration taskModel, final Task task )
  +    protected void doExecute( final ModelElement taskModel,
  +                              final Task task )
           throws TaskException
       {
           task.execute();
  @@ -122,11 +121,11 @@
       //TODO: Extract and clean taskModel here.
       //Get all parameters from model and provide to appropriate aspect.
       //aspect( final Parameters parameters, final Configuration[] elements )
  -    private final Configuration prepareAspects( final Configuration taskModel )
  +    private final ModelElement prepareAspects( final ModelElement taskModel )
           throws TaskException
       {
  -        final DefaultConfiguration newTaskModel =
  -            new DefaultConfiguration( taskModel.getName(), taskModel.getLocation() );
  +        final ModelElement newTaskModel =
  +            new ModelElement( taskModel.getName(), taskModel.getLocation() );
           final HashMap parameterMap = new HashMap();
           final HashMap elementMap = new HashMap();
   
  @@ -134,11 +133,11 @@
           processElements( taskModel, newTaskModel, elementMap );
           try
           {
  -            newTaskModel.setValue( taskModel.getValue() );
  +            newTaskModel.setContent( taskModel.getContent() );
           }
  -        catch( final ConfigurationException cee )
  +        catch( IllegalArgumentException e )
           {
  -            //Will never occur
  +            //SHould never occur
           }
   
           dispatchAspectsSettings( parameterMap, elementMap );
  @@ -157,20 +156,20 @@
           {
               final ArrayList elementList = (ArrayList)elementMap.remove( names[ i ] );
   
  -            Parameters parameters = (Parameters)parameterMap.remove( names[ i ] );
  +            Properties parameters = (Properties)parameterMap.remove( names[ i ] );
               if( null == parameters )
               {
  -                parameters = Parameters.EMPTY_PARAMETERS;
  +                parameters = new Properties();
               }
   
  -            Configuration[] elements = null;
  +            ModelElement[] elements = null;
               if( null == elementList )
               {
                   elements = EMPTY_ELEMENTS;
               }
               else
               {
  -                elements = (Configuration[])elementList.toArray( EMPTY_ELEMENTS );
  +                elements = (ModelElement[])elementList.toArray( EMPTY_ELEMENTS );
               }
   
               dispatch( names[ i ], parameters, elements );
  @@ -189,10 +188,10 @@
               for( int i = 0; i < namespaces.length; i++ )
               {
                   final String namespace = namespaces[ i ];
  -                final Parameters parameters = (Parameters)parameterMap.get( namespace );
  +                final Properties parameters = (Properties)parameterMap.get( namespace );
                   final ArrayList elementList = (ArrayList)elementMap.remove( namespace );
   
  -                Configuration[] elements = null;
  +                ModelElement[] elements = null;
   
                   if( null == elementList )
                   {
  @@ -200,7 +199,7 @@
                   }
                   else
                   {
  -                    elements = (Configuration[])elementList.toArray( EMPTY_ELEMENTS );
  +                    elements = (ModelElement[])elementList.toArray( EMPTY_ELEMENTS );
                   }
   
                   unusedSetting( namespace, parameters, elements );
  @@ -216,30 +215,30 @@
               {
                   final String namespace = namespaces[ i ];
                   final ArrayList elementList = (ArrayList)elementMap.remove( namespace );
  -                final Configuration[] elements =
  -                    (Configuration[])elementList.toArray( EMPTY_ELEMENTS );
  +                final ModelElement[] elements =
  +                    (ModelElement[])elementList.toArray( EMPTY_ELEMENTS );
   
  -                unusedSetting( namespace, Parameters.EMPTY_PARAMETERS, elements );
  +                unusedSetting( namespace, new Properties(), elements );
               }
           }
       }
   
       private void unusedSetting( final String namespace,
  -                                final Parameters parameters,
  -                                final Configuration[] elements )
  +                                final Properties parameters,
  +                                final ModelElement[] elements )
           throws TaskException
       {
           final String message =
               REZ.getString( "unused-settings.error",
                              namespace,
  -                           Integer.toString( parameters.getNames().length ),
  +                           Integer.toString( parameters.keySet().size() ),
                              Integer.toString( elements.length ) );
           throw new TaskException( message );
       }
   
       private void dispatch( final String namespace,
  -                           final Parameters parameters,
  -                           final Configuration[] elements )
  +                           final Properties parameters,
  +                           final ModelElement[] elements )
           throws TaskException
       {
           getAspectManager().dispatchAspectSettings( namespace, parameters, elements );
  @@ -249,17 +248,17 @@
               final String message =
                   REZ.getString( "dispatch-settings.notice",
                                  namespace,
  -                               Integer.toString( parameters.getNames().length ),
  +                               Integer.toString( parameters.keySet().size() ),
                                  Integer.toString( elements.length ) );
               getLogger().debug( message );
           }
       }
   
  -    private final void processElements( final Configuration taskModel,
  -                                        final DefaultConfiguration newTaskModel,
  +    private final void processElements( final ModelElement taskModel,
  +                                        final ModelElement newTaskModel,
                                           final HashMap map )
       {
  -        final Configuration[] elements = taskModel.getChildren();
  +        final ModelElement[] elements = taskModel.getChildren();
           for( int i = 0; i < elements.length; i++ )
           {
               final String name = elements[ i ].getName();
  @@ -278,15 +277,15 @@
           }
       }
   
  -    private final void processAttributes( final Configuration taskModel,
  -                                          final DefaultConfiguration newTaskModel,
  +    private final void processAttributes( final ModelElement taskModel,
  +                                          final ModelElement newTaskModel,
                                             final HashMap map )
       {
           final String[] attributes = taskModel.getAttributeNames();
           for( int i = 0; i < attributes.length; i++ )
           {
               final String name = attributes[ i ];
  -            final String value = taskModel.getAttribute( name, null );
  +            final String value = taskModel.getAttribute( name );
   
               final int index = name.indexOf( ':' );
   
  @@ -298,16 +297,16 @@
               {
                   final String namespace = name.substring( 0, index );
                   final String localName = name.substring( index + 1 );
  -                final Parameters parameters = getParameters( namespace, map );
  -                parameters.setParameter( localName, value );
  +                final Properties parameters = getParameters( namespace, map );
  +                parameters.setProperty( localName, value );
               }
           }
       }
   
  -    private final ArrayList getElements( final String namespace, final HashMap map )
  +    private final ArrayList getElements( final String namespace,
  +                                         final HashMap map )
       {
           ArrayList elements = (ArrayList)map.get( namespace );
  -
           if( null == elements )
           {
               elements = new ArrayList();
  @@ -317,13 +316,14 @@
           return elements;
       }
   
  -    private final Parameters getParameters( final String namespace, final HashMap map )
  +    private final Properties getParameters( final String namespace,
  +                                            final HashMap map )
       {
  -        Parameters parameters = (Parameters)map.get( namespace );
  +        Properties parameters = (Properties)map.get( namespace );
   
           if( null == parameters )
           {
  -            parameters = new Parameters();
  +            parameters = new Properties();
               map.put( namespace, parameters );
           }
   
  
  
  
  1.36      +5 -5      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java
  
  Index: DefaultExecutor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- DefaultExecutor.java	9 Apr 2002 02:26:34 -0000	1.35
  +++ DefaultExecutor.java	21 Apr 2002 01:54:28 -0000	1.36
  @@ -9,11 +9,11 @@
   
   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.logger.AbstractLogEnabled;
   import org.apache.myrmidon.api.Task;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.components.workspace.DefaultTaskContext;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
  @@ -25,7 +25,7 @@
    * The basic executor that just executes the tasks.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.35 $ $Date: 2002/04/09 02:26:34 $
  + * @version $Revision: 1.36 $ $Date: 2002/04/21 01:54:28 $
    */
   public class DefaultExecutor
       extends AbstractLogEnabled
  @@ -37,7 +37,7 @@
       /**
        * Executes a task.
        */
  -    public void execute( final Configuration taskModel, final ExecutionFrame frame )
  +    public void execute( final ModelElement taskModel, final ExecutionFrame frame )
           throws TaskException
       {
           final String taskName = taskModel.getName();
  @@ -109,7 +109,7 @@
        * Configures a task instance.
        */
       protected final void doConfigure( final Task task,
  -                                      final Configuration taskModel,
  +                                      final ModelElement taskModel,
                                         final TaskContext taskContext,
                                         final ExecutionFrame frame )
           throws Exception
  @@ -122,7 +122,7 @@
        * Sets the context for a task.
        */
       protected final void doContextualize( final Task task,
  -                                          final Configuration taskModel,
  +                                          final ModelElement taskModel,
                                             final TaskContext taskContext,
                                             final ExecutionFrame frame )
           throws TaskException
  
  
  
  1.5       +10 -10    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/PrintingExecutor.java
  
  Index: PrintingExecutor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/PrintingExecutor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PrintingExecutor.java	7 Feb 2002 13:02:20 -0000	1.4
  +++ PrintingExecutor.java	21 Apr 2002 01:54:28 -0000	1.5
  @@ -7,31 +7,31 @@
    */
   package org.apache.myrmidon.components.executor;
   
  -import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.myrmidon.api.Task;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   
   /**
    * An executor that just displays the tasks rather than executing them.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.4 $ $Date: 2002/02/07 13:02:20 $
  + * @version $Revision: 1.5 $ $Date: 2002/04/21 01:54:28 $
    */
   public class PrintingExecutor
       extends AspectAwareExecutor
   {
  -    protected void doExecute( final Configuration taskModel, final Task task )
  +    protected void doExecute( final ModelElement taskModel, final Task task )
           throws TaskException
       {
           final StringBuffer sb = new StringBuffer();
  -        printConfiguration( taskModel, 0, sb );
  +        printModelElement( taskModel, 0, sb );
   
           System.out.println( sb.toString() );
       }
   
  -    private void printConfiguration( final Configuration taskModel,
  -                                     final int level,
  -                                     final StringBuffer sb )
  +    private void printModelElement( final ModelElement taskModel,
  +                                    final int level,
  +                                    final StringBuffer sb )
       {
           for( int i = 0; i < level; i++ )
           {
  @@ -45,7 +45,7 @@
           for( int i = 0; i < names.length; i++ )
           {
               final String name = names[ i ];
  -            final String value = taskModel.getAttribute( name, null );
  +            final String value = taskModel.getAttribute( name );
   
               sb.append( ' ' );
               sb.append( name );
  @@ -54,7 +54,7 @@
               sb.append( '\"' );
           }
   
  -        final Configuration[] children = taskModel.getChildren();
  +        final ModelElement[] children = taskModel.getChildren();
           if( 0 == children.length )
           {
               sb.append( "/>\n" );
  @@ -65,7 +65,7 @@
   
               for( int i = 0; i < children.length; i++ )
               {
  -                printConfiguration( children[ i ], level + 1, sb );
  +                printModelElement( children[ i ], level + 1, sb );
               }
   
               for( int i = 0; i < level; i++ )
  
  
  

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