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/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor DefaultExecutor.java Executor.java
Date Tue, 29 May 2001 06:00:50 GMT
donaldp     01/05/28 23:00:50

  Modified:    proposal/myrmidon/src/java/org/apache/ant Main.java
               proposal/myrmidon/src/java/org/apache/ant/modules/basic
                        Property.java
               proposal/myrmidon/src/java/org/apache/ant/modules/core
                        AbstractResourceRegisterer.java
                        RegisterTasklet.java
               proposal/myrmidon/src/java/org/apache/ant/project
                        DefaultProjectEngine.java ProjectEngine.java
               proposal/myrmidon/src/java/org/apache/ant/tasklet/engine
                        DefaultTskDeployer.java TskDeployer.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor
                        MyrmidonEmbeddor.java
  Added:       proposal/myrmidon/src/java/org/apache/myrmidon/components/executor
                        DefaultExecutor.java Executor.java
  Removed:     proposal/myrmidon/src/java/org/apache/ant/tasklet/engine
                        DefaultTaskletEngine.java TaskletEngine.java
  Log:
  Moved TaskletEngine-> myrmidon.components.executor
  
  Changed name to match word class of other components and to enforce uniformity in conventions.
(Also same practice as used in other projects which hopefully will mean it is easier to understand).
  
  Revision  Changes    Path
  1.16      +0 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/Main.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Main.java	2001/05/28 12:28:05	1.15
  +++ Main.java	2001/05/29 06:00:46	1.16
  @@ -31,7 +31,6 @@
   import org.apache.myrmidon.api.JavaVersion;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.DefaultTaskContext;
  -import org.apache.ant.tasklet.engine.TaskletEngine;
   import org.apache.avalon.excalibur.cli.CLArgsParser;
   import org.apache.avalon.excalibur.cli.CLOption;
   import org.apache.avalon.excalibur.cli.CLUtil;
  
  
  
  1.6       +0 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/basic/Property.java
  
  Index: Property.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/basic/Property.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Property.java	2001/05/28 09:06:46	1.5
  +++ Property.java	2001/05/29 06:00:46	1.6
  @@ -12,7 +12,6 @@
   import org.apache.ant.convert.Converter;
   import org.apache.ant.tasklet.DataType;
   import org.apache.ant.tasklet.engine.DataTypeEngine;
  -import org.apache.ant.tasklet.engine.TaskletEngine;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
  
  
  
  1.5       +4 -4      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/core/AbstractResourceRegisterer.java
  
  Index: AbstractResourceRegisterer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/core/AbstractResourceRegisterer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractResourceRegisterer.java	2001/05/28 12:57:12	1.4
  +++ AbstractResourceRegisterer.java	2001/05/29 06:00:47	1.5
  @@ -13,7 +13,7 @@
   import org.apache.ant.AntException;
   import org.apache.myrmidon.api.AbstractTask;
   import org.apache.ant.tasklet.engine.TskDeployer;
  -import org.apache.ant.tasklet.engine.TaskletEngine;
  +import org.apache.myrmidon.components.executor.Executor;
   import org.apache.ant.tasklet.engine.DataTypeEngine;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.ComponentException;
  @@ -34,13 +34,13 @@
       protected String              m_classname;
       protected TskDeployer         m_tskDeployer;
       protected DataTypeEngine      m_dataTypeEngine;
  -    protected TaskletEngine          m_engine;
  +    protected Executor            m_engine;
   
       public void compose( final ComponentManager componentManager )
           throws ComponentException
       {
  -        m_engine = (TaskletEngine)componentManager.
  -            lookup( "org.apache.ant.tasklet.engine.TaskletEngine" );
  +        m_engine = (Executor)componentManager.
  +            lookup( "org.apache.myrmidon.components.executor.Executor" );
   
           m_tskDeployer = (TskDeployer)componentManager.
               lookup( "org.apache.ant.tasklet.engine.TskDeployer" );
  
  
  
  1.4       +1 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterTasklet.java
  
  Index: RegisterTasklet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterTasklet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RegisterTasklet.java	2001/05/28 12:57:13	1.3
  +++ RegisterTasklet.java	2001/05/29 06:00:47	1.4
  @@ -28,7 +28,7 @@
       {
           if( null == classname )
           {
  -            try { m_tskDeployer.deployTasklet( name, url.toString(), url ); }
  +            try { m_tskDeployer.deployTask( name, url.toString(), url ); }
               catch( final DeploymentException de )
               {
                   throw new AntException( "Failed deploying " + name + " from " + url, de
);
  
  
  
  1.11      +5 -6      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectEngine.java
  
  Index: DefaultProjectEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectEngine.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultProjectEngine.java	2001/05/28 10:27:53	1.10
  +++ DefaultProjectEngine.java	2001/05/29 06:00:47	1.11
  @@ -12,8 +12,7 @@
   import org.apache.ant.AntException;
   import org.apache.myrmidon.api.DefaultTaskContext;
   import org.apache.myrmidon.api.TaskContext;
  -import org.apache.ant.tasklet.engine.DefaultTaskletEngine;
  -import org.apache.ant.tasklet.engine.TaskletEngine;
  +import org.apache.myrmidon.components.executor.Executor;
   import org.apache.ant.util.Condition;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
  @@ -35,7 +34,7 @@
       extends AbstractLoggable
       implements ProjectEngine, Composable
   {
  -    protected TaskletEngine            m_taskEngine;
  +    protected Executor                 m_executor;
       protected ProjectListenerSupport   m_listenerSupport = new ProjectListenerSupport();
       protected DefaultComponentManager  m_componentManager;
   
  @@ -69,8 +68,8 @@
           throws ComponentException
       {
           m_componentManager = (DefaultComponentManager)componentManager;
  -        m_taskEngine = (TaskletEngine)componentManager.
  -            lookup( "org.apache.ant.tasklet.engine.TaskletEngine" );
  +        m_executor = (Executor)componentManager.
  +            lookup( "org.apache.myrmidon.components.executor.Executor" );
       }
   
       /**
  @@ -240,7 +239,7 @@
           m_listenerSupport.taskStarted( name );
   
           //run task
  -        m_taskEngine.execute( task, context );
  +        m_executor.execute( task, context );
   
           //notify listeners task has ended
           m_listenerSupport.taskFinished();
  
  
  
  1.8       +0 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/ProjectEngine.java
  
  Index: ProjectEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/ProjectEngine.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ProjectEngine.java	2001/05/28 09:06:47	1.7
  +++ ProjectEngine.java	2001/05/29 06:00:48	1.8
  @@ -9,7 +9,6 @@
   
   import org.apache.ant.AntException;
   import org.apache.myrmidon.api.TaskContext;
  -import org.apache.ant.tasklet.engine.TaskletEngine;
   import org.apache.avalon.framework.component.Component;
   
   /**
  
  
  
  1.9       +52 -51    jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTskDeployer.java
  
  Index: DefaultTskDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTskDeployer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultTskDeployer.java	2001/05/28 06:28:13	1.8
  +++ DefaultTskDeployer.java	2001/05/29 06:00:49	1.9
  @@ -18,21 +18,22 @@
   import org.apache.ant.convert.engine.ConverterEngine;
   import org.apache.ant.convert.engine.ConverterRegistry;
   import org.apache.ant.convert.engine.DefaultConverterInfo;
  -import org.apache.avalon.framework.component.Component;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.Composable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.camelot.AbstractDeployer;
   import org.apache.avalon.framework.camelot.DefaultLocator;
   import org.apache.avalon.framework.camelot.DefaultRegistry;
  -import org.apache.avalon.framework.camelot.DeploymentException;
   import org.apache.avalon.framework.camelot.DeployerUtil;
  +import org.apache.avalon.framework.camelot.DeploymentException;
   import org.apache.avalon.framework.camelot.Loader;
   import org.apache.avalon.framework.camelot.Registry;
   import org.apache.avalon.framework.camelot.RegistryException;
  +import org.apache.avalon.framework.component.Component;
  +import org.apache.avalon.framework.component.ComponentException;
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.log.Logger;
  +import org.apache.myrmidon.components.executor.Executor;
   
   /**
    * This class deploys a .tsk file into a registry.
  @@ -43,12 +44,12 @@
       extends AbstractDeployer
       implements Composable, TskDeployer
   {
  -    protected final static String   TSKDEF_FILE     = "TASK-LIB/taskdefs.xml";
  +    private final static String   TSKDEF_FILE     = "TASK-LIB/taskdefs.xml";
   
  -    protected Registry              m_dataTypeRegistry;
  -    protected Registry              m_taskletRegistry;
  -    protected Registry              m_converterRegistry;
  -    protected ConverterRegistry     m_converterInfoRegistry;
  +    private Registry              m_dataTypeRegistry;
  +    private Registry              m_taskRegistry;
  +    private Registry              m_converterRegistry;
  +    private ConverterRegistry     m_converterInfoRegistry;
   
       /**
        * Default constructor.
  @@ -57,9 +58,9 @@
       {
           super();
           m_autoUndeploy = true;
  -        m_type = "Tasklet";
  +        m_type = "Task";
       }
  -    
  +
       /**
        * Retrieve relevent services needed to deploy.
        *
  @@ -69,11 +70,11 @@
       public void compose( final ComponentManager componentManager )
           throws ComponentException
       {
  -        final TaskletEngine taskletEngine = (TaskletEngine)componentManager.
  -            lookup( "org.apache.ant.tasklet.engine.TaskletEngine" );
  +        //UGLY HACK alert !!!
  +        final Executor executor = (Executor)componentManager.
  +            lookup( "org.apache.myrmidon.components.executor.Executor" );
  +        m_taskRegistry = executor.getRegistry();
   
  -        m_taskletRegistry = taskletEngine.getRegistry();
  -
           final ConverterEngine converterEngine = (ConverterEngine)componentManager.
               lookup( "org.apache.ant.convert.engine.ConverterEngine" );
   
  @@ -82,7 +83,7 @@
   
           final DataTypeEngine dataTypeEngine = (DataTypeEngine)componentManager.
               lookup( "org.apache.ant.tasklet.engine.DataTypeEngine" );
  -        
  +
           m_dataTypeRegistry = dataTypeEngine.getRegistry();
       }
   
  @@ -90,7 +91,7 @@
        * Deploy a file.
        * Eventually this should be cached for performance reasons.
        *
  -     * @param location the location 
  +     * @param location the location
        * @param file the file
        * @exception DeploymentException if an error occurs
        */
  @@ -100,11 +101,11 @@
           final ZipFile zipFile = DeployerUtil.getZipFileFor( file );
   
           URL url = null;
  -        
  +
           try
           {
               try { url = file.toURL(); }
  -            catch( final MalformedURLException mue ) 
  +            catch( final MalformedURLException mue )
               {
                   throw new DeploymentException( "Unable to form url", mue );
               }
  @@ -117,7 +118,7 @@
           }
       }
   
  -    protected void loadResources( final ZipFile zipFile, final String location, final URL
url )
  +    private void loadResources( final ZipFile zipFile, final String location, final URL
url )
           throws DeploymentException
       {
           final Configuration taskdefs = DeployerUtil.loadConfiguration( zipFile, TSKDEF_FILE
);
  @@ -127,9 +128,9 @@
               final Configuration[] tasks = taskdefs.getChildren( "task" );
               for( int i = 0; i < tasks.length; i++ )
               {
  -                handleTasklet( tasks[ i ], url );
  +                handleTask( tasks[ i ], url );
               }
  -            
  +
               final Configuration[] converters = taskdefs.getChildren( "converter" );
               for( int i = 0; i < converters.length; i++ )
               {
  @@ -147,14 +148,14 @@
               throw new DeploymentException( "Malformed taskdefs.xml", ce );
           }
       }
  -    
  +
       public void deployConverter( String name, String location, URL url )
           throws DeploymentException
       {
           checkDeployment( location, url );
           final ZipFile zipFile = DeployerUtil.getZipFileFor( getFileFor( url ) );
           final Configuration taskdefs = DeployerUtil.loadConfiguration( zipFile, TSKDEF_FILE
);
  -        
  +
           try
           {
               final Configuration[] converters = taskdefs.getChildren( "converter" );
  @@ -178,9 +179,9 @@
       {
           checkDeployment( location, url );
           final ZipFile zipFile = DeployerUtil.getZipFileFor( getFileFor( url ) );
  -        final Configuration datatypedefs = 
  +        final Configuration datatypedefs =
               DeployerUtil.loadConfiguration( zipFile, TSKDEF_FILE );
  -        
  +
           try
           {
               final Configuration[] datatypes = datatypedefs.getChildren( "datatype" );
  @@ -198,14 +199,14 @@
               throw new DeploymentException( "Malformed taskdefs.xml", ce );
           }
       }
  -    
  -    public void deployTasklet( final String name, final String location, final URL url
)
  +
  +    public void deployTask( final String name, final String location, final URL url )
           throws DeploymentException
       {
           checkDeployment( location, url );
           final ZipFile zipFile = DeployerUtil.getZipFileFor( getFileFor( url ) );
           final Configuration taskdefs = DeployerUtil.loadConfiguration( zipFile, TSKDEF_FILE
);
  -        
  +
           try
           {
               final Configuration[] tasks = taskdefs.getChildren( "task" );
  @@ -213,7 +214,7 @@
               {
                   if( tasks[ i ].getAttribute( "name" ).equals( name ) )
                   {
  -                    handleTasklet( tasks[ i ], url );
  +                    handleTask( tasks[ i ], url );
                       break;
                   }
               }
  @@ -223,20 +224,20 @@
               throw new DeploymentException( "Malformed taskdefs.xml", ce );
           }
       }
  -    
  -    protected void handleConverter( final Configuration converter, final URL url )
  +
  +    private void handleConverter( final Configuration converter, final URL url )
           throws DeploymentException, ConfigurationException
       {
           final String name = converter.getAttribute( "classname" );
           final String source = converter.getAttribute( "source" );
           final String destination = converter.getAttribute( "destination" );
  -        
  +
           final DefaultConverterInfo info = new DefaultConverterInfo( source, destination
);
  -       
  +
           try { m_converterInfoRegistry.register( name, info ); }
           catch( final RegistryException re )
           {
  -            throw new DeploymentException( "Error registering converter info " + 
  +            throw new DeploymentException( "Error registering converter info " +
                                              name + " due to " + re,
                                              re );
           }
  @@ -246,48 +247,48 @@
           try { m_converterRegistry.register( name, locator ); }
           catch( final RegistryException re )
           {
  -            throw new DeploymentException( "Error registering converter locator " + 
  +            throw new DeploymentException( "Error registering converter locator " +
                                              name + " due to " + re,
                                              re );
           }
   
  -        getLogger().debug( "Registered converter " + name + " that converts from " + 
  +        getLogger().debug( "Registered converter " + name + " that converts from " +
                           source + " to " + destination );
       }
  -    
  -    protected void handleTasklet( final Configuration task, final URL url )
  +
  +    private void handleTask( final Configuration task, final URL url )
           throws DeploymentException, ConfigurationException
       {
           final String name = task.getAttribute( "name" );
           final String classname = task.getAttribute( "classname" );
   
           final DefaultLocator info = new DefaultLocator( classname, url );
  -        
  -        try { m_taskletRegistry.register( name, info ); }
  +
  +        try { m_taskRegistry.register( name, info ); }
           catch( final RegistryException re )
           {
               throw new DeploymentException( "Error registering " + name + " due to " + re,
                                              re );
           }
  -        
  -        getLogger().debug( "Registered tasklet " + name + " as " + classname );
  +
  +        getLogger().debug( "Registered task " + name + " as " + classname );
       }
  -  
  -    protected void handleDataType( final Configuration datatype, final URL url )
  +
  +    private void handleDataType( final Configuration datatype, final URL url )
           throws DeploymentException, ConfigurationException
       {
           final String name = datatype.getAttribute( "name" );
           final String classname = datatype.getAttribute( "classname" );
  -        
  +
           final DefaultLocator info = new DefaultLocator( classname, url );
  -        
  +
           try { m_dataTypeRegistry.register( name, info ); }
           catch( final RegistryException re )
           {
               throw new DeploymentException( "Error registering " + name + " due to " + re,
                                              re );
           }
  -        
  +
           getLogger().debug( "Registered datatype " + name + " as " + classname );
       }
   }
  
  
  
  1.7       +1 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TskDeployer.java
  
  Index: TskDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TskDeployer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TskDeployer.java	2001/05/28 06:28:13	1.6
  +++ TskDeployer.java	2001/05/29 06:00:49	1.7
  @@ -27,7 +27,7 @@
       void deployDataType( String name, String location, URL url )
           throws DeploymentException;    
   
  -    void deployTasklet( String name, String location, URL url )
  +    void deployTask( String name, String location, URL url )
           throws DeploymentException;
   }
   
  
  
  
  1.2       +9 -8      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/MyrmidonEmbeddor.java
  
  Index: MyrmidonEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/MyrmidonEmbeddor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MyrmidonEmbeddor.java	2001/05/28 12:28:07	1.1
  +++ MyrmidonEmbeddor.java	2001/05/29 06:00:49	1.2
  @@ -13,7 +13,6 @@
   import org.apache.ant.project.ProjectBuilder;
   import org.apache.ant.project.ProjectEngine;
   import org.apache.ant.tasklet.engine.DataTypeEngine;
  -import org.apache.ant.tasklet.engine.TaskletEngine;
   import org.apache.ant.tasklet.engine.TskDeployer;
   import org.apache.avalon.excalibur.io.FileUtil;
   import org.apache.avalon.framework.activity.Initializable;
  @@ -25,10 +24,11 @@
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.component.DefaultComponentManager;
   import org.apache.avalon.framework.logger.AbstractLoggable;
  -import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.parameters.Parameterizable;
  +import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.myrmidon.api.JavaVersion;
   import org.apache.myrmidon.components.configurer.Configurer;
  +import org.apache.myrmidon.components.executor.Executor;
   
   /**
    * Default implementation of Ant runtime.
  @@ -41,7 +41,7 @@
   {
       private ConverterEngine          m_converterEngine;
       private DataTypeEngine           m_dataTypeEngine;
  -    private TaskletEngine            m_taskEngine;
  +    private Executor                 m_executor;
       private ProjectEngine            m_projectEngine;
   
       private ProjectBuilder           m_builder;
  @@ -127,7 +127,7 @@
       {
           m_converterEngine = null;
           m_dataTypeEngine = null;
  -        m_taskEngine = null;
  +        m_executor = null;
           m_projectEngine = null;
           m_builder = null;
           m_deployer = null;
  @@ -163,7 +163,7 @@
           defaults.setParameter( "ant.comp.datatype",
                                 "org.apache.ant.tasklet.engine.DefaultDataTypeEngine" );
           defaults.setParameter( "ant.comp.task",
  -                              "org.apache.ant.tasklet.engine.DefaultTaskletEngine" );
  +                              "org.apache.myrmidon.components.executor.DefaultExecutor"
);
           defaults.setParameter( "ant.comp.project",
                                 "org.apache.ant.project.DefaultProjectEngine" );
           defaults.setParameter( "ant.comp.builder",
  @@ -185,7 +185,6 @@
       {
           final DefaultComponentManager componentManager = new DefaultComponentManager();
   
  -        componentManager.put( "org.apache.ant.tasklet.engine.TaskletEngine", m_taskEngine
);
           componentManager.put( "org.apache.ant.project.ProjectEngine", m_projectEngine );
           componentManager.put( "org.apache.ant.convert.engine.ConverterEngine",
                                 m_converterEngine );
  @@ -194,7 +193,9 @@
           componentManager.put( "org.apache.ant.project.ProjectBuilder", m_builder );
           componentManager.put( "org.apache.ant.tasklet.engine.TskDeployer", m_deployer );
           componentManager.put( "org.apache.avalon.framework.camelot.Factory", m_factory
);
  +
           componentManager.put( "org.apache.myrmidon.components.configurer.Configurer", m_configurer
);
  +        componentManager.put( "org.apache.myrmidon.components.executor.Executor", m_executor
);
   
           return componentManager;
       }
  @@ -216,7 +217,7 @@
           m_dataTypeEngine = (DataTypeEngine)createComponent( component, DataTypeEngine.class
);
   
           component = getParameter( "ant.comp.task" );
  -        m_taskEngine = (TaskletEngine)createComponent( component, TaskletEngine.class );
  +        m_executor = (Executor)createComponent( component, Executor.class );
   
           component = getParameter( "ant.comp.project" );
           m_projectEngine = (ProjectEngine)createComponent( component, ProjectEngine.class
);
  @@ -242,7 +243,7 @@
           setupComponent( m_factory );
           setupComponent( m_converterEngine );
           setupComponent( m_dataTypeEngine );
  -        setupComponent( m_taskEngine );
  +        setupComponent( m_executor );
           setupComponent( m_projectEngine );
           setupComponent( m_builder );
           setupComponent( m_deployer );
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java
  
  Index: DefaultExecutor.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.myrmidon.components.executor;
  
  import java.util.HashMap;
  import org.apache.ant.AntException;
  import org.apache.ant.convert.engine.ConverterEngine;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.camelot.DefaultFactory;
  import org.apache.avalon.framework.camelot.DefaultRegistry;
  import org.apache.avalon.framework.camelot.Factory;
  import org.apache.avalon.framework.camelot.FactoryException;
  import org.apache.avalon.framework.camelot.Locator;
  import org.apache.avalon.framework.camelot.Registry;
  import org.apache.avalon.framework.camelot.RegistryException;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.component.DefaultComponentManager;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLoggable;
  import org.apache.avalon.framework.logger.Loggable;
  import org.apache.log.Logger;
  import org.apache.myrmidon.api.Task;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.components.configurer.Configurer;
  
  public class DefaultExecutor
      extends AbstractLoggable
      implements Executor, Composable
  {
      protected Factory              m_factory;
      protected Registry             m_registry   = new DefaultRegistry( Locator.class );
      protected Configurer           m_configurer;
  
      protected ComponentManager     m_componentManager;
  
      public Registry getRegistry()
      {
          return m_registry;
      }
  
      /**
       * Retrieve relevent services needed to deploy.
       *
       * @param componentManager the ComponentManager
       * @exception ComponentException if an error occurs
       */
      public void compose( final ComponentManager componentManager )
          throws ComponentException
      {
          //cache CM so it can be used while executing tasks
          m_componentManager = componentManager;
  
          m_factory = (Factory)componentManager.lookup( "org.apache.avalon.framework.camelot.Factory"
);
  
          m_configurer = (Configurer)componentManager.
              lookup( "org.apache.myrmidon.components.configurer.Configurer" );
      }
  
      public void execute( final Configuration taskData, final TaskContext context )
          throws AntException
      {
          getLogger().debug( "Creating" );
          final Task task = createTask( taskData.getName() );
          setupLogger( task );
  
          getLogger().debug( "Contextualizing" );
          doContextualize( task, taskData, context );
  
          getLogger().debug( "Composing" );
          doCompose( task, taskData );
  
          getLogger().debug( "Configuring" );
          doConfigure( task, taskData, context );
  
          getLogger().debug( "Initializing" );
          doInitialize( task, taskData );
  
          getLogger().debug( "Running" );
  
          try { task.execute(); }
          catch( final Exception e )
          {
              throw new AntException( "Error executing task", e );
          }
  
          getLogger().debug( "Disposing" );
          doDispose( task, taskData );
      }
  
      protected Task createTask( final String name )
          throws AntException
      {
          try
          {
              final Locator locator = (Locator)m_registry.getInfo( name, Locator.class );
              return (Task)m_factory.create( locator, Task.class );
          }
          catch( final RegistryException re )
          {
              throw new AntException( "Unable to locate task " + name, re );
          }
          catch( final FactoryException fe )
          {
              throw new AntException( "Unable to create task " + name, fe );
          }
      }
  
      protected void doConfigure( final Task task,
                                  final Configuration taskData,
                                  final TaskContext context )
          throws AntException
      {
          try { m_configurer.configure( task, taskData, context ); }
          catch( final Throwable throwable )
          {
              throw new AntException( "Error configuring task " +  taskData.getName() + "
at " +
                                      taskData.getLocation() + "(Reason: " +
                                      throwable.getMessage() + ")", throwable );
          }
      }
  
      protected void doCompose( final Task task, final Configuration taskData )
          throws AntException
      {
          if( task instanceof Composable )
          {
              try { ((Composable)task).compose( m_componentManager ); }
              catch( final Throwable throwable )
              {
                  throw new AntException( "Error composing task " +  taskData.getName() +
" at " +
                                          taskData.getLocation() + "(Reason: " +
                                          throwable.getMessage() + ")", throwable );
              }
          }
      }
  
      protected void doContextualize( final Task task,
                                      final Configuration taskData,
                                      final TaskContext context )
          throws AntException
      {
          try
          {
              if( task instanceof Contextualizable )
              {
                  ((Contextualizable)task).contextualize( context );
              }
          }
          catch( final Throwable throwable )
          {
              throw new AntException( "Error contextualizing task " +  taskData.getName()
+ " at " +
                                      taskData.getLocation() + "(Reason: " +
                                      throwable.getMessage() + ")", throwable );
          }
      }
  
      protected void doDispose( final Task task, final Configuration taskData )
          throws AntException
      {
          if( task instanceof Disposable )
          {
              try { ((Disposable)task).dispose(); }
              catch( final Throwable throwable )
              {
                  throw new AntException( "Error disposing task " +  taskData.getName() +
" at " +
                                          taskData.getLocation() + "(Reason: " +
                                          throwable.getMessage() + ")", throwable );
              }
          }
      }
  
      protected void doInitialize( final Task task, final Configuration taskData )
          throws AntException
      {
          if( task instanceof Initializable )
          {
              try { ((Initializable)task).initialize(); }
              catch( final Throwable throwable )
              {
                  throw new AntException( "Error initializing task " +  taskData.getName()
+ " at " +
                                          taskData.getLocation() + "(Reason: " +
                                          throwable.getMessage() + ")", throwable );
              }
          }
      }
  }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/Executor.java
  
  Index: Executor.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.myrmidon.components.executor;
  
  import org.apache.ant.AntException;
  import org.apache.avalon.framework.camelot.Registry;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.myrmidon.api.TaskContext;
   
  /**
   * Engine inteface that should be implemented by all tasklet engines.
   * 
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public interface Executor
      extends Component
  {
      /**
       * Retrieve locator registry associated with engine.
       * TODO: Remove this as it violates IOC
       *
       * @return the LocatorRegistry
       */
      Registry getRegistry();
  
      /**
       * execute a task.
       *
       * @param task the configruation data for task
       * @exception AntException if an error occurs
       */
      void execute( Configuration task, TaskContext context )
          throws AntException;
  }
  
  
  

Mime
View raw message