ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test DefaultDeployerTestCase.java
Date Mon, 27 May 2002 02:17:46 GMT
adammurdoch    02/05/26 19:17:46

  Modified:    container/src/java/org/apache/myrmidon/components/converter
                        DefaultMasterConverter.java
               container/src/java/org/apache/myrmidon/components/deployer
                        ConverterTypeDeployer.java
               container/src/java/org/apache/myrmidon/interfaces/converter
                        ConverterRegistry.java
               container/src/test/org/apache/myrmidon/components
                        AbstractComponentTest.java
               container/src/test/org/apache/myrmidon/components/deployer/test
                        DefaultDeployerTestCase.java
  Added:       container/src/java/org/apache/myrmidon/components/deployer
                        TypeToConverterFactoryAdaptor.java
  Log:
  Changed ConverterRegistry.registerConverter() to use a ConverterFactory, rather
  than a converter name.  This means that the TypeManager is no longer used by
  the DefaultMasterConverter, which fixes the <converter-def> task.
  
  Revision  Changes    Path
  1.30      +9 -42     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/converter/DefaultMasterConverter.java
  
  Index: DefaultMasterConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/converter/DefaultMasterConverter.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- DefaultMasterConverter.java	23 May 2002 01:50:25 -0000	1.29
  +++ DefaultMasterConverter.java	27 May 2002 02:17:45 -0000	1.30
  @@ -7,64 +7,31 @@
    */
   package org.apache.myrmidon.components.converter;
   
  -import org.apache.aut.converter.Converter;
   import org.apache.aut.converter.AbstractMasterConverter;
  -import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.framework.service.ServiceManager;
  -import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.aut.converter.ConverterFactory;
   import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
  -import org.apache.myrmidon.interfaces.type.TypeFactory;
  -import org.apache.myrmidon.interfaces.type.TypeManager;
   
   /**
    * Converter engine to handle converting between types.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.29 $ $Date: 2002/05/23 01:50:25 $
  + * @version $Revision: 1.30 $ $Date: 2002/05/27 02:17:45 $
    */
   public class DefaultMasterConverter
       extends AbstractMasterConverter
  -    implements ConverterRegistry, Serviceable
  +    implements ConverterRegistry
   {
  -    private TypeManager m_typeManager;
  -
  -    /**
  -     * Retrieve relevent services needed to deploy.
  -     *
  -     * @param serviceManager the ServiceManager
  -     * @throws ServiceException if an error occurs
  -     */
  -    public void service( final ServiceManager serviceManager )
  -        throws ServiceException
  -    {
  -        m_typeManager = (TypeManager)serviceManager.lookup( TypeManager.ROLE );
  -    }
  -
       /**
  -     * Register a converter
  +     * Registers a converter.
        *
  -     * @param className the className of converter
        * @param source the source classname
        * @param destination the destination classname
  +     * @param factory the factory to use to create a converter instance.
        */
  -    public void registerConverter( final String className,
  -                                   final String source,
  -                                   final String destination )
  -    {
  -        super.registerConverter( className, source, destination );
  -    }
  -
  -    /**
  -     * Create an instance of converter with specified name.
  -     *
  -     * @param name the name of converter
  -     * @return the created converter instance
  -     * @throws Exception if converter can not be created.
  -     */
  -    protected Converter createConverter( final String name )
  -        throws Exception
  +    public void registerConverter( final String source,
  +                                   final String destination,
  +                                   final ConverterFactory factory )
       {
  -        final TypeFactory factory = m_typeManager.getFactory( Converter.ROLE );
  -        return (Converter)factory.create( name );
  +        super.registerConverter( factory, source, destination );
       }
   }
  
  
  
  1.7       +8 -7      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/ConverterTypeDeployer.java
  
  Index: ConverterTypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/ConverterTypeDeployer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ConverterTypeDeployer.java	22 May 2002 07:36:22 -0000	1.6
  +++ ConverterTypeDeployer.java	27 May 2002 02:17:45 -0000	1.7
  @@ -17,13 +17,14 @@
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
  +import org.apache.aut.converter.ConverterFactory;
   
   /**
    * A type deployer that deploys converters, registering them with the type
    * manager and the converter registry.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.6 $ $Date: 2002/05/22 07:36:22 $
  + * @version $Revision: 1.7 $ $Date: 2002/05/27 02:17:45 $
    */
   class ConverterTypeDeployer
       extends DefaultTypeDeployer
  @@ -48,8 +49,7 @@
                               final TypeDefinition typeDefinition )
           throws Exception
       {
  -        // Add the converter to the converter registry
  -        final String name = typeDefinition.getName();
  +        // Do some validation
           final String source = (String)typeDefinition.getAttributes().get( TypeDefinition.ATTRIBUTE_SOURCE_CLASS
);
           final String destination = (String)typeDefinition.getAttributes().get( TypeDefinition.ATTRIBUTE_DESTINATION_CLASS
);
           if( null == source )
  @@ -63,9 +63,10 @@
               throw new Exception( message );
           }
   
  -        m_converterRegistry.registerConverter( name, source, destination );
  -
  -        // Register the converter as a type
  -        super.deployType( namespace, typeDefinition );
  +        // Add the converter to the converter registry
  +        final String name = typeDefinition.getName();
  +        final TypeFactory factory = typeDefinition.getFactory();
  +        final ConverterFactory converterFactory = new TypeToConverterFactoryAdaptor( name,
factory );
  +        m_converterRegistry.registerConverter( source, destination, converterFactory );
       }
   }
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/TypeToConverterFactoryAdaptor.java
  
  Index: TypeToConverterFactoryAdaptor.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.txt file.
   */
  package org.apache.myrmidon.components.deployer;
  
  import org.apache.aut.converter.ConverterFactory;
  import org.apache.aut.converter.Converter;
  import org.apache.myrmidon.interfaces.type.TypeFactory;
  
  /**
   * Adapts a TypeFactory into a ConverterFactory
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/27 02:17:45 $
   */
  public class TypeToConverterFactoryAdaptor
      implements ConverterFactory
  {
      private String m_converterName;
      private TypeFactory m_typeFactory;
  
      public TypeToConverterFactoryAdaptor( final String converterName,
                                            final TypeFactory typeFactory )
      {
          m_converterName = converterName;
          m_typeFactory = typeFactory;
      }
  
      /**
       * Creates an instance of a converter.
       */
      public Converter createConverter() throws Exception
      {
          return (Converter)m_typeFactory.create( m_converterName );
      }
  }
  
  
  
  1.9       +8 -4      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/converter/ConverterRegistry.java
  
  Index: ConverterRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/converter/ConverterRegistry.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ConverterRegistry.java	1 Apr 2002 09:56:27 -0000	1.8
  +++ ConverterRegistry.java	27 May 2002 02:17:45 -0000	1.9
  @@ -7,11 +7,13 @@
    */
   package org.apache.myrmidon.interfaces.converter;
   
  +import org.apache.aut.converter.ConverterFactory;
  +
   /**
    * Interface for registry for ConverterInfos.
    *
    * @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/05/27 02:17:45 $
    */
   public interface ConverterRegistry
   {
  @@ -19,11 +21,13 @@
       String ROLE = ConverterRegistry.class.getName();
   
       /**
  -     * Register a converter
  +     * Registers a converter.
        *
  -     * @param className the className of converter
        * @param source the source classname
        * @param destination the destination classname
  +     * @param factory the factory to use to create a converter instance.
        */
  -    void registerConverter( String className, String source, String destination );
  +    void registerConverter( String source,
  +                            String destination,
  +                            ConverterFactory factory );
   }
  
  
  
  1.41      +7 -5      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java
  
  Index: AbstractComponentTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- AbstractComponentTest.java	23 May 2002 09:24:05 -0000	1.40
  +++ AbstractComponentTest.java	27 May 2002 02:17:45 -0000	1.41
  @@ -14,6 +14,8 @@
   import java.util.List;
   import java.util.Map;
   import org.apache.aut.converter.Converter;
  +import org.apache.aut.converter.ConverterFactory;
  +import org.apache.aut.converter.lib.SimpleConverterFactory;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
  @@ -59,7 +61,7 @@
    * A base class for tests for the default components.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.40 $ $Date: 2002/05/23 09:24:05 $
  + * @version $Revision: 1.41 $ $Date: 2002/05/27 02:17:45 $
    */
   public abstract class AbstractComponentTest
       extends AbstractContainerTestCase
  @@ -280,9 +282,9 @@
           throws Exception
       {
           final ConverterRegistry converterRegistry = (ConverterRegistry)getServiceManager().lookup(
ConverterRegistry.ROLE );
  -        final String converterName = converterClass.getName().replace( TypeManager.NAMESPACE_SEPARATOR,
'_' );
  -        converterRegistry.registerConverter( converterName, sourceClass.getName(), destClass.getName()
);
  -        final DefaultTypeFactory factory = new DefaultTypeFactory( converterName, converterClass
);
  -        getTypeManager().registerType( Converter.ROLE, converterName, factory );
  +        final ConverterFactory factory = new SimpleConverterFactory( converterClass );
  +        converterRegistry.registerConverter( sourceClass.getName(),
  +                                             destClass.getName(),
  +                                             factory );
       }
   }
  
  
  
  1.14      +1 -1      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java
  
  Index: DefaultDeployerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DefaultDeployerTestCase.java	23 May 2002 09:36:37 -0000	1.13
  +++ DefaultDeployerTestCase.java	27 May 2002 02:17:46 -0000	1.14
  @@ -181,7 +181,7 @@
       }
   
       /**
  -     * Ensures that a test tyoe has not been deployed.
  +     * Ensures that a test type has not been deployed.
        */
       private void assertTypeNotRegistered( final String role, final String typeName )
           throws Exception
  
  
  

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