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 AbstractTypeDef.java
Date Sun, 19 May 2002 08:28:59 GMT
adammurdoch    02/05/19 01:28:59

  Modified:    antlib/src/java/org/apache/antlib/runtime ConverterDef.java
               container/src/java/org/apache/myrmidon/components/deployer
                        ConverterTypeDeployer.java
                        TypeDescriptorBuilder.java
               container/src/java/org/apache/myrmidon/interfaces/deployer
                        TypeDefinition.java
               container/src/test/org/apache/myrmidon/components/deployer/test
                        DefaultDeployerTestCase.java
               framework/src/java/org/apache/myrmidon/framework
                        AbstractTypeDef.java
  Removed:     container/src/java/org/apache/myrmidon/interfaces/deployer
                        ConverterDefinition.java
  Log:
  * Added TypeDefinition.getAttributes(), to allow meta-info to be attached
    to a type definition.  This gets populated with the attributes of the
    type definition in the antlib descriptor.
  
  * Removed ConverterDefinition, use TypeDefinition instead.
  
  Revision  Changes    Path
  1.2       +8 -2      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConverterDef.java	14 Apr 2002 10:55:08 -0000	1.1
  +++ ConverterDef.java	19 May 2002 08:28:59 -0000	1.2
  @@ -7,8 +7,10 @@
    */
   package org.apache.antlib.runtime;
   
  +import java.util.HashMap;
  +import java.util.Map;
  +import org.apache.aut.converter.Converter;
   import org.apache.myrmidon.framework.AbstractTypeDef;
  -import org.apache.myrmidon.interfaces.deployer.ConverterDefinition;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   
   /**
  @@ -41,6 +43,10 @@
   
       protected TypeDefinition createTypeDefinition()
       {
  -        return new ConverterDefinition( getClassname(), m_sourceType, m_destinationType
);
  +        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 );
       }
   }
  
  
  
  1.5       +9 -11     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ConverterTypeDeployer.java	8 May 2002 04:10:26 -0000	1.4
  +++ ConverterTypeDeployer.java	19 May 2002 08:28:59 -0000	1.5
  @@ -7,24 +7,23 @@
    */
   package org.apache.myrmidon.components.deployer;
   
  -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;
  -import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  -import org.apache.myrmidon.interfaces.deployer.ConverterDefinition;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
   import org.apache.myrmidon.interfaces.deployer.DefaultTypeDeployer;
  +import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
  -import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
   
   /**
    * 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.4 $ $Date: 2002/05/08 04:10:26 $
  + * @version $Revision: 1.5 $ $Date: 2002/05/19 08:28:59 $
    */
   class ConverterTypeDeployer
       extends DefaultTypeDeployer
  @@ -51,10 +50,9 @@
           throws Exception
       {
           // Add the converter to the converter registry
  -        final ConverterDefinition converterDefinition = (ConverterDefinition)typeDefinition;
  -        final String name = converterDefinition.getName();
  -        final String source = converterDefinition.getSourceType();
  -        final String destination = converterDefinition.getDestinationType();
  +        final String name = typeDefinition.getName();
  +        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 )
           {
               final String message = REZ.getString( "converterdef.no-source.error" );
  
  
  
  1.7       +12 -17    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TypeDescriptorBuilder.java	21 Apr 2002 02:06:25 -0000	1.6
  +++ TypeDescriptorBuilder.java	19 May 2002 08:28:59 -0000	1.7
  @@ -7,12 +7,12 @@
    */
   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.avalon.framework.configuration.ConfigurationException;
  -import org.apache.myrmidon.interfaces.deployer.ConverterDefinition;
   import org.apache.myrmidon.interfaces.deployer.DeploymentException;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   
  @@ -20,7 +20,7 @@
    * Builds typelib type descriptors.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.6 $ $Date: 2002/04/21 02:06:25 $
  + * @version $Revision: 1.7 $ $Date: 2002/05/19 08:28:59 $
    */
   class TypeDescriptorBuilder
       implements DescriptorBuilder
  @@ -87,23 +87,18 @@
        * Creates a type definition.
        */
       private TypeDefinition createTypeDefinition( final Configuration element )
  -        throws ConfigurationException
  +        throws Exception
       {
           final String roleShorthand = element.getName();
  -        if( roleShorthand.equals( "converter" ) )
  +        final String typeName = element.getAttribute( "name", null );
  +        final String className = element.getAttribute( "classname", null );
  +        final String[] attributes = element.getAttributeNames();
  +        final Map attrs = new HashMap();
  +        for( int i = 0; i < attributes.length; i++ )
           {
  -            // A converter definition
  -            final String className = element.getAttribute( "classname" );
  -            final String source = element.getAttribute( "source" );
  -            final String destination = element.getAttribute( "destination" );
  -            return new ConverterDefinition( className, source, destination );
  -        }
  -        else
  -        {
  -            // A type definition
  -            final String typeName = element.getAttribute( "name" );
  -            final String className = element.getAttribute( "classname" );
  -            return new TypeDefinition( typeName, roleShorthand, className );
  +            final String name = attributes[ i ];
  +            attrs.put( name, element.getAttribute( name ) );
           }
  +        return new TypeDefinition( typeName, roleShorthand, className, attrs );
       }
   }
  
  
  
  1.6       +49 -2     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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TypeDefinition.java	24 Apr 2002 02:21:00 -0000	1.5
  +++ TypeDefinition.java	19 May 2002 08:28:59 -0000	1.6
  @@ -7,17 +7,25 @@
    */
   package org.apache.myrmidon.interfaces.deployer;
   
  +import java.util.Map;
  +import java.util.HashMap;
  +import java.util.Collections;
  +
   /**
    * A general-purpose type definition.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.5 $ $Date: 2002/04/24 02:21:00 $
  + * @version $Revision: 1.6 $ $Date: 2002/05/19 08:28:59 $
    */
   public class TypeDefinition
   {
  +    public static final String ATTRIBUTE_SOURCE_CLASS = "source";
  +    public static final String ATTRIBUTE_DESTINATION_CLASS = "destination";
  +
       private final String m_name;
       private final String m_role;
       private final String m_classname;
  +    private final Map m_attributes ;
   
       /**
        * Creates a TypeDefinition
  @@ -29,9 +37,40 @@
                              final String role,
                              final String className )
       {
  -        m_name = name;
  +        this( name, role, className, 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
  +     */
  +    public TypeDefinition( final String name,
  +                           final String role,
  +                           final String className,
  +                           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_role = role;
           m_classname = className;
  +        if( attributes != null && attributes.size() > 0 )
  +        {
  +            // TODO - make read only
  +            m_attributes = new HashMap( attributes );
  +        }
  +        else
  +        {
  +            m_attributes = Collections.EMPTY_MAP;
  +        }
       }
   
       /**
  @@ -56,5 +95,13 @@
       public String getName()
       {
           return m_name;
  +    }
  +
  +    /**
  +     * @return the type's attributes.
  +     */
  +    public Map getAttributes()
  +    {
  +        return m_attributes;
       }
   }
  
  
  
  1.11      +7 -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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultDeployerTestCase.java	17 May 2002 07:43:47 -0000	1.10
  +++ DefaultDeployerTestCase.java	19 May 2002 08:28:59 -0000	1.11
  @@ -8,21 +8,22 @@
   package org.apache.myrmidon.components.deployer.test;
   
   import java.io.File;
  +import java.util.HashMap;
  +import java.util.Map;
   import org.apache.aut.converter.Converter;
   import org.apache.aut.converter.ConverterException;
   import org.apache.myrmidon.components.AbstractComponentTest;
   import org.apache.myrmidon.components.TestDataType;
   import org.apache.myrmidon.components.deployer.DefaultDeployer;
  -import org.apache.myrmidon.interfaces.deployer.ConverterDefinition;
   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.role.RoleInfo;
   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.role.RoleInfo;
   
   /**
    * Test cases for the default deployer.
  @@ -120,8 +121,10 @@
           final String source = "java.lang.String";
           final String destClass = TestType1.class.getName();
   
  -        final ConverterDefinition typeDef =
  -            new ConverterDefinition( classname, source, destClass );
  +        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 TypeLibraryDeployer typeDeployer = getTestDeployer();
   
  
  
  
  1.7       +3 -3      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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractTypeDef.java	12 May 2002 12:57:54 -0000	1.6
  +++ AbstractTypeDef.java	19 May 2002 08:28:59 -0000	1.7
  @@ -18,14 +18,13 @@
   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.
    *
  - * TODO: Make this support classpath sub-element in future
  - *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.6 $ $Date: 2002/05/12 12:57:54 $
  + * @version $Revision: 1.7 $ $Date: 2002/05/19 08:28:59 $
    */
   public abstract class AbstractTypeDef
       extends AbstractContainerTask
  @@ -84,6 +83,7 @@
           {
               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();
  
  
  

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