You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2013/01/02 20:02:54 UTC

svn commit: r1427907 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: annotation/AnnotationManager.java intercept/WebBeansInterceptorConfig.java

Author: struberg
Date: Wed Jan  2 19:02:54 2013
New Revision: 1427907

URL: http://svn.apache.org/viewvc?rev=1427907&view=rev
Log:
OWB-344 move logic to AnnotationManager

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java?rev=1427907&r1=1427906&r2=1427907&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java Wed Jan  2 19:02:54 2013
@@ -98,6 +98,46 @@ public final class AnnotationManager
     }
 
 
+    /**
+     * This method searches for all direct and indirect annotations which
+     * represent an {@link InterceptorBinding}.
+     * InterceptorBindings in stereotypes will also be found!
+     *
+     * @return the effective interceptor annotations of the array of given annotations
+     */
+    public Set<Annotation> getInterceptorAnnotations(Annotation[] typeAnns)
+    {
+        Set<Annotation> bindingTypeSet = new HashSet<Annotation>();
+
+        AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
+
+        Annotation[] anns = annotationManager.getInterceptorBindingMetaAnnotations(typeAnns);
+
+        for (Annotation ann : anns)
+        {
+            bindingTypeSet.add(ann);
+        }
+
+        // check for stereotypes _explicitly_ declared on the bean class (not
+        // inherited)
+        Annotation[] stereoTypes =
+                annotationManager.getStereotypeMetaAnnotations(typeAnns);
+        for (Annotation stereoType : stereoTypes)
+        {
+            if (annotationManager.hasInterceptorBindingMetaAnnotation(stereoType.annotationType().getDeclaredAnnotations()))
+            {
+                Annotation[] steroInterceptorBindings = annotationManager.getInterceptorBindingMetaAnnotations(
+                        stereoType.annotationType().getDeclaredAnnotations());
+
+                for (Annotation ann : steroInterceptorBindings)
+                {
+                    bindingTypeSet.add(ann);
+                }
+            }
+        }
+
+        return bindingTypeSet;
+    }
 
     /**
      * If any Annotations in the input is an interceptor binding annotation type then return
@@ -140,7 +180,7 @@ public final class AnnotationManager
                 interAnns.add(ann);
 
                 //check for transitive
-                Annotation[] transitives = getTransitiveInterceptorBindings(ann.annotationType().getDeclaredAnnotations());
+                Annotation[] transitives = getInterceptorBindingMetaAnnotations(ann.annotationType().getDeclaredAnnotations());
 
                 for(Annotation transitive : transitives)
                 {
@@ -156,10 +196,6 @@ public final class AnnotationManager
         return ret;
     }
 
-    private Annotation[] getTransitiveInterceptorBindings(Annotation[] anns)
-    {
-        return getInterceptorBindingMetaAnnotations(anns);
-    }
 
     /**
      * Returns true if the annotation is defined in xml or annotated with

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=1427907&r1=1427906&r2=1427907&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java Wed Jan  2 19:02:54 2013
@@ -133,8 +133,6 @@ public final class WebBeansInterceptorCo
         }
     }
 
-
-
     /**
      * Configures the given class for applicable interceptors.
      *
@@ -143,13 +141,28 @@ public final class WebBeansInterceptorCo
     {
         Class<?> clazz = ((AbstractOwbBean<?>)component).getReturnType();
         AnnotatedType<?> annotatedType = component.getAnnotatedType();
+        Set<Annotation> annotations = null;
 
-        Annotation[] anns;
+        if(annotatedType != null)
+        {
+            annotations = annotatedType.getAnnotations();
+        }
 
         AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
 
+        Annotation[] typeAnns;
+        if(annotations != null)
+        {
+            typeAnns = annotations.toArray(new Annotation[annotations.size()]);
+        }
+        else
+        {
+            typeAnns = clazz.getDeclaredAnnotations();
+        }
+        Set<Annotation> bindingTypeSet = annotationManager.getInterceptorAnnotations(typeAnns);
+
+        Annotation[] anns;
         Set<Interceptor<?>> componentInterceptors = null;
-        Set<Annotation> bindingTypeSet = getComponentInterceptors(annotatedType, clazz);
 
         // Look for inherited binding types, keeping in mind that
         // IBeanInheritedMetaData knows nothing of the transitive
@@ -226,58 +239,6 @@ public final class WebBeansInterceptorCo
 
     }
 
-    private Set<Annotation> getComponentInterceptors(AnnotatedType<?> annotatedType, Class clazz)
-    {
-        Set<Annotation> annotations = null;
-
-        if(annotatedType != null)
-        {
-            annotations = annotatedType.getAnnotations();
-        }
-
-        Set<Annotation> bindingTypeSet = new HashSet<Annotation>();
-        Annotation[] anns;
-
-        Annotation[] typeAnns;
-        if(annotations != null)
-        {
-            typeAnns = annotations.toArray(new Annotation[annotations.size()]);
-        }
-        else
-        {
-            typeAnns = clazz.getDeclaredAnnotations();
-        }
-
-        AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
-
-        anns = annotationManager.getInterceptorBindingMetaAnnotations(typeAnns);
-
-        for (Annotation ann : anns)
-        {
-            bindingTypeSet.add(ann);
-        }
-
-        // check for stereotypes _explicitly_ declared on the bean class (not
-        // inherited)
-        Annotation[] stereoTypes =
-                annotationManager.getStereotypeMetaAnnotations(typeAnns);
-        for (Annotation stero : stereoTypes)
-        {
-            if (annotationManager.hasInterceptorBindingMetaAnnotation(stero.annotationType().getDeclaredAnnotations()))
-            {
-                Annotation[] steroInterceptorBindings = annotationManager.getInterceptorBindingMetaAnnotations(
-                        stero.annotationType().getDeclaredAnnotations());
-
-                for (Annotation ann : steroInterceptorBindings)
-                {
-                    bindingTypeSet.add(ann);
-                }
-            }
-        }
-
-        return bindingTypeSet;
-    }
-
     private void filterInterceptorsPerBDA(AbstractInjectionTargetBean<?> component, List<InterceptorData> stack)
     {