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/myrmidon/components/configurer Resources.properties PropertyConfigurer.java DefaultPropertyConfigurer.java DefaultObjectConfigurer.java DefaultConfigurer.java
Date Tue, 05 Mar 2002 08:44:14 GMT
donaldp     02/03/05 00:44:14

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer
                        Resources.properties PropertyConfigurer.java
                        DefaultPropertyConfigurer.java
                        DefaultObjectConfigurer.java DefaultConfigurer.java
  Log:
  Remove support for creators
  
  Revision  Changes    Path
  1.16      +0 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/Resources.properties,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Resources.properties	26 Feb 2002 23:21:07 -0000	1.15
  +++ Resources.properties	5 Mar 2002 08:44:14 -0000	1.16
  @@ -3,10 +3,8 @@
   mismatch-ref-types.error=Could not convert reference "{0}" to the type expected for property
"{1}".
   incompatible-element-types.error=Incompatible creator and adder/setter methods found in
class {0} for property "{1}".
   multiple-adder-methods-for-element.error=Multiple add{1}() or set{1}() methods found in
class {0}.
  -multiple-creator-methods-for-element.error=Multiple {1}() methods found in class {0}.
   multiple-content-setter-methods.error=Multiple content setter methods found in class {0}.
   pending-property-value.error=An object created using the creator method has not been set
using the adder/setter method.
  -must-be-element.error=This property must be configured using a nested element.
   too-many-values.error=Too many values for this property.
   no-complex-type.error=Can not get complex type for non-primitive type {0}.
   no-such-attribute.error=Element <{0}> does not support attribute "{1}".
  
  
  
  1.5       +1 -14     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/PropertyConfigurer.java
  
  Index: PropertyConfigurer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/PropertyConfigurer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PropertyConfigurer.java	24 Feb 2002 07:43:37 -0000	1.4
  +++ PropertyConfigurer.java	5 Mar 2002 08:44:14 -0000	1.5
  @@ -14,7 +14,7 @@
    * TODO - axe createValue().
    *
    * @author <a href="mailto:adammurdoch_ml@yahoo.com">Adam Murdoch</a>
  - * @version $Revision: 1.4 $ $Date: 2002/02/24 07:43:37 $
  + * @version $Revision: 1.5 $ $Date: 2002/03/05 08:44:14 $
    */
   interface PropertyConfigurer
   {
  @@ -22,19 +22,6 @@
        * Returns the type of this property.
        */
       Class getType();
  -
  -    /**
  -     * Creates a default value for this property.  This value must be configured,
  -     * and then attached to the object using {@link #addValue}.
  -     *
  -     * @param state The state object, representing the object being configured.
  -     * @return An object which is assignable to the type returned by
  -     *         {@link #getType}.  Returns null if this property does not
  -     *         need a default value.
  -     * @throws ConfigurationException If the object cannot be created.
  -     */
  -    Object createValue( ConfigurationState state )
  -        throws ConfigurationException;
   
       /**
        * Adds a value for this property, to an object.
  
  
  
  1.5       +1 -49     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultPropertyConfigurer.java
  
  Index: DefaultPropertyConfigurer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultPropertyConfigurer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultPropertyConfigurer.java	27 Jan 2002 23:36:55 -0000	1.4
  +++ DefaultPropertyConfigurer.java	5 Mar 2002 08:44:14 -0000	1.5
  @@ -18,7 +18,7 @@
    * create and set property values.
    *
    * @author <a href="mailto:adammurdoch_ml@yahoo.com">Adam Murdoch</a>
  - * @version $Revision: 1.4 $ $Date: 2002/01/27 23:36:55 $
  + * @version $Revision: 1.5 $ $Date: 2002/03/05 08:44:14 $
    */
   class DefaultPropertyConfigurer
       implements PropertyConfigurer
  @@ -28,13 +28,11 @@
   
       private final int m_propIndex;
       private final Class m_type;
  -    private final Method m_createMethod;
       private final Method m_addMethod;
       private final int m_maxCount;
   
       public DefaultPropertyConfigurer( final int propIndex,
                                         final Class type,
  -                                      final Method createMethod,
                                         final Method addMethod,
                                         final int maxCount )
       {
  @@ -47,7 +45,6 @@
           {
               m_type = type;
           }
  -        m_createMethod = createMethod;
           m_addMethod = addMethod;
           m_maxCount = maxCount;
       }
  @@ -61,44 +58,6 @@
       }
   
       /**
  -     * Creates a default value for this property.
  -     */
  -    public Object createValue( final ConfigurationState state )
  -        throws ConfigurationException
  -    {
  -        if( null == m_createMethod )
  -        {
  -            return null;
  -        }
  -
  -        final DefaultConfigurationState defState = (DefaultConfigurationState)state;
  -
  -        // Make sure there isn't a pending object for this property
  -        if( defState.getCreatedObject( m_propIndex ) != null )
  -        {
  -            final String message = REZ.getString( "pending-property-value.error" );
  -            throw new ConfigurationException( message );
  -        }
  -
  -        try
  -        {
  -            // Create the value
  -            final Object object = m_createMethod.invoke( defState.getObject(), null );
  -            defState.setCreatedObject( m_propIndex, object );
  -            return object;
  -        }
  -        catch( final InvocationTargetException ite )
  -        {
  -            final Throwable cause = ite.getTargetException();
  -            throw new ConfigurationException( cause.getMessage(), cause );
  -        }
  -        catch( final Exception e )
  -        {
  -            throw new ConfigurationException( e.getMessage(), e );
  -        }
  -    }
  -
  -    /**
        * Adds a value for this property, to an object.
        */
       public void addValue( final ConfigurationState state, final Object value )
  @@ -110,13 +69,6 @@
           final Object pending = defState.getCreatedObject( m_propIndex );
           if( pending != null && pending != value )
           {
  -        }
  -
  -        // Make sure the creator method was called, if necessary
  -        if( pending == null && m_createMethod != null )
  -        {
  -            final String message = REZ.getString( "must-be-element.error" );
  -            throw new ConfigurationException( message );
           }
   
           defState.setCreatedObject( m_propIndex, null );
  
  
  
  1.13      +4 -77     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultObjectConfigurer.java
  
  Index: DefaultObjectConfigurer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultObjectConfigurer.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultObjectConfigurer.java	24 Feb 2002 07:43:37 -0000	1.12
  +++ DefaultObjectConfigurer.java	5 Mar 2002 08:44:14 -0000	1.13
  @@ -12,11 +12,9 @@
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.HashMap;
  -import java.util.HashSet;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  -import java.util.Set;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  @@ -26,7 +24,7 @@
    * of a class.
    *
    * @author <a href="mailto:adammurdoch_ml@yahoo.com">Adam Murdoch</a>
  - * @version $Revision: 1.12 $ $Date: 2002/02/24 07:43:37 $
  + * @version $Revision: 1.13 $ $Date: 2002/03/05 08:44:14 $
    */
   class DefaultObjectConfigurer
       implements ObjectConfigurer
  @@ -72,58 +70,28 @@
       public void enableAll()
           throws ConfigurationException
       {
  -        // TODO - get rid of creators
           enableProperties();
           enableContent();
       }
   
       /**
  -     * Enables all creators + adders.
  +     * Enables all adders.
        */
       private void enableProperties()
           throws ConfigurationException
       {
  -        final Map creators = findCreators();
           final Map adders = findAdders();
   
           // Add the elements
  -        final Set elemNames = new HashSet();
  -        elemNames.addAll( creators.keySet() );
  -        elemNames.addAll( adders.keySet() );
   
  -        final Iterator iterator = elemNames.iterator();
  +        final Iterator iterator = adders.keySet().iterator();
           while( iterator.hasNext() )
           {
               final String propName = (String)iterator.next();
  -            final Method createMethod = (Method)creators.get( propName );
               final Method addMethod = (Method)adders.get( propName );
   
               // Determine and check the return type
  -            Class type;
  -            if( createMethod != null && addMethod != null )
  -            {
  -                // Make sure the add method is more general than the create
  -                // method
  -                type = createMethod.getReturnType();
  -                final Class addType = addMethod.getParameterTypes()[ 0 ];
  -                if( !addType.isAssignableFrom( type ) )
  -                {
  -                    final String message =
  -                        REZ.getString( "incompatible-element-types.error",
  -                                       m_class.getName(),
  -                                       propName );
  -                    throw new ConfigurationException( message );
  -                }
  -            }
  -            else if( createMethod != null )
  -            {
  -                type = createMethod.getReturnType();
  -            }
  -            else
  -            {
  -                type = addMethod.getParameterTypes()[ 0 ];
  -            }
  -
  +            final Class type = addMethod.getParameterTypes()[ 0 ];
               final boolean isTypedProp = ( propName.length() == 0 );
               if( isTypedProp && !type.isInterface() )
               {
  @@ -144,7 +112,6 @@
               final DefaultPropertyConfigurer configurer =
                   new DefaultPropertyConfigurer( m_allProps.size(),
                                                  type,
  -                                               createMethod,
                                                  addMethod,
                                                  maxCount );
               m_allProps.add( configurer );
  @@ -225,45 +192,6 @@
       }
   
       /**
  -     * Find all 'create' methods, which return a non-primitive type,
  -     *  and take no parameters.
  -     */
  -    private Map findCreators()
  -        throws ConfigurationException
  -    {
  -        final Map creators = new HashMap();
  -        final List methodSet = new ArrayList();
  -        findMethodsWithPrefix( "create", methodSet );
  -
  -        final Iterator iterator = methodSet.iterator();
  -        while( iterator.hasNext() )
  -        {
  -            final Method method = (Method)iterator.next();
  -            final String methodName = method.getName();
  -            if( method.getReturnType().isPrimitive() ||
  -                method.getParameterTypes().length != 0 )
  -            {
  -                continue;
  -            }
  -
  -            // Extract element name
  -            final String elemName = extractName( 6, methodName );
  -
  -            // Add to the creators map
  -            if( creators.containsKey( elemName ) )
  -            {
  -                final String message =
  -                    REZ.getString( "multiple-creator-methods-for-element.error",
  -                                   m_class.getName(),
  -                                   methodName );
  -                throw new ConfigurationException( message );
  -            }
  -            creators.put( elemName, method );
  -        }
  -        return creators;
  -    }
  -
  -    /**
        * Enables content.
        */
       private void enableContent()
  @@ -300,7 +228,6 @@
               m_contentConfigurer =
                   new DefaultPropertyConfigurer( m_allProps.size(),
                                                  type,
  -                                               null,
                                                  method,
                                                  1 );
               m_allProps.add( m_contentConfigurer );
  
  
  
  1.36      +10 -13    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultConfigurer.java
  
  Index: DefaultConfigurer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultConfigurer.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- DefaultConfigurer.java	3 Mar 2002 07:30:38 -0000	1.35
  +++ DefaultConfigurer.java	5 Mar 2002 08:44:14 -0000	1.36
  @@ -33,7 +33,7 @@
    * Class used to configure tasks.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.35 $ $Date: 2002/03/03 07:30:38 $
  + * @version $Revision: 1.36 $ $Date: 2002/03/05 08:44:14 $
    * @ant:type type="configurer" name="default"
    */
   public class DefaultConfigurer
  @@ -459,19 +459,16 @@
           }
   
           // Create an instance
  -        Object child = childConfigurer.createValue( state );
  -        if( null == child )
  +        Object child = null;
  +        if( childConfigurer == state.getConfigurer().getTypedProperty() )
           {
  -            if( childConfigurer == state.getConfigurer().getTypedProperty() )
  -            {
  -                // Typed property
  -                child = createTypedObject( name, type );
  -            }
  -            else
  -            {
  -                // Named property
  -                child = createNamedObject( type );
  -            }
  +            // Typed property
  +            child = createTypedObject( name, type );
  +        }
  +        else
  +        {
  +            // Named property
  +            child = createNamedObject( type );
           }
   
           // Configure the object
  
  
  

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