You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ky...@apache.org on 2005/02/10 01:16:23 UTC

svn commit: r153135 - incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/properties/AnnotatedElementMap.java

Author: kylem
Date: Wed Feb  9 16:16:22 2005
New Revision: 153135

URL: http://svn.apache.org/viewcvs?view=rev&rev=153135
Log:
I added support for looking up the interface inheritance hierarchy for PropertySets that
are marked as @Inherited.  Should resolve JIRA-257.

Modified:
    incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/properties/AnnotatedElementMap.java

Modified: incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/properties/AnnotatedElementMap.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/properties/AnnotatedElementMap.java?view=diff&r1=153134&r2=153135
==============================================================================
--- incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/properties/AnnotatedElementMap.java (original)
+++ incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/properties/AnnotatedElementMap.java Wed Feb  9 16:16:22 2005
@@ -19,6 +19,7 @@
 
 import java.io.IOException;
 import java.lang.annotation.Annotation;
+import java.lang.annotation.Inherited;
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -107,12 +108,42 @@
         if (!isValidKey(key))
             throw new IllegalArgumentException("Key " + key + " is not valid for " + _mapClass);
 
+
         //
         // Look for the property value on the associated annotated element
         //
-        Annotation annot = _annotElem.getAnnotation(key.getPropertySet());
+        Class propertySet = key.getPropertySet();
+        Annotation annot = _annotElem.getAnnotation(propertySet);
         if (annot != null)
             return key.extractValue(annot);
+
+        //
+        // If the property supports inheritance and the annotated element is an interface,
+        // then we'll search up the ControlInheritance/Extension hierachy to see if it is
+        // provided higher up the chain.
+        //
+        if (propertySet.isAnnotationPresent(Inherited.class) && _annotElem instanceof Class)
+        {
+            Class controlIntf = (Class)_annotElem;
+            do
+            {
+                Class [] superIntfs = controlIntf.getInterfaces();
+                controlIntf = null;
+                for (int i = 0; i < superIntfs.length; i++)
+                {
+                    if (superIntfs[i].isAnnotationPresent(ControlInterface.class) ||
+                        superIntfs[i].isAnnotationPresent(ControlExtension.class))
+                    {
+                        controlIntf = superIntfs[i];
+                        annot = controlIntf.getAnnotation(propertySet);
+                        if (annot != null)
+                            return key.extractValue(annot);
+                    }
+                }
+
+            }
+            while (controlIntf != null);
+        }
 
         //
         // Call up to superclass for delegation / default value