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/ant/tasklet/engine DefaultTaskletEngine.java DefaultTskDeployer.java TaskletEngine.java
Date Wed, 07 Feb 2001 06:49:45 GMT
donaldp     01/02/06 22:49:45

  Modified:    proposal/myrmidon/src/java/org/apache/ant
                        DefaultAntEngine.java
               proposal/myrmidon/src/java/org/apache/ant/modules/core
                        RegisterConverter.java
               proposal/myrmidon/src/java/org/apache/ant/tasklet/engine
                        DefaultTaskletEngine.java DefaultTskDeployer.java
                        TaskletEngine.java
  Added:       proposal/myrmidon/src/java/org/apache/ant/convert/engine
                        ConverterEngine.java ConverterInfo.java
                        ConverterRegistry.java DefaultConverterEngine.java
                        DefaultConverterInfo.java
                        DefaultConverterRegistry.java
  Removed:     proposal/myrmidon/src/java/org/apache/ant/convert
                        ConverterEngine.java ConverterInfo.java
                        ConverterRegistry.java DefaultConverterEngine.java
                        DefaultConverterInfo.java
                        DefaultConverterRegistry.java
  Log:
  Rearranged convert package with separation of client-engine code
  
  Revision  Changes    Path
  1.3       +4 -3      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/DefaultAntEngine.java
  
  Index: DefaultAntEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/DefaultAntEngine.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultAntEngine.java	2001/02/07 05:39:25	1.2
  +++ DefaultAntEngine.java	2001/02/07 06:49:30	1.3
  @@ -10,7 +10,7 @@
   import java.io.File;
   import java.util.Properties;
   import org.apache.ant.configuration.Configurer;
  -import org.apache.ant.convert.ConverterEngine;
  +import org.apache.ant.convert.engine.ConverterEngine;
   import org.apache.ant.tasklet.engine.DataTypeEngine;
   import org.apache.ant.project.ProjectBuilder;
   import org.apache.ant.project.ProjectEngine;
  @@ -158,7 +158,7 @@
   
           //create all the default properties for components
           defaults.setProperty( "ant.comp.converter",
  -                              "org.apache.ant.convert.DefaultConverterEngine" );
  +                              "org.apache.ant.convert.engine.DefaultConverterEngine" );
           defaults.setProperty( "ant.comp.datatype",
                                 "org.apache.ant.tasklet.engine.DefaultDataTypeEngine" );
           defaults.setProperty( "ant.comp.tasklet",
  @@ -186,7 +186,8 @@
   
           componentManager.put( "org.apache.ant.tasklet.engine.TaskletEngine", m_taskletEngine
);
           componentManager.put( "org.apache.ant.project.ProjectEngine", m_projectEngine );
  -        componentManager.put( "org.apache.ant.convert.ConverterEngine", m_converterEngine
);
  +        componentManager.put( "org.apache.ant.convert.engine.ConverterEngine", 
  +                              m_converterEngine );
           componentManager.put( "org.apache.ant.convert.Converter", m_converterEngine );
           componentManager.put( "org.apache.ant.tasklet.engine.DataTypeEngine", m_dataTypeEngine
);
           componentManager.put( "org.apache.ant.project.ProjectBuilder", m_builder );
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/convert/engine/ConverterEngine.java
  
  Index: ConverterEngine.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.ant.convert.engine;
  
  import org.apache.ant.convert.Converter;
  import org.apache.avalon.Component;
  import org.apache.avalon.camelot.LocatorRegistry;
  
  /**
   * Converter engine to handle converting between types.
   * 
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public interface ConverterEngine
      extends Component, Converter
  {
      /**
       * Get registry used to locate converters.
       *
       * @return the LocatorRegistry
       */
      LocatorRegistry getRegistry();
  
      /**
       * Get registry for converterInfo objects.
       *
       * @return the ConverterRegistry
       */
      ConverterRegistry getInfoRegistry();
  }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/convert/engine/ConverterInfo.java
  
  Index: ConverterInfo.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.ant.convert.engine;
  
  import org.apache.avalon.camelot.Info;
  
  /**
   * This info represents meta-information about a converter.
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public interface ConverterInfo
      extends Info
  {
      /**
       * Retrieve the source type from which it can convert.
       * NB: Should this be an array ????
       *
       * @return the classname from which object produced
       */
      String getSource();
  
      /**
       * Retrieve the type to which the converter converts.
       * NB: Should this be an array ????
       *
       * @return the classname of the produced object
       */
      String getDestination();
  }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/convert/engine/ConverterRegistry.java
  
  Index: ConverterRegistry.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.ant.convert.engine;
  
  import org.apache.avalon.camelot.Registry;
  
  /**
   * Interface for registry for ConverterInfos.
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public interface ConverterRegistry
      extends Registry
  {
      /**
       * Retrieve name of ConverterInfo that describes converter that converts 
       * from source to destination.
       *
       * @param source the source classname
       * @param destination the destination classname
       * @return the converter-info or null if none available
       */
      String getConverterInfoName( String source, String destination );
  }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/convert/engine/DefaultConverterEngine.java
  
  Index: DefaultConverterEngine.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.ant.convert.engine;
  
  import org.apache.ant.AntException;
  import org.apache.ant.convert.Converter;
  import org.apache.ant.convert.ConverterException;
  import org.apache.avalon.AbstractLoggable;
  import org.apache.avalon.ComponentManager;
  import org.apache.avalon.ComponentManagerException;
  import org.apache.avalon.Composer;
  import org.apache.avalon.Context;
  import org.apache.avalon.camelot.DefaultFactory;
  import org.apache.avalon.camelot.DefaultLocatorRegistry;
  import org.apache.avalon.camelot.Factory;
  import org.apache.avalon.camelot.Locator;
  import org.apache.avalon.camelot.LocatorRegistry;
  
  /**
   * Converter engine to handle converting between types.
   * 
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class DefaultConverterEngine
      extends AbstractLoggable
      implements ConverterEngine, Composer
  {
      protected final static boolean DEBUG                = false;
  
      protected Factory              m_factory;
      protected LocatorRegistry      m_registry      = new DefaultLocatorRegistry();
      protected ConverterRegistry    m_infoRegistry  = new DefaultConverterRegistry();
  
      /**
       * Get registry used to locate converters.
       *
       * @return the LocatorRegistry
       */
      public LocatorRegistry getRegistry()
      {
          return m_registry;
      }
      
      /**
       * Get registry for converterInfo objects.
       *
       * @return the ConverterRegistry
       */
      public ConverterRegistry getInfoRegistry()
      {
          return m_infoRegistry;
      }
      
      /**
       * Retrieve relevent services needed to deploy.
       *
       * @param componentManager the ComponentManager
       * @exception ComponentManagerException if an error occurs
       */
      public void compose( final ComponentManager componentManager )
          throws ComponentManagerException
      {
          m_factory = (Factory)componentManager.lookup( "org.apache.avalon.camelot.Factory"
);
      }
  
      /**
       * Convert object to destination type.
       *
       * @param destination the destination type
       * @param original the original object
       * @param context the context in which to convert
       * @return the converted object
       * @exception Exception if an error occurs
       */
      public Object convert( Class destination, final Object original, final Context context
)
          throws Exception
      {
          final Class originalClass = original.getClass();
  
          if( destination.isAssignableFrom( originalClass ) )
          {
              return original;
          }
  
          if( DEBUG )
          {
              m_logger.debug( "Looking for converter from " + originalClass.getName() +
                              " to " + destination.getName() );
          }
  
          //TODO: Start searching inheritance hierarchy for converter
          final String name = 
              m_infoRegistry.getConverterInfoName( originalClass.getName(), 
                                                   destination.getName() );
              
          if( null == name ) 
          {
              throw new ConverterException( "Unable to find converter for " + 
                                            originalClass.getName() + " to " + 
                                            destination.getName() + " conversion" );
          }
  
          //TODO: Start caching converters instead of repeatedly instantiating em.
          final Locator locator = m_registry.getLocator( name );
          final Converter converter = (Converter)m_factory.create( locator, Converter.class
);
          return converter.convert( destination, original, context );
      }
  }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/convert/engine/DefaultConverterInfo.java
  
  Index: DefaultConverterInfo.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.ant.convert.engine;
  
  /**
   * This info represents meta-information about a converter.
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class DefaultConverterInfo
      implements ConverterInfo
  {
      protected final String            m_source;
      protected final String            m_destination;
  
      public DefaultConverterInfo( final String source, final String destination )
      {
          m_source = source;
          m_destination = destination;
      } 
  
      /**
       * Retrieve the source type from which it can convert.
       * NB: Should this be an array ????
       *
       * @return the classname from which object produced
       */
      public String getSource()
      {
          return m_source;
      }
      
      /**
       * Retrieve the type to which the converter converts.
       * NB: Should this be an array ????
       *
       * @return the classname of the produced object
       */
      public String getDestination()
      {
          return m_destination;
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/convert/engine/DefaultConverterRegistry.java
  
  Index: DefaultConverterRegistry.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.ant.convert.engine;
  
  import java.util.HashMap;
  import org.apache.avalon.camelot.DefaultRegistry;
  import org.apache.avalon.camelot.Info;
  import org.apache.avalon.camelot.RegistryException;
  
  /**
   * Default implementation of ConverterInfo registry.
   * 
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class DefaultConverterRegistry
      extends DefaultRegistry
      implements ConverterRegistry
  {
      protected final HashMap         m_mapping        = new HashMap();
  
      public DefaultConverterRegistry()
      {
          super( ConverterInfo.class );
      }
  
      /**
       * Retrieve ConverterInfo that describes converter that converts from source to destination.
       *
       * @param source the source classname
       * @param destination the destination classname
       * @return the converter-info or null if none available
       */
      public String getConverterInfoName( final String source, final String destination )
      {
          final HashMap map = (HashMap)m_mapping.get( source );
          if( null == map ) return null;
          return (String)map.get( destination );
      }
  
      /**
       * Overidden method so can add info into mapping.
       *
       * @param name the name of info
       * @param info the Info
       * @exception RegistryException if an error occurs
       */
      protected void checkInfo( final String name, final Info info )
          throws RegistryException
      {
          super.checkInfo( name, info );
  
          final ConverterInfo converterInfo = (ConverterInfo)info;
          final String source = converterInfo.getSource();
          final String destination = converterInfo.getDestination();
  
          HashMap map = (HashMap)m_mapping.get( source );
          if( null == map )
          {
              map = new HashMap();
              m_mapping.put( source, map );
          }
          
          map.put( destination, name );        
      }
  }
  
  
  
  1.2       +2 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterConverter.java
  
  Index: RegisterConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RegisterConverter.java	2001/02/07 05:36:21	1.1
  +++ RegisterConverter.java	2001/02/07 06:49:41	1.2
  @@ -11,8 +11,8 @@
   import java.net.MalformedURLException;
   import java.net.URL;
   import org.apache.ant.AntException;
  -import org.apache.ant.convert.ConverterEngine;
  -import org.apache.ant.convert.DefaultConverterInfo;
  +import org.apache.ant.convert.engine.ConverterEngine;
  +import org.apache.ant.convert.engine.DefaultConverterInfo;
   import org.apache.ant.tasklet.AbstractTasklet;
   import org.apache.ant.tasklet.engine.TaskletEngine;
   import org.apache.avalon.ComponentManager;
  
  
  
  1.10      +3 -4      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletEngine.java
  
  Index: DefaultTaskletEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletEngine.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultTaskletEngine.java	2001/02/07 05:38:29	1.9
  +++ DefaultTaskletEngine.java	2001/02/07 06:49:42	1.10
  @@ -13,7 +13,7 @@
   import org.apache.ant.configuration.Configuration;
   import org.apache.ant.configuration.Configurer;
   import org.apache.ant.configuration.DefaultConfigurer;
  -import org.apache.ant.convert.ConverterEngine;
  +import org.apache.ant.convert.engine.ConverterEngine;
   import org.apache.ant.tasklet.Tasklet;
   import org.apache.ant.tasklet.TaskletContext;
   import org.apache.avalon.AbstractLoggable;
  @@ -95,11 +95,10 @@
           m_dataTypeEngine = (DataTypeEngine)componentManager.
               lookup( "org.apache.ant.tasklet.engine.DataTypeEngine" );
           m_converterEngine = (ConverterEngine)componentManager.
  -            lookup( "org.apache.ant.convert.ConverterEngine" );
  +            lookup( "org.apache.ant.convert.engine.ConverterEngine" );
       }
   
  -    public void execute( final Configuration task, 
  -                         final TaskletContext context )
  +    public void execute( final Configuration task, final TaskletContext context )
           throws AntException
       {
           getLogger().debug( "Creating" );
  
  
  
  1.7       +4 -4      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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultTskDeployer.java	2001/02/07 05:38:30	1.6
  +++ DefaultTskDeployer.java	2001/02/07 06:49:43	1.7
  @@ -15,9 +15,9 @@
   import java.util.zip.ZipEntry;
   import java.util.zip.ZipException;
   import java.util.zip.ZipFile;
  -import org.apache.ant.convert.ConverterEngine;
  -import org.apache.ant.convert.ConverterRegistry;
  -import org.apache.ant.convert.DefaultConverterInfo;
  +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.Component;
   import org.apache.avalon.ComponentManager;
   import org.apache.avalon.ComponentManagerException;
  @@ -75,7 +75,7 @@
           m_taskletRegistry = taskletEngine.getRegistry();
   
           final ConverterEngine converterEngine = (ConverterEngine)componentManager.
  -            lookup( "org.apache.ant.convert.ConverterEngine" );
  +            lookup( "org.apache.ant.convert.engine.ConverterEngine" );
   
           m_converterInfoRegistry = converterEngine.getInfoRegistry();
           m_converterRegistry = converterEngine.getRegistry();
  
  
  
  1.9       +1 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletEngine.java
  
  Index: TaskletEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/TaskletEngine.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TaskletEngine.java	2001/02/07 05:38:30	1.8
  +++ TaskletEngine.java	2001/02/07 06:49:43	1.9
  @@ -9,7 +9,7 @@
   
   import org.apache.ant.AntException;
   import org.apache.ant.configuration.Configuration;
  -import org.apache.ant.convert.ConverterEngine;
  +import org.apache.ant.convert.engine.ConverterEngine;
   import org.apache.ant.tasklet.engine.DataTypeEngine;
   import org.apache.ant.tasklet.TaskletContext;
   import org.apache.avalon.Component;
  
  
  

Mime
View raw message