Author: kylem
Date: Fri Apr 15 09:46:04 2005
New Revision: 161501

URL: http://svn.apache.org/viewcvs?view=rev&rev=161501
Log:
Resolve JavaBean compat issues 
(http://issues.apache.org/jira/browse/BEEHIVE-528) plus added an additional JAR 
manifest attribute identifying Beans as a Beehive Control (for special case 
tool-handling, if desired)  (http://issues.apache.org/jira/browse/BEEHIVE-521)

Patch submitted by: Mridul Muralidharan


Modified:
    
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/properties/PropertyKey.java
    
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlManifest.vm

Modified: 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/properties/PropertyKey.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/properties/PropertyKey.java?view=diff&r1=161500&r2=161501
==============================================================================
--- 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/properties/PropertyKey.java
 (original)
+++ 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/properties/PropertyKey.java
 Fri Apr 15 09:46:04 2005
@@ -21,6 +21,8 @@
 import java.lang.reflect.Method;
 import java.util.HashMap;
 
+import org.apache.beehive.controls.api.ControlException;
+
 /**
  * The PropertyKey class represents a key that can be used to set a JSR-175 
attribute member
  * value within a <code>PropertyMap</code>.
@@ -59,6 +61,25 @@
         }
     }
 
+    protected Method getMethod()
+    {
+        if (null == _getMethod)
+        {
+            try
+            {
+                _getMethod = _propertySet.getMethod(_propertyName, (Class 
[])null);
+            }
+            catch(NoSuchMethodException nsmEx)
+            {
+                // This can only happen if a PropertySet is incompatibly 
changed after
+                // serialization of a PropertyKey (since it is initially 
validated in
+                // the constructor).
+                throw new ControlException("Unable to locate PropertyKey 
accessor method", nsmEx);
+            }
+        }
+        return _getMethod;
+    }
+
     /**
      * Computes the default value for the value of this property key, or null 
if there
      * is no defined default.
@@ -67,7 +88,7 @@
     {
         // Query the accessor method for the default value
         // This method will return 'null' if there is no defined default
-        return _getMethod.getDefaultValue();
+        return getMethod().getDefaultValue();
     }
 
     /**
@@ -77,7 +98,7 @@
     {
         try
         {
-            return _getMethod.invoke(annot, new Object [] {});
+            return getMethod().invoke(annot, new Object [] {});
         }
         // TODO -- cleanup exception handling, property defining a 
PropertyException
         catch (RuntimeException re) { throw re; }
@@ -113,11 +134,14 @@
     public Class<? extends Annotation>  getPropertySet()  { return  
_propertySet; }
     public String   getPropertyName() { return _propertyName; }
     public Class    getPropertyType() { return _propertyType; }
-    public Annotation[] getAnnotations() { return _getMethod.getAnnotations();}
+    public Annotation[] getAnnotations() { return 
getMethod().getAnnotations();}
 
     Class<? extends Annotation>  _propertySet;
     String  _propertyName;
     Class   _propertyType;
     int     _hashCode;
-    Method  _getMethod;
+
+    // WARNING: This field should never be accessed directly but instead via 
the getMethod()
+    // API.  This ensures that the (transient) value is appropriately 
recomputed when necessary.
+    private transient Method  _getMethod;
 }

Modified: 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlManifest.vm
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlManifest.vm?view=diff&r1=161500&r2=161501
==============================================================================
--- 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlManifest.vm
 (original)
+++ 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlManifest.vm
 Fri Apr 15 09:46:04 2005
@@ -33,7 +33,8 @@
 Manifest-Version: 1.0
 
 Name: $bean.manifestName
-JavaBean: true
+Java-Bean: true
+Beehive-Control: true
 #set ($attrs = $intf.manifestAttributes)
 #foreach ($name in $attrs.keySet())
 ${name}: ${attrs.get($name)}


Reply via email to