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/framework/src/java/org/apache/myrmidon/framework/listener ProjectListenerDeployer.java
Date Wed, 22 May 2002 07:36:24 GMT
adammurdoch    02/05/22 00:36:24

  Modified:    ant1compat/src/java/org/apache/tools/ant
                        Ant1CompatProject.java
               antlib   project.xml
               antlib/src/java/org/apache/antlib/runtime ConverterDef.java
                        TypeDef.java
               antlib/src/test/org/apache/antlib
                        AbstractProjectTestCase.java
               container/src/java/org/apache/myrmidon/components/configurer
                        Resources.properties
               container/src/java/org/apache/myrmidon/components/deployer
                        CompoundTypeDeployer.java
                        ConverterTypeDeployer.java
                        DefaultTypeLibraryDeployer.java
                        DescriptorBuilder.java RoleDeployer.java
                        RoleDescriptor.java RoleDescriptorBuilder.java
                        TypeDescriptorBuilder.java
               container/src/java/org/apache/myrmidon/interfaces/deployer
                        DefaultTypeDeployer.java TypeDefinition.java
                        TypeDeployer.java
               container/src/java/org/apache/myrmidon/interfaces/type
                        DefaultTypeFactory.java ReloadingTypeFactory.java
               container/src/test/org/apache/myrmidon/components
                        AbstractComponentTest.java TestDataType.java
               container/src/test/org/apache/myrmidon/components/deployer/test
                        DefaultDeployerTestCase.java ant-descriptor.xml
               container/src/test/org/apache/myrmidon/components/service/test
                        InstantiatingServiceManagerTestCase.java
               container/src/test/org/apache/myrmidon/components/type/test
                        DefaultTypeManagerTestCase.java
               container/src/test/org/apache/myrmidon/interfaces/type/test
                        TypeFactoryTestCase.java
               framework/src/java/org/apache/myrmidon/framework
                        AbstractTypeDef.java DataTypeDeployer.java
                        Resources.properties
               framework/src/java/org/apache/myrmidon/framework/listener
                        ProjectListenerDeployer.java
  Added:       antlib/src/test/org/apache/antlib/runtime/test
                        AbstractTypeDefTestCase.java
                        ConverterDefTestCase.java
                        ConverterDefTestConverter.java
                        ConverterDefTestType.java TypeDefTestCase.java
                        TypeDefTestTask.java TypeDefTestType.java
                        converter-def.ant task-def.ant
               container/src/java/org/apache/myrmidon/interfaces/type
                        ClassLoaderTypeFactory.java
  Removed:     container/src/java/org/apache/myrmidon/components/deployer
                        RoleDefinition.java
  Log:
  Some deployer refactoring:
  
  * Replaced TypeDefinition.getClassName(), with getTypeFactory().  No need
    to pass TypeFactory in to TypeDeployer.deployType() any more.
  
  * Removed RoleDefinition, use RoleInfo instead.
  
  * Renamed DefaultTypeFactory to ClassLoaderTypeFactory.
  
  * Added new DefaultTypeFactory, which instantiates types using Class objects.
    Use this type factory in those places where we already have the Class object
    (ant 1 compat, tests, etc).
  
  * Moved namespace attribute from AbstractTypeDef to TypeDef.
  
  * Added unit tests for <type-def> and <converter-def>.  They don't pass.
  
  Revision  Changes    Path
  1.5       +4 -6      jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/Ant1CompatProject.java
  
  Index: Ant1CompatProject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/Ant1CompatProject.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Ant1CompatProject.java	8 May 2002 13:40:21 -0000	1.4
  +++ Ant1CompatProject.java	22 May 2002 07:36:21 -0000	1.5
  @@ -35,7 +35,7 @@
    * Ant1 original, this class contains the extensions.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.4 $ $Date: 2002/05/08 13:40:21 $
  + * @version $Revision: 1.5 $ $Date: 2002/05/22 07:36:21 $
    */
   public class Ant1CompatProject
       extends Project
  @@ -289,11 +289,9 @@
                                    final Class type )
           throws Exception
       {
  -        final ClassLoader loader = type.getClassLoader();
  -        final DefaultTypeFactory factory = new DefaultTypeFactory( loader );
  -        factory.addNameClassMapping( typeName, type.getName() );
  -
  -        TypeManager typeManager = (TypeManager)m_context.getService( TypeManager.class );
  +        // TODO - reuse the type factory, for all types typedefed in the project
  +        final DefaultTypeFactory factory = new DefaultTypeFactory( typeName, type );
  +        final TypeManager typeManager = (TypeManager)m_context.getService( TypeManager.class );
           typeManager.registerType( roleType, typeName, factory );
       }
   
  
  
  
  1.9       +8 -0      jakarta-ant-myrmidon/antlib/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/project.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- project.xml	12 May 2002 04:03:32 -0000	1.8
  +++ project.xml	22 May 2002 07:36:21 -0000	1.9
  @@ -84,6 +84,14 @@
           </jar>
       </build>
   
  +    <additional-build>
  +        <lib-dir>${test.working.dir}/org/apache/antlib/runtime/test</lib-dir>
  +        <jar>
  +            <id>empty-lib</id>
  +            <name>empty-lib.jar</name>
  +        </jar>
  +    </additional-build>
  +
       <unitTest>
           <sourceDirectory>src/test</sourceDirectory>
           <classpath>
  
  
  
  1.3       +20 -4     jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/ConverterDef.java
  
  Index: ConverterDef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/ConverterDef.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConverterDef.java	19 May 2002 08:28:59 -0000	1.2
  +++ ConverterDef.java	22 May 2002 07:36:21 -0000	1.3
  @@ -11,7 +11,12 @@
   import java.util.Map;
   import org.apache.aut.converter.Converter;
   import org.apache.myrmidon.framework.AbstractTypeDef;
  +import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  +import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
  +import org.apache.myrmidon.interfaces.library.Library;
  +import org.apache.myrmidon.interfaces.type.ClassLoaderTypeFactory;
  +import org.apache.myrmidon.interfaces.type.TypeManager;
   
   /**
    * Task to define a converter.
  @@ -28,7 +33,7 @@
       /**
        * Sets the converter's source type.
        */
  -    public void setSourceType( final String sourceType )
  +    public void setSource( final String sourceType )
       {
           m_sourceType = sourceType;
       }
  @@ -36,17 +41,28 @@
       /**
        * Sets the converter's destination type.
        */
  -    public void setDestinationType( final String destinationType )
  +    public void setDestination( final String destinationType )
       {
           m_destinationType = destinationType;
       }
   
  -    protected TypeDefinition createTypeDefinition()
  +    protected void createTypeDefinition( final Library library )
  +        throws Exception
       {
           final Map attrs = new HashMap();
           attrs.put( TypeDefinition.ATTRIBUTE_SOURCE_CLASS, m_sourceType );
           attrs.put( TypeDefinition.ATTRIBUTE_DESTINATION_CLASS, m_destinationType );
   
  -        return new TypeDefinition( null, Converter.ROLE, getClassname(), attrs );
  +        // Generate a type name
  +        final String name = m_classname.replace( TypeManager.NAMESPACE_SEPARATOR, '_' );
  +
  +        final ClassLoaderTypeFactory typeFactory = new ClassLoaderTypeFactory( library.getClassLoader() );
  +        typeFactory.addNameClassMapping( name, m_classname );
  +
  +        final TypeDefinition typeDef = new TypeDefinition( name, Converter.ROLE, typeFactory, attrs );
  +
  +        final Deployer deployer = (Deployer)getService( Deployer.class );
  +        final TypeLibraryDeployer typeDeployer = deployer.createDeployer( library, null );
  +        typeDeployer.deployType( typeDef );
       }
   }
  
  
  
  1.3       +28 -6     jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeDef.java
  
  Index: TypeDef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeDef.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeDef.java	3 May 2002 06:56:10 -0000	1.2
  +++ TypeDef.java	22 May 2002 07:36:21 -0000	1.3
  @@ -8,7 +8,11 @@
   package org.apache.antlib.runtime;
   
   import org.apache.myrmidon.framework.AbstractTypeDef;
  +import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  +import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
  +import org.apache.myrmidon.interfaces.library.Library;
  +import org.apache.myrmidon.interfaces.type.ClassLoaderTypeFactory;
   
   /**
    * Task to define a type.
  @@ -19,8 +23,17 @@
   public class TypeDef
       extends AbstractTypeDef
   {
  -    private String m_role;
       private String m_name;
  +    private String m_role;
  +    private String m_namespace;
  +
  +    /**
  +     * Sets the type's name.
  +     */
  +    public void setName( final String name )
  +    {
  +        m_name = name;
  +    }
   
       /**
        * Sets the type's role.
  @@ -31,15 +44,24 @@
       }
   
       /**
  -     * Sets the type's name.
  +     * Sets the namespace under which the type is registered.
  +     * This parameter is optional.
  +     * @param namespace
        */
  -    public void setName( final String name )
  +    public void setNamespace( final String namespace )
       {
  -        m_name = name;
  +        m_namespace = namespace;
       }
   
  -    protected TypeDefinition createTypeDefinition()
  +    protected void createTypeDefinition( final Library library )
  +        throws Exception
       {
  -        return new TypeDefinition( m_name, m_role, getClassname() );
  +        final ClassLoaderTypeFactory typeFactory = new ClassLoaderTypeFactory( library.getClassLoader() );
  +        typeFactory.addNameClassMapping( m_name, m_classname );
  +
  +        final Deployer deployer = (Deployer)getService( Deployer.class );
  +        final TypeLibraryDeployer typeDeployer = deployer.createDeployer( library, m_namespace );
  +        final TypeDefinition typeDef = new TypeDefinition( m_name, m_role, typeFactory );
  +        typeDeployer.deployType( typeDef );
       }
   }
  
  
  
  1.3       +26 -3     jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/AbstractProjectTestCase.java
  
  Index: AbstractProjectTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/AbstractProjectTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractProjectTestCase.java	12 May 2002 04:03:32 -0000	1.2
  +++ AbstractProjectTestCase.java	22 May 2002 07:36:21 -0000	1.3
  @@ -12,12 +12,13 @@
   import org.apache.myrmidon.TrackingTaskListener;
   import org.apache.myrmidon.api.event.TaskListener;
   import org.apache.myrmidon.interfaces.EmbeddedAnt;
  +import org.apache.avalon.framework.ExceptionUtil;
   
   /**
    * A base class for test cases which need to execute projects or tasks.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/12 04:03:32 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/22 07:36:21 $
    */
   public class AbstractProjectTestCase
       extends AbstractAutTestCase
  @@ -57,7 +58,7 @@
       {
           try
           {
  -            executeTarget( projectFile, targetName, null );
  +            doExecuteTarget( projectFile, targetName, null );
               fail( "target execution did not fail" );
           }
           catch( final Exception e )
  @@ -86,6 +87,29 @@
                                     final TaskListener listener )
           throws Exception
       {
  +        try
  +        {
  +            doExecuteTarget( projectFile, targetName, listener );
  +        }
  +        catch( final Exception e )
  +        {
  +            // Log the entire exception chain, then rethrow
  +            //for( Throwable t = e; t != null; t = ExceptionUtil.getCause( t, true ) )
  +            //{
  +            //    getLogger().error( t.getMessage(), t );
  +            //}
  +            throw e;
  +        }
  +    }
  +
  +    /**
  +     * Executes a target in a project, and asserts that it does not fail.
  +     */
  +    private void doExecuteTarget( final File projectFile,
  +                                  final String targetName,
  +                                  final TaskListener listener )
  +        throws Exception
  +    {
           final EmbeddedAnt embeddor = new EmbeddedAnt();
           final TrackingTaskListener tracker = new TrackingTaskListener();
   
  @@ -120,7 +144,6 @@
           {
               embeddor.stop();
           }
  -
   
           // Make sure all expected events were delivered
           tracker.assertComplete();
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/runtime/test/AbstractTypeDefTestCase.java
  
  Index: AbstractTypeDefTestCase.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.antlib.runtime.test;
  
  import org.apache.antlib.AbstractProjectTestCase;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.framework.AbstractTypeDef;
  import java.io.File;
  
  /**
   * General purpose test cases for type-def tasks that extend AbstractTypeDef.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/22 07:36:21 $
   */
  public abstract class AbstractTypeDefTestCase
      extends AbstractProjectTestCase
  {
      public AbstractTypeDefTestCase( final String name )
      {
          super( name );
      }
  
      /**
       * Returns the project file for the task being tested.
       */
      protected abstract File getProjectFile() throws Exception;
  
      /**
       * Tests validation.
       */
      public void testValidation()
          throws Exception
      {
          final File projectFile = getProjectFile();
          final Resources res = getResourcesForTested( AbstractTypeDef.class );
  
          // No classpath specified
          String message = res.getString( "typedef.no-lib.error" );
          executeTargetExpectError( projectFile, "no-classpath", message );
  
          // No classname specified
          message = res.getString( "typedef.no-classname.error" );
          executeTargetExpectError( projectFile, "no-classname", message );
      }
  
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/runtime/test/ConverterDefTestCase.java
  
  Index: ConverterDefTestCase.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.antlib.runtime.test;
  
  import java.io.File;
  import org.apache.myrmidon.LogMessageTracker;
  
  /**
   * Test cases for the <converter-def> task.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/22 07:36:21 $
   */
  public class ConverterDefTestCase
      extends AbstractTypeDefTestCase
  {
      public ConverterDefTestCase( final String name )
      {
          super( name );
      }
  
      /**
       * Returns the project file for the task being tested.
       */
      protected File getProjectFile() throws Exception
      {
          return getTestResource( "converter-def.ant" );
      }
  
      /**
       * Tests that a converter can be registered, and used.
       */
      public void testConverter() throws Exception
      {
          final File projectFile = getProjectFile();
          final LogMessageTracker tracker = new LogMessageTracker();
          tracker.addExpectedMessage( "/converter-def/converter-def/log", "[some content]" );
          executeTarget( projectFile, "converter-def", tracker );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/runtime/test/ConverterDefTestConverter.java
  
  Index: ConverterDefTestConverter.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.antlib.runtime.test;
  
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  
  /**
   * A test converter.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/22 07:36:21 $
   */
  public class ConverterDefTestConverter
      extends AbstractConverter
  {
      public ConverterDefTestConverter()
      {
          super( ConverterDefTestType.class, String.class );
      }
  
      protected Object convert( final Object original, final Object context )
          throws ConverterException
      {
          final ConverterDefTestType obj = (ConverterDefTestType)original;
          return "[" + obj + "]";
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/runtime/test/ConverterDefTestType.java
  
  Index: ConverterDefTestType.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.antlib.runtime.test;
  
  import org.apache.myrmidon.framework.DataType;
  
  /**
   * A data-type used by the <converter-def> test cases.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/22 07:36:21 $
   *
   * @ant.data-type name="converter-def-test-type"
   */
  public class ConverterDefTestType
      implements DataType
  {
      private String m_content;
  
      public void addContent( final String content )
      {
          m_content = content;
      }
  
      public String toString()
      {
          return m_content;
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/runtime/test/TypeDefTestCase.java
  
  Index: TypeDefTestCase.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.antlib.runtime.test;
  
  import org.apache.myrmidon.LogMessageTracker;
  import java.io.File;
  
  /**
   * Test cases for the <type-def> task.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/22 07:36:21 $
   */
  public class TypeDefTestCase
      extends AbstractTypeDefTestCase
  {
      public TypeDefTestCase( final String name )
      {
          super( name );
      }
  
      /**
       * Returns the project file for the task being tested.
       */
      protected File getProjectFile() throws Exception
      {
          return getTestResource( "task-def.ant" );
      }
  
      /**
       * Tests that a task can be defined, and then used.
       */
      public void testTaskDef()
          throws Exception
      {
          final File projectFile = getProjectFile();
          final LogMessageTracker tracker = new LogMessageTracker();
          tracker.addExpectedMessage( "/task-def/task-def/test-task", "This is the test task." );
          executeTarget( projectFile, "task-def", tracker );
      }
  
      /**
       * Tests that a data-type can be defined, and then used.
       */
      public void testDataTypeDef()
          throws Exception
      {
          final File projectFile = getProjectFile();
          final LogMessageTracker tracker = new LogMessageTracker();
          tracker.addExpectedMessage( "/task-def/data-type-def/log", "This is prop1." );
          tracker.addExpectedMessage( "/task-def/data-type-def/log", "This is prop2." );
          executeTarget( projectFile, "data-type-def", tracker );
      }
  
      /**
       * Tests that a polymorphic type can be defined, and then used.
       */
      public void testPolymorphicTypeDef()
          throws Exception
      {
          final File projectFile = getProjectFile();
          final LogMessageTracker tracker = new LogMessageTracker();
          final File testFile = getTestResource( "some-file", false );
          tracker.addExpectedMessage( "/task-def/path-type-def/list-path", testFile.getAbsolutePath() );
          executeTarget( projectFile, "path-type-def", tracker );
      }
  
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/runtime/test/TypeDefTestTask.java
  
  Index: TypeDefTestTask.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.antlib.runtime.test;
  
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * A task for testing the <type-def> task.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/22 07:36:21 $
   */
  public class TypeDefTestTask
      extends AbstractTask
  {
      /**
       * Execute task.
       */
      public void execute()
          throws TaskException
      {
          getContext().info( "This is the test task." );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/runtime/test/TypeDefTestType.java
  
  Index: TypeDefTestType.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.antlib.runtime.test;
  
  import org.apache.myrmidon.framework.DataType;
  
  /**
   * A test data-type for the <type-def> task.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/22 07:36:21 $
   */
  public class TypeDefTestType
      implements DataType
  {
      private String m_content;
  
      public void addContent( final String content )
      {
          m_content = content;
      }
  
      public String toString()
      {
          return m_content;
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/runtime/test/converter-def.ant
  
  Index: converter-def.ant
  ===================================================================
  <project version="2.0">
      <path id="test.path" path="empty-lib.jar"/>
  
      <target name="no-classpath">
          <converter-def source="org.apache.antlib.runtime.test.ConverterDefTestType"
                         destination="java.lang.String"
                         classname="org.apache.antlib.runtime.test.ConverterDefTestConverter"/>
      </target>
  
      <target name="no-classname">
          <converter-def source="org.apache.antlib.runtime.test.ConverterDefTestType"
                         destination="java.lang.String">
              <classpath-ref id="test.path"/>
          </converter-def>
      </target>
  
      <target name="converter-def">
          <converter-def source="org.apache.antlib.runtime.test.ConverterDefTestType"
                         destination="java.lang.String"
                         classname="org.apache.antlib.runtime.test.ConverterDefTestConverter">
              <classpath-ref id="test.path"/>
          </converter-def>
          <property name="test.prop">
              <converter-def-test-type>some content</converter-def-test-type>
          </property>
          <log>${test.prop}</log>
      </target>
  
  </project>
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/runtime/test/task-def.ant
  
  Index: task-def.ant
  ===================================================================
  <project version="2.0">
      <path id="test.path" path="empty-lib.jar"/>
  
      <!-- Define and use a task -->
      <target name="task-def">
          <type-def role="task"
                    name="test-task"
                    classname="org.apache.antlib.runtime.test.TypeDefTestTask">
              <classpath-ref id="test.path"/>
          </type-def>
          <test-task/>
      </target>
  
      <!-- Define and use a data-type -->
      <target name="data-type-def">
          <type-def role="data-type"
                    name="test-type"
                    classname="org.apache.antlib.runtime.test.TypeDefTestType">
              <classpath-ref id="test.path"/>
          </type-def>
          <test-type id="test.prop">this is prop1</test-type>
          <property name="test.prop2">
              <test-type>this is prop2</test-type>
          </property>
          <log>${test.prop}</log>
          <log>${test.prop2}</log>
      </target>
  
      <!-- Define and use a polymorphic type -->
      <target name="path-type-def">
          <type-def role="path"
                    name="test-path"
                    classname="org.apache.antlib.runtime.test.TypeDefTestFileList">
              <classpath-ref id="test.path"/>
          </type-def>
          <list-path>
              <test-path some-prop="some-file"/>
          </list-path>
      </target>
  
      <!-- No classpath -->
      <target name="no-classpath">
          <type-def role="task"
                    name="some-task"
                    classname="org.apache.antlib.runtime.test.TypeDefTestTask"/>
      </target>
  
      <!-- No class name -->
      <target name="no-classname">
          <type-def role="task"
                    name="test-task">
              <classpath-ref id="test.path"/>
          </type-def>
      </target>
  
  </project>
  
  
  1.21      +1 -1      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/configurer/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/configurer/Resources.properties,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Resources.properties	25 Apr 2002 02:55:41 -0000	1.20
  +++ Resources.properties	22 May 2002 07:36:21 -0000	1.21
  @@ -9,7 +9,7 @@
   bad-set-attribute.error=Could not set attribute "{1}" for element <{0}>.
   bad-set-class-attribute.error=Could not set attribute "{0}" for object of class {1}.
   no-such-element.error=Element <{0}> does not support nested <{1}> elements.
  -no-content.error=Element <{0} does not support text content.
  +no-content.error=Element <{0}> does not support text content.
   bad-set-content.error=Could not set text content for element <{0}>.
   create-typed-object.error=Could not create an object of type "{0}" of class {1}.
   unknown-reference.error=Could not find referenced object "{0}".
  
  
  
  1.5       +3 -4      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/CompoundTypeDeployer.java
  
  Index: CompoundTypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/CompoundTypeDeployer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CompoundTypeDeployer.java	8 May 2002 04:10:26 -0000	1.4
  +++ CompoundTypeDeployer.java	22 May 2002 07:36:22 -0000	1.5
  @@ -17,7 +17,7 @@
    * A type deployer that delegates to a type deployer per role.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.4 $ $Date: 2002/05/08 04:10:26 $
  + * @version $Revision: 1.5 $ $Date: 2002/05/22 07:36:22 $
    */
   class CompoundTypeDeployer
       implements TypeDeployer
  @@ -42,8 +42,7 @@
        * Deploys a type.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDefinition,
  -                            final TypeFactory typeFactory )
  +                            final TypeDefinition typeDefinition )
           throws Exception
       {
           // Use the deployer for the type's role, if any.  Otherwise use the
  @@ -53,6 +52,6 @@
           {
               deployer = m_defaultDeployer;
           }
  -        deployer.deployType( namespace, typeDefinition, typeFactory );
  +        deployer.deployType( namespace, typeDefinition );
       }
   }
  
  
  
  1.6       +3 -4      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ConverterTypeDeployer.java	19 May 2002 08:28:59 -0000	1.5
  +++ ConverterTypeDeployer.java	22 May 2002 07:36:22 -0000	1.6
  @@ -23,7 +23,7 @@
    * manager and the converter registry.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.5 $ $Date: 2002/05/19 08:28:59 $
  + * @version $Revision: 1.6 $ $Date: 2002/05/22 07:36:22 $
    */
   class ConverterTypeDeployer
       extends DefaultTypeDeployer
  @@ -45,8 +45,7 @@
        * Deploys a type.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDefinition,
  -                            final TypeFactory typeFactory )
  +                            final TypeDefinition typeDefinition )
           throws Exception
       {
           // Add the converter to the converter registry
  @@ -67,6 +66,6 @@
           m_converterRegistry.registerConverter( name, source, destination );
   
           // Register the converter as a type
  -        super.deployType( namespace, typeDefinition, typeFactory );
  +        super.deployType( namespace, typeDefinition );
       }
   }
  
  
  
  1.7       +15 -28    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultTypeLibraryDeployer.java
  
  Index: DefaultTypeLibraryDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultTypeLibraryDeployer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultTypeLibraryDeployer.java	9 May 2002 07:54:31 -0000	1.6
  +++ DefaultTypeLibraryDeployer.java	22 May 2002 07:36:22 -0000	1.7
  @@ -24,7 +24,7 @@
   import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
   import org.apache.myrmidon.interfaces.role.RoleInfo;
   import org.apache.myrmidon.interfaces.role.RoleRegistry;
  -import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
  +import org.apache.myrmidon.interfaces.type.ClassLoaderTypeFactory;
   import org.xml.sax.XMLReader;
   
   /**
  @@ -32,7 +32,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.6 $ $Date: 2002/05/09 07:54:31 $
  + * @version $Revision: 1.7 $ $Date: 2002/05/22 07:36:22 $
    *
    * @todo Keep track of which types have been deployed, and don't redeploy them.
    */
  @@ -115,13 +115,13 @@
       /**
        * Returns the type factory for a role.
        */
  -    public DefaultTypeFactory getFactory( final String roleName )
  +    public ClassLoaderTypeFactory getFactory( final String roleName )
       {
  -        DefaultTypeFactory factory = (DefaultTypeFactory)m_factories.get( roleName );
  +        ClassLoaderTypeFactory factory = (ClassLoaderTypeFactory)m_factories.get( roleName );
   
           if( null == factory )
           {
  -            factory = new DefaultTypeFactory( m_classLoader );
  +            factory = new ClassLoaderTypeFactory( m_classLoader );
               m_factories.put( roleName, factory );
           }
   
  @@ -211,7 +211,6 @@
           // Validate the type definition
           final String typeName = typeDef.getName();
           final String roleName = typeDef.getRole();
  -        final String className = typeDef.getClassname();
           if( null == roleName )
           {
               final String message = REZ.getString( "typedef.no-role.error" );
  @@ -222,18 +221,9 @@
               final String message = REZ.getString( "typedef.no-name.error" );
               throw new DeploymentException( message );
           }
  -        if( null == className )
  -        {
  -            final String message = REZ.getString( "typedef.no-classname.error" );
  -            throw new DeploymentException( message );
  -        }
  -
  -        // Add to type factory
  -        final DefaultTypeFactory factory = getFactory( roleName );
  -        factory.addNameClassMapping( typeName, className );
   
           // Deploy
  -        m_typeDeployer.deployType( m_namespace, typeDef, factory );
  +        m_typeDeployer.deployType( m_namespace, typeDef );
   
           if( getLogger().isDebugEnabled() )
           {
  @@ -261,7 +251,7 @@
               // Parse the file
               parser.parse( url );
               final TypelibDescriptor descriptor =
  -                builder.createDescriptor( handler.getConfiguration(), url );
  +                builder.createDescriptor( handler.getConfiguration(), url, this );
               descriptors.add( descriptor );
           }
   
  @@ -322,14 +312,14 @@
                   getLogger().debug( message );
               }
   
  -            final RoleDefinition[] definitions = descriptor.getDefinitions();
  +            final RoleInfo[] definitions = descriptor.getDefinitions();
               for( int i = 0; i < definitions.length; i++ )
               {
  -                final RoleDefinition definition = definitions[ i ];
  -                deployRole( definition );
  +                final RoleInfo roleInfo = definitions[ i ];
  +                deployRole( roleInfo );
               }
           }
  -        catch( Exception e )
  +        catch( final Exception e )
           {
               final String message = REZ.getString( "deploy-roles.error", descriptor.getUrl() );
               throw new DeploymentException( message, e );
  @@ -337,20 +327,17 @@
       }
   
       /**
  -     * Handles a role definition.
  +     * Deploys a role.
        */
  -    private void deployRole( final RoleDefinition roleDef )
  +    private void deployRole( final RoleInfo roleInfo )
           throws Exception
       {
  -        final String role = roleDef.getRoleName();
  -        final String className = roleDef.getClassName();
  -        final Class type = m_classLoader.loadClass( className );
  -        final RoleInfo roleInfo = new RoleInfo( role, type, roleDef.getAttributes() );
           m_roleRegistry.addRole( roleInfo );
   
           if( getLogger().isDebugEnabled() )
           {
  -            final String debugMessage = REZ.getString( "register-role.notice", role, className );
  +            final String debugMessage =
  +                REZ.getString( "register-role.notice", roleInfo.getName(), roleInfo.getImplementationClass().getName() );
               getLogger().debug( debugMessage );
           }
       }
  
  
  
  1.3       +3 -2      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DescriptorBuilder.java
  
  Index: DescriptorBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DescriptorBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DescriptorBuilder.java	21 Apr 2002 02:06:25 -0000	1.2
  +++ DescriptorBuilder.java	22 May 2002 07:36:22 -0000	1.3
  @@ -14,7 +14,7 @@
    * Builds a descriptor.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.2 $ $Date: 2002/04/21 02:06:25 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/22 07:36:22 $
    */
   interface DescriptorBuilder
   {
  @@ -22,6 +22,7 @@
        * Builds a descriptor from a set of configuration.
        */
       TypelibDescriptor createDescriptor( Configuration model,
  -                                        String descriptorUrl )
  +                                        String descriptorUrl,
  +                                        DefaultTypeLibraryDeployer deployer )
           throws DeploymentException;
   }
  
  
  
  1.2       +6 -7      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/RoleDeployer.java
  
  Index: RoleDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/RoleDeployer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RoleDeployer.java	25 Apr 2002 09:34:45 -0000	1.1
  +++ RoleDeployer.java	22 May 2002 07:36:22 -0000	1.2
  @@ -7,22 +7,21 @@
    */
   package org.apache.myrmidon.components.deployer;
   
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
   import org.apache.myrmidon.interfaces.role.RoleException;
   import org.apache.myrmidon.interfaces.role.RoleInfo;
   import org.apache.myrmidon.interfaces.role.RoleRegistry;
  -import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
  -import org.apache.avalon.framework.service.Serviceable;
  -import org.apache.avalon.framework.service.ServiceManager;
  -import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.excalibur.i18n.ResourceManager;
  -import org.apache.avalon.excalibur.i18n.Resources;
   
   /**
    * Responsible for deploying roles, and instantiating custom type deployers
    * for roles.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/25 09:34:45 $
  + * @version $Revision: 1.2 $ $Date: 2002/05/22 07:36:22 $
    */
   class RoleDeployer
       implements RoleRegistry
  
  
  
  1.3       +6 -6      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/RoleDescriptor.java
  
  Index: RoleDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/RoleDescriptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RoleDescriptor.java	1 Apr 2002 09:56:26 -0000	1.2
  +++ RoleDescriptor.java	22 May 2002 07:36:22 -0000	1.3
  @@ -9,12 +9,13 @@
   
   import java.util.ArrayList;
   import java.util.List;
  +import org.apache.myrmidon.interfaces.role.RoleInfo;
   
   /**
    * A typelib role descriptor, which defines a set of roles.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.2 $ $Date: 2002/04/01 09:56:26 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/22 07:36:22 $
    */
   class RoleDescriptor
       extends TypelibDescriptor
  @@ -29,17 +30,16 @@
       /**
        * Returns the role definitions in the descriptor.
        */
  -    public RoleDefinition[] getDefinitions()
  +    public RoleInfo[] getDefinitions()
       {
  -        return (RoleDefinition[])m_definitions.toArray
  -            ( new RoleDefinition[ m_definitions.size() ] );
  +        return (RoleInfo[])m_definitions.toArray( new RoleInfo[ m_definitions.size() ] );
       }
   
       /**
        * Adds a role definition to the descriptor.
        */
  -    public void addDefinition( final RoleDefinition def )
  +    public void addDefinition( final RoleInfo roleInfo )
       {
  -        m_definitions.add( def );
  +        m_definitions.add( roleInfo );
       }
   }
  
  
  
  1.8       +10 -8     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/RoleDescriptorBuilder.java
  
  Index: RoleDescriptorBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/RoleDescriptorBuilder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RoleDescriptorBuilder.java	25 Apr 2002 09:34:45 -0000	1.7
  +++ RoleDescriptorBuilder.java	22 May 2002 07:36:22 -0000	1.8
  @@ -7,20 +7,20 @@
    */
   package org.apache.myrmidon.components.deployer;
   
  +import java.util.HashMap;
  +import java.util.Map;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.Version;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.myrmidon.interfaces.deployer.DeploymentException;
  -import java.util.Map;
  -import java.util.Collections;
  -import java.util.HashMap;
  +import org.apache.myrmidon.interfaces.role.RoleInfo;
   
   /**
    * Builds typelib role descriptors.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.7 $ $Date: 2002/04/25 09:34:45 $
  + * @version $Revision: 1.8 $ $Date: 2002/05/22 07:36:22 $
    */
   class RoleDescriptorBuilder
       implements DescriptorBuilder
  @@ -34,7 +34,8 @@
        * Builds a descriptor from a set of configuration.
        */
       public TypelibDescriptor createDescriptor( final Configuration model,
  -                                               final String url )
  +                                               final String url,
  +                                               final DefaultTypeLibraryDeployer deployer )
           throws DeploymentException
       {
           try
  @@ -59,6 +60,7 @@
                   final Configuration type = types[ i ];
                   final String roleName = type.getAttribute( "name" );
                   final String className = type.getAttribute( "classname" );
  +                final Class roleType = deployer.getClassLoader().loadClass( className );
                   final Map attrMap = new HashMap();
                   final String[] attrs = type.getAttributeNames();
                   for( int j = 0; j < attrs.length; j++ )
  @@ -69,13 +71,13 @@
                   attrMap.remove( "name" );
                   attrMap.remove( "classname" );
   
  -                final RoleDefinition roleDef = new RoleDefinition( roleName, className, attrMap );
  -                descriptor.addDefinition( roleDef );
  +                final RoleInfo roleInfo = new RoleInfo( roleName, roleType, attrMap );
  +                descriptor.addDefinition( roleInfo );
               }
   
               return descriptor;
           }
  -        catch( Exception e )
  +        catch( final Exception e )
           {
               final String message = REZ.getString( "build-role-descriptor.error", url );
               throw new DeploymentException( message, e );
  
  
  
  1.8       +21 -8     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/TypeDescriptorBuilder.java
  
  Index: TypeDescriptorBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/TypeDescriptorBuilder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TypeDescriptorBuilder.java	19 May 2002 08:28:59 -0000	1.7
  +++ TypeDescriptorBuilder.java	22 May 2002 07:36:22 -0000	1.8
  @@ -15,12 +15,14 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.myrmidon.interfaces.deployer.DeploymentException;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  +import org.apache.myrmidon.interfaces.type.ClassLoaderTypeFactory;
  +import org.apache.myrmidon.interfaces.type.TypeManager;
   
   /**
    * Builds typelib type descriptors.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.7 $ $Date: 2002/05/19 08:28:59 $
  + * @version $Revision: 1.8 $ $Date: 2002/05/22 07:36:22 $
    */
   class TypeDescriptorBuilder
       implements DescriptorBuilder
  @@ -34,7 +36,8 @@
        * Builds a descriptor from a set of configuration.
        */
       public TypelibDescriptor createDescriptor( final Configuration model,
  -                                               final String url )
  +                                               final String url,
  +                                               final DefaultTypeLibraryDeployer deployer )
           throws DeploymentException
       {
           try
  @@ -69,7 +72,7 @@
                   for( int i = 0; i < typeEntries.length; i++ )
                   {
                       final Configuration typeEntry = typeEntries[ i ];
  -                    final TypeDefinition typeDef = createTypeDefinition( typeEntry );
  +                    final TypeDefinition typeDef = createTypeDefinition( typeEntry, deployer );
                       descriptor.addDefinition( typeDef );
                   }
   
  @@ -86,12 +89,22 @@
       /**
        * Creates a type definition.
        */
  -    private TypeDefinition createTypeDefinition( final Configuration element )
  +    private TypeDefinition createTypeDefinition( final Configuration element,
  +                                                 final DefaultTypeLibraryDeployer deployer )
           throws Exception
       {
  -        final String roleShorthand = element.getName();
  -        final String typeName = element.getAttribute( "name", null );
  -        final String className = element.getAttribute( "classname", null );
  +        final String roleName = element.getName();
  +        final String className = element.getAttribute( "classname" );
  +        String typeName = element.getAttribute( "name", null );
  +        if( typeName == null )
  +        {
  +            typeName = className.replace( TypeManager.NAMESPACE_SEPARATOR, '_' );
  +        }
  +
  +        // Add to type factory
  +        final ClassLoaderTypeFactory factory = deployer.getFactory( roleName );
  +        factory.addNameClassMapping( typeName, className );
  +
           final String[] attributes = element.getAttributeNames();
           final Map attrs = new HashMap();
           for( int i = 0; i < attributes.length; i++ )
  @@ -99,6 +112,6 @@
               final String name = attributes[ i ];
               attrs.put( name, element.getAttribute( name ) );
           }
  -        return new TypeDefinition( typeName, roleShorthand, className, attrs );
  +        return new TypeDefinition( typeName, roleName, factory, attrs );
       }
   }
  
  
  
  1.3       +3 -3      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/DefaultTypeDeployer.java
  
  Index: DefaultTypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/DefaultTypeDeployer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultTypeDeployer.java	8 May 2002 04:10:27 -0000	1.2
  +++ DefaultTypeDeployer.java	22 May 2002 07:36:22 -0000	1.3
  @@ -19,7 +19,7 @@
    * manager.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/08 04:10:27 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/22 07:36:22 $
    */
   public class DefaultTypeDeployer
       implements TypeDeployer, Serviceable
  @@ -41,12 +41,12 @@
        * Deploys a type.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDefinition,
  -                            final TypeFactory typeFactory )
  +                            final TypeDefinition typeDefinition )
           throws Exception
       {
           final String roleName = typeDefinition.getRole();
           final String typeName = typeDefinition.getName();
  +        final TypeFactory typeFactory = typeDefinition.getFactory();
           m_typeManager.registerType( roleName, namespace, typeName, typeFactory );
       }
   }
  
  
  
  1.7       +18 -25    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/TypeDefinition.java
  
  Index: TypeDefinition.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/TypeDefinition.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TypeDefinition.java	19 May 2002 08:28:59 -0000	1.6
  +++ TypeDefinition.java	22 May 2002 07:36:22 -0000	1.7
  @@ -10,12 +10,13 @@
   import java.util.Map;
   import java.util.HashMap;
   import java.util.Collections;
  +import org.apache.myrmidon.interfaces.type.TypeFactory;
   
   /**
    * A general-purpose type definition.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.6 $ $Date: 2002/05/19 08:28:59 $
  + * @version $Revision: 1.7 $ $Date: 2002/05/22 07:36:22 $
    */
   public class TypeDefinition
   {
  @@ -24,44 +25,36 @@
   
       private final String m_name;
       private final String m_role;
  -    private final String m_classname;
  +    private final TypeFactory m_factory;
       private final Map m_attributes ;
   
       /**
        * Creates a TypeDefinition
        * @param name the name of the type
        * @param role the name of the role of this type
  -     * @param className the name of the class implementing this type
  +     * @param factory the factory to use to create instances of this type
        */
       public TypeDefinition( final String name,
                              final String role,
  -                           final String className )
  +                           final TypeFactory factory )
       {
  -        this( name, role, className, null );
  +        this( name, role, factory, null );
       }
   
       /**
        * Creates a TypeDefinition
        * @param name the name of the type
        * @param role the name of the role of this type
  -     * @param className the name of the class implementing this type
  +     * @param factory the factory to use to create instances of this type
        */
       public TypeDefinition( final String name,
                              final String role,
  -                           final String className,
  +                           final TypeFactory factory,
                              final Map attributes )
       {
  -        if( name != null )
  -        {
  -            m_name = name;
  -        }
  -        else
  -        {
  -            // TODO - this is hackery, some roles don't need a name.
  -            m_name = className.replace( '.', '_' );
  -        }
  +        m_name = name;
           m_role = role;
  -        m_classname = className;
  +        m_factory = factory;
           if( attributes != null && attributes.size() > 0 )
           {
               // TODO - make read only
  @@ -74,14 +67,6 @@
       }
   
       /**
  -     * @return the type's implementation class name.
  -     */
  -    public final String getClassname()
  -    {
  -        return m_classname;
  -    }
  -
  -    /**
        * @return the type's role.
        */
       public final String getRole()
  @@ -95,6 +80,14 @@
       public String getName()
       {
           return m_name;
  +    }
  +
  +    /**
  +     * @return the type's factory.
  +     */
  +    public TypeFactory getFactory()
  +    {
  +        return m_factory;
       }
   
       /**
  
  
  
  1.9       +2 -7      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/TypeDeployer.java
  
  Index: TypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/TypeDeployer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TypeDeployer.java	10 May 2002 01:44:48 -0000	1.8
  +++ TypeDeployer.java	22 May 2002 07:36:22 -0000	1.9
  @@ -7,14 +7,11 @@
    */
   package org.apache.myrmidon.interfaces.deployer;
   
  -import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  -import org.apache.myrmidon.interfaces.type.TypeFactory;
  -
   /**
    * Deploys the types of a particular role.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.8 $ $Date: 2002/05/10 01:44:48 $
  + * @version $Revision: 1.9 $ $Date: 2002/05/22 07:36:22 $
    */
   public interface TypeDeployer
   {
  @@ -23,11 +20,9 @@
        *
        * @param namespace The namespace to deploy the types under.
        * @param typeDefinition The type to deploy.
  -     * @param typeFactory The factory to use for instantiating the type.
        * @throws java.lang.Exception On error.
        */
       void deployType( String namespace,
  -                     TypeDefinition typeDefinition,
  -                     TypeFactory typeFactory )
  +                     TypeDefinition typeDefinition )
           throws Exception;
   }
  
  
  
  1.14      +19 -38    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/type/DefaultTypeFactory.java
  
  Index: DefaultTypeFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/type/DefaultTypeFactory.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DefaultTypeFactory.java	18 May 2002 04:07:08 -0000	1.13
  +++ DefaultTypeFactory.java	22 May 2002 07:36:23 -0000	1.14
  @@ -16,7 +16,7 @@
    * from the same classloader.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version CVS $Revision: 1.13 $ $Date: 2002/05/18 04:07:08 $
  + * @version CVS $Revision: 1.14 $ $Date: 2002/05/22 07:36:23 $
    */
   public class DefaultTypeFactory
       implements TypeFactory
  @@ -24,50 +24,41 @@
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultTypeFactory.class );
   
  -    ///A Map of shortnames to classnames
  -    private final HashMap m_classNames = new HashMap();
  -
  -    ///The parent classLoader (if any)
  -    private ClassLoader m_classLoader;
  +    /** A Map from type name to implementing Class. */
  +    private final HashMap m_typeMap = new HashMap();
   
       /**
  -     * Construct a factory that uses specified ClassLoader to load
  -     * types from.
  -     * @param classLoader The ClassLoader to use for loading types.
  +     * Creates a factory, with no type mappings.
        */
  -    public DefaultTypeFactory( final ClassLoader classLoader )
  +    public DefaultTypeFactory()
       {
  -        if( null == classLoader )
  -        {
  -            throw new NullPointerException( "classLoader" );
  -        }
  -
  -        m_classLoader = classLoader;
       }
   
       /**
  -     * No arg constructor used by subclasses who wish to overide getClassLoader().
  +     * Creates a factory, with a single type mapping.  Additional mappings
  +     * can be added using {@link #addNameClassMapping}.
        */
  -    protected DefaultTypeFactory()
  +    public DefaultTypeFactory( final String name, final Class implClass )
       {
  +        addNameClassMapping( name, implClass );
       }
   
       /**
  -     * Map a name to the fully qualified name of the Class that implements type.
  +     * Map a type name to the Class that implements the type.
        * @param name The type name.
  -     * @param className The fully qualified name of the implementin Class.
  +     * @param implClass The implementing Class.
        */
  -    public void addNameClassMapping( final String name, final String className )
  +    public void addNameClassMapping( final String name, final Class implClass )
       {
  -        m_classNames.put( name, className );
  +        m_typeMap.put( name, implClass );
       }
   
       /**
        * @see TypeFactory#canCreate
        */
  -    public boolean canCreate( String name )
  +    public boolean canCreate( final String name )
       {
  -        return ( getClassName( name ) != null );
  +        return ( getClassForType( name ) != null );
       }
   
       /**
  @@ -77,8 +68,8 @@
           throws TypeException
       {
           // Determine the name of the class to instantiate
  -        final String className = getClassName( name );
  -        if( null == className )
  +        final Class clazz = getClassForType( name );
  +        if( null == clazz )
           {
               final String message = REZ.getString( "no-mapping.error", name );
               throw new TypeException( message );
  @@ -87,8 +78,6 @@
           // Instantiate the object
           try
           {
  -            final ClassLoader classLoader = getClassLoader();
  -            final Class clazz = classLoader.loadClass( className );
               return clazz.newInstance();
           }
           catch( final Exception e )
  @@ -98,16 +87,8 @@
           }
       }
   
  -    private String getClassName( final String name )
  -    {
  -        return (String)m_classNames.get( name );
  -    }
  -
  -    /**
  -     * @return The ClassLoader to use for loading types.
  -     */
  -    protected ClassLoader getClassLoader()
  +    private Class getClassForType( final String name )
       {
  -        return m_classLoader;
  +        return (Class)m_typeMap.get( name );
       }
   }
  
  
  
  1.4       +2 -2      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/type/ReloadingTypeFactory.java
  
  Index: ReloadingTypeFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/type/ReloadingTypeFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ReloadingTypeFactory.java	1 Apr 2002 09:56:27 -0000	1.3
  +++ ReloadingTypeFactory.java	22 May 2002 07:36:23 -0000	1.4
  @@ -18,10 +18,10 @@
    * libraries.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2002/04/01 09:56:27 $
  + * @version CVS $Revision: 1.4 $ $Date: 2002/05/22 07:36:23 $
    */
   public class ReloadingTypeFactory
  -    extends DefaultTypeFactory
  +    extends ClassLoaderTypeFactory
   {
       /**
        * The URLs that are used to construct the ClassLoader.
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/type/ClassLoaderTypeFactory.java
  
  Index: ClassLoaderTypeFactory.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.interfaces.type;
  
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import java.util.HashMap;
  
  /**
   * A {@link TypeFactory} implementation that creates instances using classes
   * from the a classloader.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/22 07:36:22 $
   */
  public class ClassLoaderTypeFactory
      implements TypeFactory
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( DefaultTypeFactory.class );
  
      ///A Map of shortnames to classnames
      private final HashMap m_classNames = new HashMap();
  
      ///The parent classLoader (if any)
      private ClassLoader m_classLoader;
  
      /**
       * Construct a factory that uses specified ClassLoader to load
       * types from.
       * @param classLoader The ClassLoader to use for loading types.
       */
      public ClassLoaderTypeFactory( final ClassLoader classLoader )
      {
          if( null == classLoader )
          {
              throw new NullPointerException( "classLoader" );
          }
  
          m_classLoader = classLoader;
      }
  
      /**
       * No arg constructor used by subclasses who wish to overide getClassLoader().
       */
      protected ClassLoaderTypeFactory()
      {
      }
  
      /**
       * Map a name to the fully qualified name of the Class that implements type.
       * @param name The type name.
       * @param className The fully qualified name of the implementin Class.
       */
      public void addNameClassMapping( final String name, final String className )
      {
          m_classNames.put( name, className );
      }
  
      /**
       * @see TypeFactory#canCreate
       */
      public boolean canCreate( String name )
      {
          return ( getClassName( name ) != null );
      }
  
      /**
       * @see TypeFactory#create
       */
      public Object create( final String name )
          throws TypeException
      {
          // Determine the name of the class to instantiate
          final String className = getClassName( name );
          if( null == className )
          {
              final String message = REZ.getString( "no-mapping.error", name );
              throw new TypeException( message );
          }
  
          // Instantiate the object
          try
          {
              final ClassLoader classLoader = getClassLoader();
              final Class clazz = classLoader.loadClass( className );
              return clazz.newInstance();
          }
          catch( final Exception e )
          {
              final String message = REZ.getString( "no-instantiate.error", name );
              throw new TypeException( message, e );
          }
      }
  
      private String getClassName( final String name )
      {
          return (String)m_classNames.get( name );
      }
  
      /**
       * @return The ClassLoader to use for loading types.
       */
      protected ClassLoader getClassLoader()
      {
          return m_classLoader;
      }
  
  }
  
  
  
  1.39      +3 -6      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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- AbstractComponentTest.java	18 May 2002 04:17:03 -0000	1.38
  +++ AbstractComponentTest.java	22 May 2002 07:36:23 -0000	1.39
  @@ -59,7 +59,7 @@
    * A base class for tests for the default components.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.38 $ $Date: 2002/05/18 04:17:03 $
  + * @version $Revision: 1.39 $ $Date: 2002/05/22 07:36:23 $
    */
   public abstract class AbstractComponentTest
       extends AbstractContainerTestCase
  @@ -266,9 +266,7 @@
                                    final Class type )
           throws Exception
       {
  -        final ClassLoader loader = getClass().getClassLoader();
  -        final DefaultTypeFactory factory = new DefaultTypeFactory( loader );
  -        factory.addNameClassMapping( typeName, type.getName() );
  +        final DefaultTypeFactory factory = new DefaultTypeFactory( typeName, type );
           getTypeManager().registerType( roleName, typeName, factory );
       }
   
  @@ -283,8 +281,7 @@
           final ConverterRegistry converterRegistry = (ConverterRegistry)getServiceManager().lookup( ConverterRegistry.ROLE );
           final String converterName = converterClass.getName().replace( TypeManager.NAMESPACE_SEPARATOR, '_' );
           converterRegistry.registerConverter( converterName, sourceClass.getName(), destClass.getName() );
  -        DefaultTypeFactory factory = new DefaultTypeFactory( getClass().getClassLoader() );
  -        factory.addNameClassMapping( converterName, converterClass.getName() );
  +        final DefaultTypeFactory factory = new DefaultTypeFactory( converterName, converterClass );
           getTypeManager().registerType( Converter.ROLE, converterName, factory );
       }
   }
  
  
  
  1.3       +1 -1      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/TestDataType.java
  
  Index: TestDataType.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/TestDataType.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestDataType.java	24 Apr 2002 02:21:00 -0000	1.2
  +++ TestDataType.java	22 May 2002 07:36:23 -0000	1.3
  @@ -15,5 +15,5 @@
    */
   public interface TestDataType
   {
  -    String ROLE = "data-type";
  +    String ROLE = "test-data-type";
   }
  
  
  
  1.12      +6 -4      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultDeployerTestCase.java	19 May 2002 08:28:59 -0000	1.11
  +++ DefaultDeployerTestCase.java	22 May 2002 07:36:23 -0000	1.12
  @@ -24,6 +24,7 @@
   import org.apache.myrmidon.interfaces.type.TypeException;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
  +import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
   
   /**
    * Test cases for the default deployer.
  @@ -93,10 +94,10 @@
       public void testSingleType() throws Exception
       {
           final String typeName = TEST_TYPE1_NAME;
  -        final String classname = TestType1.class.getName();
   
           // Create the type definition
  -        final TypeDefinition typeDef = new TypeDefinition( typeName, TestDataType.ROLE, classname );
  +        final TypeFactory typeFactory = new DefaultTypeFactory( TEST_TYPE1_NAME, TestType1.class );
  +        final TypeDefinition typeDef = new TypeDefinition( typeName, TestDataType.ROLE, typeFactory );
   
           final TypeLibraryDeployer typeDeployer = getTestDeployer();
   
  @@ -117,14 +118,15 @@
       public void testSingleConverter() throws Exception
       {
           // Create the type definition
  -        final String classname = TestConverter1.class.getName();
  +        final String converterName = "test-converter";
           final String source = "java.lang.String";
           final String destClass = TestType1.class.getName();
   
           final Map typeDefAttrs = new HashMap();
           typeDefAttrs.put( TypeDefinition.ATTRIBUTE_SOURCE_CLASS, source );
           typeDefAttrs.put( TypeDefinition.ATTRIBUTE_DESTINATION_CLASS, destClass );
  -        final TypeDefinition typeDef = new TypeDefinition( "test-converter", Converter.ROLE, classname, typeDefAttrs );
  +        final TypeFactory typeFactory = new DefaultTypeFactory( converterName, TestConverter1.class );
  +        final TypeDefinition typeDef = new TypeDefinition( converterName, Converter.ROLE, typeFactory, typeDefAttrs );
   
           final TypeLibraryDeployer typeDeployer = getTestDeployer();
   
  
  
  
  1.2       +1 -1      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test/ant-descriptor.xml
  
  Index: ant-descriptor.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test/ant-descriptor.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ant-descriptor.xml	17 Mar 2002 08:07:09 -0000	1.1
  +++ ant-descriptor.xml	22 May 2002 07:36:23 -0000	1.2
  @@ -2,7 +2,7 @@
   
       <types>
           <!-- Register a data-type -->
  -        <data-type name="test-type1"
  +        <test-data-type name="test-type1"
                      classname="org.apache.myrmidon.components.deployer.test.TestType1"/>
   
           <!-- Register a custom role implementation -->
  
  
  
  1.7       +3 -5      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/service/test/InstantiatingServiceManagerTestCase.java
  
  Index: InstantiatingServiceManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/service/test/InstantiatingServiceManagerTestCase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- InstantiatingServiceManagerTestCase.java	19 May 2002 10:50:31 -0000	1.6
  +++ InstantiatingServiceManagerTestCase.java	22 May 2002 07:36:23 -0000	1.7
  @@ -8,9 +8,8 @@
   package org.apache.myrmidon.components.service.test;
   
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.context.DefaultContext;
  +import org.apache.avalon.framework.service.ServiceException;
   import org.apache.myrmidon.components.AbstractComponentTest;
   import org.apache.myrmidon.components.service.InstantiatingServiceManager;
   import org.apache.myrmidon.interfaces.role.RoleInfo;
  @@ -23,7 +22,7 @@
    * Test cases for the default service manager.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.6 $ $Date: 2002/05/19 10:50:31 $
  + * @version $Revision: 1.7 $ $Date: 2002/05/22 07:36:23 $
    */
   public class InstantiatingServiceManagerTestCase
       extends AbstractComponentTest
  @@ -143,8 +142,7 @@
           // TODO - add stuff to TypeDeployer to do this instead
           final RoleRegistry roleRegistry = (RoleRegistry)getServiceManager().lookup( RoleRegistry.ROLE );
           roleRegistry.addRole( new RoleInfo( serviceRoleName, serviceType ) );
  -        final DefaultTypeFactory typeFactory = new DefaultTypeFactory( getClass().getClassLoader() );
  -        typeFactory.addNameClassMapping( serviceRoleName, factoryClass.getName() );
  +        final DefaultTypeFactory typeFactory = new DefaultTypeFactory( serviceRoleName, factoryClass );
           final TypeManager typeManager = (TypeManager)getServiceManager().lookup( TypeManager.ROLE );
           typeManager.registerType( ServiceFactory.ROLE, serviceRoleName, typeFactory );
       }
  
  
  
  1.4       +5 -6      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/type/test/DefaultTypeManagerTestCase.java
  
  Index: DefaultTypeManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/type/test/DefaultTypeManagerTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultTypeManagerTestCase.java	10 May 2002 01:44:48 -0000	1.3
  +++ DefaultTypeManagerTestCase.java	22 May 2002 07:36:23 -0000	1.4
  @@ -20,7 +20,7 @@
    * Test cases for the DefaultTypeManager
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.3 $ $Date: 2002/05/10 01:44:48 $
  + * @version $Revision: 1.4 $ $Date: 2002/05/22 07:36:23 $
    */
   public class DefaultTypeManagerTestCase
       extends AbstractComponentTest
  @@ -277,9 +277,9 @@
           final Class individualClass = TYPE_CLASS2;
   
           // Create a set of types to register (all names map to Type1).
  -        DefaultTypeFactory factory = new DefaultTypeFactory( groupClass.getClassLoader() );
  -        factory.addNameClassMapping( TYPE_NAME1, groupClass.getName() );
  -        factory.addNameClassMapping( TYPE_NAME2, groupClass.getName() );
  +        DefaultTypeFactory factory = new DefaultTypeFactory();
  +        factory.addNameClassMapping( TYPE_NAME1, groupClass );
  +        factory.addNameClassMapping( TYPE_NAME2, groupClass );
   
           // Register the factory
           m_typeManager.registerTypes( TEST_ROLE, groupNs, factory );
  @@ -333,8 +333,7 @@
                                  final Class type )
           throws TypeException
       {
  -        DefaultTypeFactory factory = new DefaultTypeFactory( type.getClassLoader() );
  -        factory.addNameClassMapping( typeName, type.getName() );
  +        DefaultTypeFactory factory = new DefaultTypeFactory( typeName, type );
   
           if( namespace == null )
           {
  
  
  
  1.4       +56 -23    jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/interfaces/type/test/TypeFactoryTestCase.java
  
  Index: TypeFactoryTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/interfaces/type/test/TypeFactoryTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TypeFactoryTestCase.java	6 May 2002 09:29:44 -0000	1.3
  +++ TypeFactoryTestCase.java	22 May 2002 07:36:23 -0000	1.4
  @@ -13,12 +13,15 @@
   import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
   import org.apache.myrmidon.interfaces.type.ReloadingTypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeException;
  +import org.apache.myrmidon.interfaces.type.ClassLoaderTypeFactory;
  +import org.apache.myrmidon.interfaces.type.TypeFactory;
  +import org.apache.avalon.excalibur.i18n.Resources;
   
   /**
    * These are unit tests that test the basic operation of TypeFactories.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.3 $ $Date: 2002/05/06 09:29:44 $
  + * @version $Revision: 1.4 $ $Date: 2002/05/22 07:36:23 $
    */
   public class TypeFactoryTestCase
       extends AbstractContainerTestCase
  @@ -36,28 +39,64 @@
       }
   
       /**
  -     * Make sure that you can load a basic type from DefaultTypeManager.
  +     * Test DefaultTypeFactory.
        */
  -    public void testBasicType()
  +    public void testDefaultTypeFactory()
  +        throws Exception
       {
  -        final ClassLoader classLoader = getClass().getClassLoader();
  -        final DefaultTypeFactory factory = new DefaultTypeFactory( classLoader );
  -        factory.addNameClassMapping( TYPE_NAME2, TYPE_CLASSNAME2 );
  +        // Make sure an instance of the expected class is created
  +        final DefaultTypeFactory factory = new DefaultTypeFactory();
  +        factory.addNameClassMapping( TYPE_NAME2, TYPE_CLASS2 );
  +
  +        final Object type = factory.create( TYPE_NAME2 );
  +        final Class typeClass = type.getClass();
  +        assertEquals( "The type loaded for factory should be same class as in current classloader",
  +                      typeClass, TYPE_CLASS2 );
   
  +        testUnknownType( factory );
  +    }
  +
  +    /**
  +     * Ensures that a type factory throws an exception when an unknown type
  +     * is requested.
  +     */
  +    private void testUnknownType( final TypeFactory factory )
  +    {
  +        final String typeName = "unknown-type";
  +        assertTrue( ! factory.canCreate( typeName ) );
           try
           {
  -            final Object type = factory.create( TYPE_NAME2 );
  -            final Class typeClass = type.getClass();
  -            assertEquals( "The type loaded for factory should be same class as in current classloader",
  -                          typeClass, TYPE_CLASS2 );
  +            factory.create( typeName );
  +            fail();
           }
           catch( TypeException e )
           {
  -            fail( "Unable to create Type due to " + e );
  +            final Resources res = getResourcesForTested( factory.getClass() );
  +            final String message = res.getString(  "no-mapping.error", typeName );
  +            assertSameMessage( message, e );
           }
       }
   
       /**
  +     * Test ClassLoaderTypeFactory.
  +     */
  +    public void testClassLoaderTypeFactory()
  +        throws Exception
  +    {
  +        // Check that an instance of the expected class is created
  +        final ClassLoader classLoader = getClass().getClassLoader();
  +        final ClassLoaderTypeFactory factory = new ClassLoaderTypeFactory( classLoader );
  +        factory.addNameClassMapping( TYPE_NAME2, TYPE_CLASSNAME2 );
  +
  +        final Object type = factory.create( TYPE_NAME2 );
  +        final Class typeClass = type.getClass();
  +        assertEquals( "The type loaded for factory should be same class as in current classloader",
  +                      typeClass, TYPE_CLASS2 );
  +
  +        testUnknownType( factory );
  +    }
  +
  +    /**
        * Make sure that when you load a type from a RelaodableTypeFactory
        * that it is actually reloaded.
        */
  @@ -69,17 +108,11 @@
           final ReloadingTypeFactory factory = new ReloadingTypeFactory( classpath, null );
           factory.addNameClassMapping( TYPE_NAME1, TYPE_CLASSNAME1 );
   
  -        try
  -        {
  -            final Object type = factory.create( TYPE_NAME1 );
  -            final Class typeClass = type.getClass();
  -            final boolean sameClass = typeClass == TYPE_CLASS1;
  -            assertTrue( "The type loaded for factory should not be same class as in current classloader",
  -                        !sameClass );
  -        }
  -        catch( TypeException e )
  -        {
  -            fail( "Unable to create Type due to " + e );
  -        }
  +        final Object type = factory.create( TYPE_NAME1 );
  +        final Class typeClass = type.getClass();
  +        assertTrue( "The type loaded for factory should not be same class as in current classloader",
  +                    typeClass != TYPE_CLASS1 );
  +
  +        testUnknownType( factory );
       }
   }
  
  
  
  1.8       +11 -28    jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/AbstractTypeDef.java
  
  Index: AbstractTypeDef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/AbstractTypeDef.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AbstractTypeDef.java	19 May 2002 08:28:59 -0000	1.7
  +++ AbstractTypeDef.java	22 May 2002 07:36:24 -0000	1.8
  @@ -13,18 +13,14 @@
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.framework.file.FileListUtil;
   import org.apache.myrmidon.framework.file.Path;
  -import org.apache.myrmidon.interfaces.deployer.Deployer;
  -import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  -import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
   import org.apache.myrmidon.interfaces.library.Library;
   import org.apache.myrmidon.interfaces.library.LibraryManager;
  -import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
   
   /**
    * Abstract task to extend to define a type.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.7 $ $Date: 2002/05/19 08:28:59 $
  + * @version $Revision: 1.8 $ $Date: 2002/05/22 07:36:24 $
    */
   public abstract class AbstractTypeDef
       extends AbstractContainerTask
  @@ -33,8 +29,7 @@
           ResourceManager.getPackageResources( AbstractTypeDef.class );
   
       private Path m_classpath = new Path();
  -    private String m_classname;
  -    private String m_namespace = null;
  +    protected String m_classname;
   
       public void setClassname( final String classname )
       {
  @@ -51,21 +46,6 @@
           m_classpath.add( path );
       }
   
  -    protected final String getClassname()
  -    {
  -        return m_classname;
  -    }
  -
  -    /**
  -     * Sets the namespace under which the type is registered.
  -     * This parameter is optional.
  -     * @param namespace
  -     */
  -    public void setNamespace( final String namespace )
  -    {
  -        m_namespace = namespace;
  -    }
  -
       /**
        * Executes the task.
        */
  @@ -79,15 +59,17 @@
               throw new TaskException( message );
           }
   
  +        if( m_classname == null )
  +        {
  +            final String message = REZ.getString( "typedef.no-classname.error" );
  +            throw new TaskException( message );
  +        }
  +
           try
           {
               final LibraryManager libraryManager = (LibraryManager)getService( LibraryManager.class );
               final Library library = libraryManager.createLibrary( classpath );
  -
  -            final Deployer deployer = (Deployer)getService( Deployer.class );
  -            final TypeLibraryDeployer typeDeployer = deployer.createDeployer( library, m_namespace );
  -            final TypeDefinition typeDef = createTypeDefinition();
  -            typeDeployer.deployType( typeDef );
  +            createTypeDefinition( library );
           }
           catch( final Exception e )
           {
  @@ -98,5 +80,6 @@
       /**
        * Creates the definition for the type to be deployed.
        */
  -    protected abstract TypeDefinition createTypeDefinition();
  +    protected abstract void createTypeDefinition( final Library library )
  +        throws Exception;
   }
  
  
  
  1.4       +4 -4      jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/DataTypeDeployer.java
  
  Index: DataTypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/DataTypeDeployer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DataTypeDeployer.java	18 May 2002 04:15:09 -0000	1.3
  +++ DataTypeDeployer.java	22 May 2002 07:36:24 -0000	1.4
  @@ -19,7 +19,7 @@
    * task with the same name.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.3 $ $Date: 2002/05/18 04:15:09 $
  + * @version $Revision: 1.4 $ $Date: 2002/05/22 07:36:24 $
    */
   public class DataTypeDeployer
       extends DefaultTypeDeployer
  @@ -31,15 +31,15 @@
        * Deploys a type.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDefinition,
  -                            final TypeFactory typeFactory )
  +                            final TypeDefinition typeDefinition )
           throws Exception
       {
           // Register the type itself
  -        super.deployType( namespace, typeDefinition, typeFactory );
  +        super.deployType( namespace, typeDefinition );
   
           // Register the instantiating task
           final String name = typeDefinition.getName();
  +        final TypeFactory typeFactory = typeDefinition.getFactory();
           m_factory.addMapping( name, typeFactory );
           getTypeManager().registerType( Task.ROLE, namespace, name, m_factory );
       }
  
  
  
  1.3       +1 -0      jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/Resources.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Resources.properties	9 May 2002 07:37:12 -0000	1.2
  +++ Resources.properties	22 May 2002 07:36:24 -0000	1.3
  @@ -7,6 +7,7 @@
   container.unknown-role-type.error=Could not determine the role for class "{0}".
   
   typedef.no-lib.error=Must specify a classpath.
  +typedef.no-classname.error=No classname specified.
   
   condition.no-resolve.error=Error resolving {0}.
   
  
  
  
  1.2       +4 -4      jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener/ProjectListenerDeployer.java
  
  Index: ProjectListenerDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener/ProjectListenerDeployer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProjectListenerDeployer.java	18 May 2002 04:19:34 -0000	1.1
  +++ ProjectListenerDeployer.java	22 May 2002 07:36:24 -0000	1.2
  @@ -18,7 +18,7 @@
    * ProjectListener, and a TaskListener.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.1 $ $Date: 2002/05/18 04:19:34 $
  + * @version $Revision: 1.2 $ $Date: 2002/05/22 07:36:24 $
    */
   public class ProjectListenerDeployer
       extends DefaultTypeDeployer
  @@ -29,15 +29,15 @@
        * Deploys a type.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDefinition,
  -                            final TypeFactory typeFactory )
  +                            final TypeDefinition typeDefinition )
           throws Exception
       {
           // Register the listener as a ProjectListener
  -        super.deployType( namespace, typeDefinition, typeFactory );
  +        super.deployType( namespace, typeDefinition );
   
           // Register the listener as a TaskListener
           final String typeName = typeDefinition.getName();
  +        final TypeFactory typeFactory = typeDefinition.getFactory();
           m_factory.addMapping( typeName, typeFactory );
           getTypeManager().registerType( TaskListener.ROLE, namespace, typeDefinition.getName(), m_factory );
       }
  
  
  

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