[seam-commits] Seam SVN: r14172 - branches/enterprise/JBPAPP_5_1_1_JBPAPP-6925/src/main/org/jboss/seam/util.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Sep 7 12:48:05 EDT 2011


Author: smendenh at redhat.com
Date: 2011-09-07 12:48:05 -0400 (Wed, 07 Sep 2011)
New Revision: 14172

Modified:
   branches/enterprise/JBPAPP_5_1_1_JBPAPP-6925/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java
Log:
further changes for JBPAPP-6925

Modified: branches/enterprise/JBPAPP_5_1_1_JBPAPP-6925/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java
===================================================================
--- branches/enterprise/JBPAPP_5_1_1_JBPAPP-6925/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java	2011-09-07 13:15:02 UTC (rev 14171)
+++ branches/enterprise/JBPAPP_5_1_1_JBPAPP-6925/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java	2011-09-07 16:48:05 UTC (rev 14172)
@@ -14,18 +14,28 @@
  */
 public class AnnotatedBeanProperty<T extends Annotation> implements java.io.Serializable
 {
-   private Field propertyField;
-   private Method propertyGetter;
-   private Method propertySetter;
+   private transient Field propertyField;
+   private transient Method propertyGetter;
+   private transient Method propertySetter;
    private String name;
    private Type propertyType;
    private T annotation;
    
    private boolean isFieldProperty;
    private boolean set = false;
+
+   private Class<?> cls;
+   private Class<T> annotationClass;
    
    public AnnotatedBeanProperty(Class<?> cls, Class<T> annotationClass)
    {      
+	  this.cls = cls;
+	  this.annotationClass = annotationClass;
+      init();
+   }
+
+   private void init() 
+   {	
       // First check declared fields
       for (Field f : cls.getDeclaredFields())
       {
@@ -37,7 +47,7 @@
             return;
          }
       }      
-      
+
       // Then check public fields, in case it's inherited
       for (Field f : cls.getFields())
       {
@@ -49,7 +59,7 @@
             return;
          }
       }
-      
+
       // Then check public methods (we ignore private methods)
       for (Method m : cls.getMethods())
       {
@@ -57,7 +67,7 @@
          {
             this.annotation = m.getAnnotation(annotationClass);
             String methodName = m.getName();
-            
+
             if ( m.getName().startsWith("get") )
             {
                this.name = Introspector.decapitalize( m.getName().substring(3) );
@@ -66,7 +76,7 @@
             {
                this.name = Introspector.decapitalize( m.getName().substring(2) );
             }            
-            
+
             if (this.name != null)
             {
                this.propertyGetter = Reflections.getGetterMethod(cls, this.name);
@@ -81,9 +91,30 @@
                      "Method: " + m + " in class: " + cls);
             }
          }
-      }      
+      }
    }
 
+   public Field getPropertyField() 
+   { 
+      if (propertyField == null) 
+         init(); 
+      return propertyField; 
+   }
+
+   public Method getPropertyGetter() 
+   { 
+      if (propertyGetter == null) 
+         init(); 
+      return propertyGetter; 
+   }
+
+   public Method getPropertySetter() 
+   { 
+      if (propertySetter == null) 
+         init(); 
+      return propertySetter; 
+   }
+
    private void setupFieldProperty(Field propertyField)
    {
       this.propertyField = propertyField;
@@ -96,11 +127,11 @@
    {
       if (isFieldProperty)
       {
-         Reflections.setAndWrap(propertyField, bean, value);         
+         Reflections.setAndWrap(getPropertyField(), bean, value);         
       }
       else
       {
-         Reflections.invokeAndWrap(propertySetter, bean, value);
+         Reflections.invokeAndWrap(getPropertySetter(), bean, value);
       }
    }
    
@@ -108,11 +139,11 @@
    {
       if (isFieldProperty)
       {
-         return Reflections.getAndWrap(propertyField, bean);  
+         return Reflections.getAndWrap(getPropertyField(), bean);  
       }
       else
       {
-         return Reflections.invokeAndWrap(propertyGetter, bean);
+         return Reflections.invokeAndWrap(getPropertyGetter(), bean);
       }
    }
    



More information about the seam-commits mailing list