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/type DefaultTypeManager.java TypeManager.java
Date Sat, 02 Jun 2001 06:58:13 GMT
donaldp     01/06/01 23:58:13

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/api Task.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer
                        DefaultTskDeployer.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor
                        MyrmidonEmbeddor.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/type
                        DefaultTypeManager.java TypeManager.java
  Log:
  Integrate TypeManager into embeddor and in deployment mechanism.
  
  Revision  Changes    Path
  1.3       +2 -0      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/Task.java
  
  Index: Task.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/Task.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Task.java	2001/05/29 12:06:16	1.2
  +++ Task.java	2001/06/02 06:58:12	1.3
  @@ -25,6 +25,8 @@
    */
   public interface Task
   {
  +    String ROLE = "org.apache.myrmidon.api.Task";
  +
       /**
        * Execute task. 
        * This method is called to perform actual work associated with task.
  
  
  
  1.4       +45 -13    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultTskDeployer.java
  
  Index: DefaultTskDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultTskDeployer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultTskDeployer.java	2001/05/31 17:20:02	1.3
  +++ DefaultTskDeployer.java	2001/06/02 06:58:12	1.4
  @@ -35,7 +35,11 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.Loggable;
   import org.apache.log.Logger;
  +import org.apache.myrmidon.api.Task;
   import org.apache.myrmidon.components.executor.Executor;
  +import org.apache.myrmidon.components.type.TypeManager;
  +import org.apache.myrmidon.components.type.ComponentFactory;
  +import org.apache.myrmidon.components.type.DefaultComponentFactory;
   
   /**
    * This class deploys a .tsk file into a registry.
  @@ -52,13 +56,13 @@
       private Registry              m_taskRegistry;
       private Registry              m_converterRegistry;
       private ConverterRegistry     m_converterInfoRegistry;
  +    private TypeManager           m_typeManager;
   
       /**
        * Default constructor.
        */
       public DefaultTskDeployer()
       {
  -        super();
           m_autoUndeploy = true;
           m_type = "Task";
       }
  @@ -86,6 +90,8 @@
               lookup( "org.apache.ant.tasklet.engine.DataTypeEngine" );
   
           m_dataTypeRegistry = dataTypeEngine.getRegistry();
  +
  +        m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE );
       }
   
       /**
  @@ -124,12 +130,15 @@
       {
           final Configuration taskdefs = DeployerUtil.loadConfiguration( zipFile, TSKDEF_FILE
);
   
  +        final DefaultComponentFactory factory = 
  +            new DefaultComponentFactory( new URL[] { url } );
  +
           try
           {
               final Configuration[] tasks = taskdefs.getChildren( "task" );
               for( int i = 0; i < tasks.length; i++ )
               {
  -                handleTask( tasks[ i ], url );
  +                handleTask( tasks[ i ], url, factory );
               }
   
               final Configuration[] converters = taskdefs.getChildren( "converter" );
  @@ -141,7 +150,7 @@
               final Configuration[] datatypes = taskdefs.getChildren( "datatype" );
               for( int i = 0; i < datatypes.length; i++ )
               {
  -                handleDataType( datatypes[ i ], url );
  +                handleDataType( datatypes[ i ], url, factory );
               }
           }
           catch( final ConfigurationException ce )
  @@ -190,7 +199,9 @@
               {
                   if( datatypes[ i ].getAttribute( "name" ).equals( name ) )
                   {
  -                    handleDataType( datatypes[ i ], url );
  +                    final DefaultComponentFactory factory = 
  +                        new DefaultComponentFactory( new URL[] { url } );
  +                    handleDataType( datatypes[ i ], url, factory );
                       break;
                   }
               }
  @@ -215,7 +226,9 @@
               {
                   if( tasks[ i ].getAttribute( "name" ).equals( name ) )
                   {
  -                    handleTask( tasks[ i ], url );
  +                    final DefaultComponentFactory factory = 
  +                        new DefaultComponentFactory( new URL[] { url } );
  +                    handleTask( tasks[ i ], url, factory );
                       break;
                   }
               }
  @@ -257,13 +270,15 @@
                              source + " to " + destination );
       }
   
  -    private void handleTask( final Configuration task, final URL url )
  +    private void handleTask( final Configuration task, 
  +                             final URL url, 
  +                             final DefaultComponentFactory factory )
           throws DeploymentException, ConfigurationException
       {
           final String name = task.getAttribute( "name" );
  -        final String classname = task.getAttribute( "classname" );
  +        final String className = task.getAttribute( "classname" );
   
  -        final DefaultLocator info = new DefaultLocator( classname, url );
  +        final DefaultLocator info = new DefaultLocator( className, url );
   
           try { m_taskRegistry.register( name, info ); }
           catch( final RegistryException re )
  @@ -272,16 +287,26 @@
                                              re );
           }
   
  -        getLogger().debug( "Registered task " + name + " as " + classname );
  +        factory.addNameClassMapping( name, className );
  +        
  +        try { m_typeManager.registerType( Task.ROLE, name, factory ); }
  +        catch( final Exception e )
  +        {
  +            throw new DeploymentException( "Error registering " + name + " due to " + e,
e );
  +        }
  +        
  +        getLogger().debug( "Registered task " + name + " as " + className );
       }
   
  -    private void handleDataType( final Configuration datatype, final URL url )
  +    private void handleDataType( final Configuration datatype, 
  +                                 final URL url, 
  +                                 final DefaultComponentFactory factory )
           throws DeploymentException, ConfigurationException
       {
           final String name = datatype.getAttribute( "name" );
  -        final String classname = datatype.getAttribute( "classname" );
  +        final String className = datatype.getAttribute( "classname" );
   
  -        final DefaultLocator info = new DefaultLocator( classname, url );
  +        final DefaultLocator info = new DefaultLocator( className, url );
   
           try { m_dataTypeRegistry.register( name, info ); }
           catch( final RegistryException re )
  @@ -289,7 +314,14 @@
               throw new DeploymentException( "Error registering " + name + " due to " + re,
                                              re );
           }
  +
  +        factory.addNameClassMapping( name, className );
  +        try { m_typeManager.registerType( Task.ROLE, name, factory ); }
  +        catch( final Exception e )
  +        {
  +            throw new DeploymentException( "Error registering " + name + " due to " + e,
e );
  +        }
   
  -        getLogger().debug( "Registered datatype " + name + " as " + classname );
  +        getLogger().debug( "Registered datatype " + name + " as " + className );
       }
   }
  
  
  
  1.12      +17 -4     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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MyrmidonEmbeddor.java	2001/06/02 05:48:24	1.11
  +++ MyrmidonEmbeddor.java	2001/06/02 06:58:12	1.12
  @@ -26,6 +26,7 @@
   import org.apache.myrmidon.components.builder.ProjectBuilder;
   import org.apache.myrmidon.components.configurer.Configurer;
   import org.apache.myrmidon.components.executor.Executor;
  +import org.apache.myrmidon.components.type.TypeManager;
   import org.apache.myrmidon.components.manager.ProjectManager;
   import org.apache.myrmidon.components.deployer.TskDeployer;
   
  @@ -39,14 +40,17 @@
       extends AbstractLoggable
       implements Embeddor
   {
  -    private ConverterEngine          m_converterEngine;
  -    private DataTypeEngine           m_dataTypeEngine;
  -    private Executor                 m_executor;
       private ProjectManager           m_projectManager;
  -
       private ProjectBuilder           m_builder;
       private TskDeployer              m_deployer;
  +
  +    private DataTypeEngine           m_dataTypeEngine;
  +    private TypeManager              m_typeManager;
  +    private ConverterEngine          m_converterEngine;
  +
  +    private Executor                 m_executor;
       private Configurer               m_configurer;
  +    
   
       private Factory                  m_factory;
   
  @@ -170,6 +174,9 @@
                                  "org.apache.ant.convert.engine.DefaultConverterEngine" );
           defaults.setParameter( "org.apache.ant.tasklet.engine.DataTypeEngine",
                                  "org.apache.ant.tasklet.engine.DefaultDataTypeEngine" );
  +
  +        defaults.setParameter( TypeManager.ROLE,
  +                               "org.apache.myrmidon.components.type.DefaultTypeManager"
);
           defaults.setParameter( Executor.ROLE,
                                  "org.apache.myrmidon.components.executor.DefaultExecutor"
);
           defaults.setParameter( ProjectManager.ROLE,
  @@ -206,6 +213,9 @@
           //Following components required when Myrmidon allows user deployment of tasks etal.
           componentManager.put( TskDeployer.ROLE, m_deployer );
   
  +        //Following components used when want to types (ie tasks/mappers etc)
  +        componentManager.put( TypeManager.ROLE, m_typeManager );
  +
           //Following components required when allowing Container tasks
           componentManager.put( Configurer.ROLE, m_configurer );
           componentManager.put( Executor.ROLE, m_executor );
  @@ -228,6 +238,9 @@
   
           component = getParameter( "org.apache.ant.tasklet.engine.DataTypeEngine" );
           m_dataTypeEngine = (DataTypeEngine)createComponent( component, DataTypeEngine.class
);
  +
  +        component = getParameter( TypeManager.ROLE );
  +        m_typeManager = (TypeManager)createComponent( component, TypeManager.class );
   
           component = getParameter( Executor.ROLE );
           m_executor = (Executor)createComponent( component, Executor.class );
  
  
  
  1.2       +5 -0      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/DefaultTypeManager.java
  
  Index: DefaultTypeManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/DefaultTypeManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultTypeManager.java	2001/06/02 05:47:28	1.1
  +++ DefaultTypeManager.java	2001/06/02 06:58:12	1.2
  @@ -26,6 +26,11 @@
       ///Maps role to TypedComponentSelector.
       private final HashMap      m_roleMap      = new HashMap();
   
  +    public DefaultTypeManager()
  +    {
  +        this( null );
  +    }
  +
       public DefaultTypeManager( final TypeManager parent )
       {
           m_parent = parent;
  
  
  
  1.2       +2 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/TypeManager.java
  
  Index: TypeManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/type/TypeManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypeManager.java	2001/06/02 05:47:28	1.1
  +++ TypeManager.java	2001/06/02 06:58:12	1.2
  @@ -7,6 +7,7 @@
    */
   package org.apache.myrmidon.components.type;
   
  +import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentManager;
   
   /**
  @@ -15,7 +16,7 @@
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
    */
   public interface TypeManager
  -    extends ComponentManager
  +    extends Component, ComponentManager
   {
       String ROLE = "org.apache.myrmidon.components.type.TypeManager";
   
  
  
  

Mime
View raw message