ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/runtime Facility.java
Date Thu, 14 Feb 2002 10:21:12 GMT
donaldp     02/02/14 02:21:12

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/framework
                        TypeInstanceTask.java Resources.properties
                        AbstractContainerTask.java
               proposal/myrmidon/src/java/org/apache/antlib/core
                        Property.java
               proposal/myrmidon/src/java/org/apache/antlib/runtime
                        Facility.java
  Log:
  Added a newInstance method to AbstractContainerTask to make it easier to create instances
of a role with a specific type
  
  Revision  Changes    Path
  1.12      +2 -4      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/TypeInstanceTask.java
  
  Index: TypeInstanceTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/TypeInstanceTask.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TypeInstanceTask.java	7 Feb 2002 13:01:02 -0000	1.11
  +++ TypeInstanceTask.java	14 Feb 2002 10:21:12 -0000	1.12
  @@ -15,13 +15,12 @@
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.myrmidon.interfaces.type.TypeFactory;
   
   /**
    * 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.11 $ $Date: 2002/02/07 13:01:02 $
  + * @version $Revision: 1.12 $ $Date: 2002/02/14 10:21:12 $
    */
   public class TypeInstanceTask
       extends AbstractContainerTask
  @@ -64,8 +63,7 @@
   
           try
           {
  -            final TypeFactory typeFactory = getTypeFactory( DataType.class );
  -            m_value = typeFactory.create( configuration.getName() );
  +            m_value = newInstance( DataType.class, configuration.getName() );
           }
           catch( final Exception e )
           {
  
  
  
  1.6       +1 -0      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Resources.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Resources.properties	2 Feb 2002 12:51:59 -0000	1.5
  +++ Resources.properties	14 Feb 2002 10:21:12 -0000	1.6
  @@ -2,6 +2,7 @@
   container.bad-resolve.error=Error resolving value ({0}).
   container.bad-config.error=Error converting value.
   container.no-factory.error=Could not locate the type factory for type "{0}".
  +container.no-create-type.error=Could not create instance of role "{0}" with type name "{1}".
   
   typedef.no-lib.error=Must specify the lib parameter.
   
  
  
  
  1.15      +22 -1     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java
  
  Index: AbstractContainerTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractContainerTask.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AbstractContainerTask.java	7 Feb 2002 13:01:02 -0000	1.14
  +++ AbstractContainerTask.java	14 Feb 2002 10:21:12 -0000	1.15
  @@ -27,7 +27,7 @@
    * This is the class that Task writers should extend to provide custom tasks.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.14 $ $Date: 2002/02/07 13:01:02 $
  + * @version $Revision: 1.15 $ $Date: 2002/02/14 10:21:12 $
    */
   public abstract class AbstractContainerTask
       extends AbstractTask
  @@ -105,6 +105,27 @@
           throws ConfigurationException
       {
           getConfigurer().configure( object, name, value, getContext() );
  +    }
  +
  +    /**
  +     * Create an instance of type with specified type and in specified role.
  +     */
  +    protected final Object newInstance( final Class roleType, final String typeName )
  +        throws TaskException
  +    {
  +        final TypeFactory typeFactory = getTypeFactory( roleType );
  +        try
  +        {
  +            return typeFactory.create( typeName );
  +        }
  +        catch( final TypeException te )
  +        {
  +            final String message =
  +                REZ.getString( "container.no-create-type.error",
  +                               roleType.getName(),
  +                               typeName );
  +            throw new TaskException( message, te );
  +        }
       }
   
       /**
  
  
  
  1.9       +3 -3      jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/core/Property.java
  
  Index: Property.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/core/Property.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Property.java	1 Feb 2002 00:37:58 -0000	1.8
  +++ Property.java	14 Feb 2002 10:21:12 -0000	1.9
  @@ -24,7 +24,7 @@
    * TODO: Determine final format of property task.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.8 $ $Date: 2002/02/01 00:37:58 $
  + * @version $Revision: 1.9 $ $Date: 2002/02/14 10:21:12 $
    * @ant:task name="property"
    */
   public class Property
  @@ -54,8 +54,8 @@
           {
               try
               {
  -                final TypeFactory typeFactory = getTypeFactory( DataType.class );
  -                final DataType value = (DataType)typeFactory.create( children[ i ].getName()
);
  +                final String typeName = children[ i ].getName();
  +                final DataType value = (DataType)newInstance( DataType.class, typeName
);
                   configure( value, children[ i ] );
                   setValue( value );
               }
  
  
  
  1.8       +3 -3      jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/runtime/Facility.java
  
  Index: Facility.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/runtime/Facility.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Facility.java	2 Feb 2002 15:44:04 -0000	1.7
  +++ Facility.java	14 Feb 2002 10:21:12 -0000	1.8
  @@ -49,15 +49,15 @@
   
           if( 1 == children.length )
           {
  +            final String typeName = children[ 0 ].getName();
               try
               {
  -                final TypeFactory typeFactory = getTypeFactory( AspectHandler.class );
  -                m_aspectHandler = (AspectHandler)typeFactory.create( children[ 0 ].getName()
);
  +                m_aspectHandler = (AspectHandler)newInstance( AspectHandler.class, typeName
);
               }
               catch( final Exception e )
               {
                   final String message =
  -                    REZ.getString( "facility.no-create.error", children[ 0 ].getName()
);
  +                    REZ.getString( "facility.no-create.error", typeName );
                   throw new ConfigurationException( message, e );
               }
   
  
  
  

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