jsalvata    2004/01/04 03:30:06

  Modified:    src/core/org/apache/jmeter/testbeans Tag:
                        testbeans_experimental_branch TestBean.java
  Log:
  Initialize only those properties that were defined by the GUI.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.6   +17 -8     
jakarta-jmeter/src/core/org/apache/jmeter/testbeans/Attic/TestBean.java
  
  Index: TestBean.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testbeans/Attic/TestBean.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- TestBean.java     4 Jan 2004 01:44:44 -0000       1.1.2.5
  +++ TestBean.java     4 Jan 2004 11:30:06 -0000       1.1.2.6
  @@ -62,6 +62,8 @@
   import java.beans.Introspector;
   import java.beans.PropertyDescriptor;
   import java.lang.reflect.InvocationTargetException;
  +import java.util.HashMap;
  +import java.util.Map;
   
   import org.apache.jmeter.control.NextIsNullException;
   import org.apache.jmeter.samplers.Sampler;
  @@ -93,9 +95,9 @@
   public abstract class TestBean extends AbstractTestElement
   {
       /**
  -     * Property name String to property setter method map.
  +     * Property name to property descriptor method map.
        */
  -    private static PropertyDescriptor[] descriptors= null;
  +    private static Map descriptors= null;
   
       
       /**
  @@ -112,9 +114,15 @@
           {
               try
               {
  +             // Obtain the property descriptors:
                   BeanInfo beanInfo= Introspector.getBeanInfo(this.getClass(),
                       TestBean.class);
  -                descriptors= beanInfo.getPropertyDescriptors();
  +                PropertyDescriptor[] desc= beanInfo.getPropertyDescriptors();
  +                descriptors= new HashMap();
  +                for (int i=0; i<desc.length; i++)
  +                {
  +                     descriptors.put(desc[i].getName(), desc[i]);
  +                }
               }
               catch (IntrospectionException e)
               {
  @@ -136,11 +144,12 @@
       {
           Object[] param= new Object[1];
           
  -        for (int i=0; i<descriptors.length; i++)
  +        for (PropertyIterator i= propertyIterator(); i.hasNext(); )
           {
               // Obtain a value of the appropriate type for this property. 
  -            JMeterProperty property= getProperty(descriptors[i].getName());
  -            Class type= descriptors[i].getPropertyType();
  +            JMeterProperty property= i.next();
  +            PropertyDescriptor descriptor= 
(PropertyDescriptor)descriptors.get(property.getName()); 
  +            Class type= descriptor.getPropertyType();
               Object value= unwrapProperty(property, type);
   
               // Set the bean's property to the value we just obtained:
  @@ -150,7 +159,7 @@
                       // We can't assign null to primitive types.
                   {
                       param[0]= value;
  -                    descriptors[i].getWriteMethod().invoke(this, param);
  +                    descriptor.getWriteMethod().invoke(this, param);
                   }
               }
               catch (IllegalArgumentException e)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to