[jboss-cvs] JBossAS SVN: r60325 - in projects/microcontainer/trunk/container/src/main/org/jboss: javabean/plugins/xml and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 6 08:03:58 EST 2007


Author: alesj
Date: 2007-02-06 08:03:57 -0500 (Tue, 06 Feb 2007)
New Revision: 60325

Modified:
   projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/NestedPropertyInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/ConfigurationUtil.java
Log:
Diff between undeterminable and methods that can be called on NestedPropertyInfo.

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java	2007-02-06 12:19:16 UTC (rev 60324)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java	2007-02-06 13:03:57 UTC (rev 60325)
@@ -127,7 +127,7 @@
                }
                else
                {
-                  nestedPropertyInfo = new NestedPropertyInfo(previous.getName());
+                  nestedPropertyInfo = new NestedPropertyInfo(previous.getName(), this);
                   nestedPropertyInfo.addPropertyInfo(previous);
                   propertiesByName.put(previous.getName(), nestedPropertyInfo);
                }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/NestedPropertyInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/NestedPropertyInfo.java	2007-02-06 12:19:16 UTC (rev 60324)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/NestedPropertyInfo.java	2007-02-06 13:03:57 UTC (rev 60325)
@@ -21,27 +21,43 @@
 */
 package org.jboss.beans.info.plugins;
 
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.jboss.beans.info.spi.BeanInfo;
 import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.reflect.spi.MethodInfo;
 import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+import org.jboss.util.NotImplementedException;
 
 /**
  * When bean has more than one property with the same name
- * we try to use this impl to look over all possible setters.
- * In case of getter we cannot determine which one to use
- * since there is insufficient information - only parent bean.
+ * we try to use this impl to look over all possible setters
+ * in order to set the value.
  *
+ * But for most of other methods there is insufficent information
+ * to invoke the right method - e.g. just property name and parent bean. 
+ *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class NestedPropertyInfo extends AbstractPropertyInfo
+public class NestedPropertyInfo extends JBossObject implements PropertyInfo, Serializable
 {
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   private String name;
+   private BeanInfo beanInfo;
    private List<PropertyInfo> propertys = new ArrayList<PropertyInfo>();
 
-   public NestedPropertyInfo(String name)
+   public NestedPropertyInfo(String name, BeanInfo beanInfo)
    {
-      super(name);
+      this.name = name;
+      this.beanInfo = beanInfo;
    }
 
    void addPropertyInfo(PropertyInfo propertyInfo)
@@ -49,11 +65,35 @@
       propertys.add(propertyInfo);
    }
 
-   public Object get(Object bean) throws Throwable
+   // can be used
+
+   public BeanInfo getBeanInfo()
    {
-      throw new IllegalArgumentException("Unable to determine getter on " + bean + " for property " + name);
+      return beanInfo;
    }
 
+   public String getName()
+   {
+      return name;
+   }
+
+   public String getUpperName()
+   {
+      return name;
+   }
+
+   /**
+    * In this case it is better to return null
+    * then to throw an exception, since we might still have
+    * enough information to use this class to set the value.
+    *
+    * @return null
+    */
+   public TypeInfo getType()
+   {
+      return null;
+   }
+
    public void set(Object bean, Object value) throws Throwable
    {
       if (value != null)
@@ -75,4 +115,95 @@
       throw new IllegalArgumentException("Unable to determine setter on " + bean + " for property " + name + " with value " + value);
    }
 
+   @Override
+   public boolean equals(Object object)
+   {
+      if (object == null || object instanceof NestedPropertyInfo == false)
+         return false;
+
+      NestedPropertyInfo other = (NestedPropertyInfo) object;
+      if (notEqual(name, other.name))
+         return false;
+      if (notEqual(beanInfo, other.beanInfo))
+         return false;
+      else if (notEqual(propertys.size(), other.propertys.size()))
+         return false;
+      return true;
+   }
+
+   @Override
+   public void toString(JBossStringBuilder buffer)
+   {
+      buffer.append("name=").append(name);
+   }
+
+   @Override
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append(name);
+   }
+
+   @Override
+   public int getHashCode()
+   {
+      return name.hashCode();
+   }
+
+   // ---- undeterminable
+
+   public Object get(Object bean) throws Throwable
+   {
+      throw new IllegalArgumentException("Unable to determine getter on " + bean + " for property " + name);
+   }
+
+   public MethodInfo getGetter()
+   {
+      throw new IllegalArgumentException("Unable to determine right PropertyInfo by name: " + name);
+   }
+
+   public void setGetter(MethodInfo getter)
+   {
+      throw new NotImplementedException("setGetter");
+   }
+
+   public MethodInfo getSetter()
+   {
+      throw new IllegalArgumentException("Unable to determine right PropertyInfo by name: " + name);
+   }
+
+   public void setSetter(MethodInfo setter)
+   {
+      throw new NotImplementedException("setSetter");
+   }
+
+   public AnnotationValue[] getAnnotations()
+   {
+      throw new IllegalArgumentException("Unable to determine right PropertyInfo by name: " + name);
+   }
+
+   public AnnotationValue getAnnotation(String name)
+   {
+      throw new IllegalArgumentException("Unable to determine right PropertyInfo by name: " + this.name);
+   }
+
+   public boolean isAnnotationPresent(String name)
+   {
+      throw new IllegalArgumentException("Unable to determine right PropertyInfo by name: " + this.name);
+   }
+
+   public Annotation[] getUnderlyingAnnotations()
+   {
+      throw new IllegalArgumentException("Unable to determine right PropertyInfo by name: " + name);
+   }
+
+   public <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType)
+   {
+      throw new IllegalArgumentException("Unable to determine right PropertyInfo by name: " + name);
+   }
+
+   public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+   {
+      throw new IllegalArgumentException("Unable to determine right PropertyInfo by name: " + name);
+   }
+
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/ConfigurationUtil.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/ConfigurationUtil.java	2007-02-06 12:19:16 UTC (rev 60324)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/ConfigurationUtil.java	2007-02-06 13:03:57 UTC (rev 60325)
@@ -129,7 +129,8 @@
       TypeInfo type = property.getType();
       if (override != null)
          type = typeInfoFactory.getTypeInfo(override, null);
-      return type.convertValue(value);
+
+      return type != null ? type.convertValue(value) : value;
    }
 
 }




More information about the jboss-cvs-commits mailing list