openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1429492 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: annotation/AnnotationManager.java intercept/InterceptorResolution.java intercept/WebBeansInterceptorConfig.java
Date Sun, 06 Jan 2013 10:24:44 GMT
Author: struberg
Date: Sun Jan  6 10:24:44 2013
New Revision: 1429492

URL: http://svn.apache.org/viewvc?rev=1429492&view=rev
Log:
OWB-344 add a few methods with Set<Annotation>

This is helpful when we get the annotations from Annotated<?>

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/InterceptorResolution.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=1429492&r1=1429491&r2=1429492&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
Sun Jan  6 10:24:44 2013
@@ -105,7 +105,7 @@ public final class AnnotationManager
      *
      * @return the effective interceptor annotations of the array of given annotations
      */
-    public Set<Annotation> getInterceptorAnnotations(Annotation[] typeAnns)
+    public Set<Annotation> getInterceptorAnnotations(Set<Annotation> typeAnns)
     {
         Set<Annotation> bindingTypeSet = new HashSet<Annotation>();
 
@@ -166,6 +166,17 @@ public final class AnnotationManager
      * @param anns An array of annotations
      * @return an array of interceptor binding annotations, including the input and any transitively
declared annotations
      */
+    public Annotation[] getInterceptorBindingMetaAnnotations(Set<Annotation> anns)
+    {
+        return getInterceptorBindingMetaAnnotations(AnnotationUtil.getAnnotationsFromSet(anns));
+    }
+
+    /**
+     * Collect the interceptor bindings from an array of annotations, including
+     * transitively defined interceptor bindings.
+     * @param anns An array of annotations
+     * @return an array of interceptor binding annotations, including the input and any transitively
declared annotations
+     */
     public Annotation[] getInterceptorBindingMetaAnnotations(Annotation[] anns)
     {
         Asserts.assertNotNull(anns, "anns parameter can not be null");
@@ -412,6 +423,36 @@ public final class AnnotationManager
         return false;
     }
 
+    public Annotation[] getStereotypeMetaAnnotations(Set<Annotation> anns)
+    {
+        Asserts.assertNotNull(anns, "anns parameter can not be null");
+        List<Annotation> interAnns = new ArrayList<Annotation>();
+
+        for (Annotation ann : anns)
+        {
+            if (isStereoTypeAnnotation(ann.annotationType()))
+            {
+                interAnns.add(ann);
+
+                //check for transitive
+                Annotation[] transitives = getTransitiveStereoTypes(ann.annotationType().getDeclaredAnnotations());
+
+                for(Annotation transitive : transitives)
+                {
+                    interAnns.add(transitive);
+                }
+            }
+        }
+
+        Annotation[] ret = new Annotation[interAnns.size()];
+        ret = interAnns.toArray(ret);
+
+        return ret;
+    }
+
+    /**
+     * Same like {@link #getStereotypeMetaAnnotations(java.util.Set)} but with an array
+     */
     public Annotation[] getStereotypeMetaAnnotations(Annotation[] anns)
     {
         Asserts.assertNotNull(anns, "anns parameter can not be null");

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java?rev=1429492&r1=1429491&r2=1429492&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java
Sun Jan  6 10:24:44 2013
@@ -90,7 +90,7 @@ public class InterceptorResolution
         // pick up CDI interceptors from a class level
         //X TODO should work but can surely be improved!
         Set<Annotation> classInterceptorBindings
-                = annotationManager.getInterceptorAnnotations(AnnotationUtil.getAnnotationsFromSet(annotatedType.getAnnotations()));
+                = annotationManager.getInterceptorAnnotations(annotatedType.getAnnotations());
 
         //X TODO pick up EJB interceptors from a class level
         //X TODO pick up the decorators
@@ -104,7 +104,7 @@ public class InterceptorResolution
         {
             Set<Annotation> cummulatedInterceptorBindings = new HashSet<Annotation>();
             cummulatedInterceptorBindings.addAll(
-                    annotationManager.getInterceptorAnnotations(AnnotationUtil.getAnnotationsFromSet(interceptableAnnotatedMethod.getAnnotations())));
+                    annotationManager.getInterceptorAnnotations(interceptableAnnotatedMethod.getAnnotations()));
 
             cummulatedInterceptorBindings.addAll(classInterceptorBindings);
 
@@ -115,7 +115,10 @@ public class InterceptorResolution
 
             InterceptionType interceptionType = calculateInterceptionType(interceptableAnnotatedMethod);
             MethodInterceptorInfo methodInterceptorInfo = new MethodInterceptorInfo(interceptionType);
-            List<Interceptor<?>> methodInterceptors = beanManager.resolveInterceptors(interceptionType,
AnnotationUtil.getAnnotationsFromSet(cummulatedInterceptorBindings));
+
+            List<Interceptor<?>> methodInterceptors
+                    = beanManager.resolveInterceptors(interceptionType, AnnotationUtil.getAnnotationsFromSet(cummulatedInterceptorBindings));
+
             methodInterceptorInfo.setCdiInterceptors(methodInterceptors);
 
             allUsedCdiInterceptors.addAll(methodInterceptors);

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=1429492&r1=1429491&r2=1429492&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
Sun Jan  6 10:24:44 2013
@@ -30,6 +30,7 @@ import org.apache.webbeans.plugins.OpenW
 import org.apache.webbeans.spi.BDABeansXmlScanner;
 import org.apache.webbeans.spi.ScannerService;
 import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.ArrayUtil;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
@@ -145,7 +146,7 @@ public final class WebBeansInterceptorCo
 
         Annotation[] typeAnns;
         typeAnns = annotations.toArray(new Annotation[annotations.size()]);
-        Set<Annotation> bindingTypeSet = annotationManager.getInterceptorAnnotations(typeAnns);
+        Set<Annotation> bindingTypeSet = annotationManager.getInterceptorAnnotations(ArrayUtil.asSet(typeAnns));
 
         Annotation[] anns;
         Set<Interceptor<?>> componentInterceptors = null;



Mime
View raw message