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 DataTypeDeployer.java TypeInstanceTask.java TypeInstanceTaskFactory.java
Date Sat, 18 May 2002 04:15:09 GMT
adammurdoch    02/05/17 21:15:09

  Modified:    framework/src/java/org/apache/myrmidon/framework
                        DataTypeDeployer.java TypeInstanceTask.java
  Removed:     framework/src/java/org/apache/myrmidon/framework
                        TypeInstanceTaskFactory.java
  Log:
  Use AdaptingTypeFactory instead of a custom type factory for creating TypeInstanceTask
  instances.  This moves responsibility for creating the data type instance out of
  TypeInstanceTask, which makes it reuseable for any role.
  
  Revision  Changes    Path
  1.3       +8 -6      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DataTypeDeployer.java	8 May 2002 04:10:27 -0000	1.2
  +++ DataTypeDeployer.java	18 May 2002 04:15:09 -0000	1.3
  @@ -7,25 +7,25 @@
    */
   package org.apache.myrmidon.framework;
   
  +import org.apache.myrmidon.api.Task;
   import org.apache.myrmidon.interfaces.deployer.DefaultTypeDeployer;
  -import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  +import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
  +import org.apache.myrmidon.interfaces.type.AdaptingTypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
  -import org.apache.myrmidon.framework.TypeInstanceTaskFactory;
  -import org.apache.myrmidon.api.Task;
   
   /**
    * A deployer for data-types.  Registers the type, and an instantiating
    * task with the same name.
    *
    * @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/18 04:15:09 $
    */
   public class DataTypeDeployer
       extends DefaultTypeDeployer
       implements TypeDeployer
   {
  -    private TypeInstanceTaskFactory m_factory = new TypeInstanceTaskFactory();
  +    private AdaptingTypeFactory m_factory = new AdaptingTypeFactory( TypeInstanceTask.class
);
   
       /**
        * Deploys a type.
  @@ -39,6 +39,8 @@
           super.deployType( namespace, typeDefinition, typeFactory );
   
           // Register the instantiating task
  -        getTypeManager().registerType( Task.ROLE, namespace, typeDefinition.getName(),
m_factory );
  +        final String name = typeDefinition.getName();
  +        m_factory.addMapping( name, typeFactory );
  +        getTypeManager().registerType( Task.ROLE, namespace, name, m_factory );
       }
   }
  
  
  
  1.3       +13 -40    jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/TypeInstanceTask.java
  
  Index: TypeInstanceTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/TypeInstanceTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeInstanceTask.java	21 Apr 2002 01:58:52 -0000	1.2
  +++ TypeInstanceTask.java	18 May 2002 04:15:09 -0000	1.3
  @@ -13,12 +13,13 @@
   import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.api.metadata.ModelException;
   import org.apache.myrmidon.api.metadata.Modeller;
  +import org.apache.myrmidon.interfaces.model.ModelElementUtil;
   
   /**
    * This is the property "task" to declare a binding of a datatype to a name.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.2 $ $Date: 2002/04/21 01:58:52 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/18 04:15:09 $
    */
   public class TypeInstanceTask
       extends AbstractContainerTask
  @@ -28,55 +29,27 @@
           ResourceManager.getPackageResources( TypeInstanceTask.class );
   
       private String m_id;
  -    private Object m_value;
  +    private final Object m_value;
  +
  +    public TypeInstanceTask( final Object value )
  +    {
  +        m_value = value;
  +    }
   
       public void model( final ModelElement model )
           throws ModelException
       {
  -        final ModelElement newElement =
  -            new ModelElement( model.getName(), model.getLocation() );
  +        // Configure self
  +        m_id = model.getAttribute( "id" );
   
  -        final String[] attributes = model.getAttributeNames();
  -        for( int i = 0; i < attributes.length; i++ )
  -        {
  -            final String name = attributes[ i ];
  -            final String value = model.getAttribute( name );
  -
  -            if( name.equals( "id" ) || name.equals( "local-scope" ) )
  -            {
  -                configureAttribute( this, name, value );
  -            }
  -            else
  -            {
  -                newElement.setAttribute( name, value );
  -            }
  -        }
  -
  -        final ModelElement[] children = model.getChildren();
  -        for( int i = 0; i < children.length; i++ )
  -        {
  -            newElement.addChild( children[ i ] );
  -        }
  -
  -        try
  -        {
  -            m_value = newInstance( DataType.ROLE, model.getName() );
  -        }
  -        catch( final Exception e )
  -        {
  -            final String message = REZ.getString( "type.no-create.error" );
  -            throw new ModelException( message, e );
  -        }
  +        // Build model for the value
  +        final ModelElement newElement = ModelElementUtil.copyModel( model );
  +        newElement.setAttribute( "id", null );
   
           //Make sure we make the element read only prior
           //to configuration
           newElement.makeReadOnly();
           configureElement( m_value, newElement );
  -    }
  -
  -    public void setId( final String id )
  -    {
  -        m_id = id;
       }
   
       public void execute()
  
  
  

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