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/03 21:18:39 UTC

svn commit: r1428573 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/ webbeans-impl/src/main/java/org/apache/webbeans/annotation/ webbeans-impl/src/main/java/org/apache/webbeans/container/ webbeans-impl/s...

Author: struberg
Date: Thu Jan  3 20:18:39 2013
New Revision: 1428573

URL: http://svn.apache.org/viewvc?rev=1428573&view=rev
Log:
OWB-344 first version of a InterceptorResolution + cleanup

Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.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
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBean.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java?rev=1428573&r1=1428572&r2=1428573&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java Thu Jan  3 20:18:39 2013
@@ -72,7 +72,6 @@ import org.apache.webbeans.util.WebBeans
  * @version $Rev$ $Date$
  *
  */
-    
 public class OpenWebBeansEjbInterceptor implements Serializable
 {
     private static final long serialVersionUID = -4317127341083031217L;

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=1428573&r1=1428572&r2=1428573&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 Thu Jan  3 20:18:39 2013
@@ -118,16 +118,14 @@ public final class AnnotationManager
             bindingTypeSet.add(ann);
         }
 
-        // check for stereotypes _explicitly_ declared on the bean class (not
-        // inherited)
-        Annotation[] stereoTypes =
-                annotationManager.getStereotypeMetaAnnotations(typeAnns);
+        // 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());
+                Annotation[] steroInterceptorBindings =
+                        annotationManager.getInterceptorBindingMetaAnnotations(stereoType.annotationType().getDeclaredAnnotations());
 
                 for (Annotation ann : steroInterceptorBindings)
                 {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1428573&r1=1428572&r2=1428573&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java Thu Jan  3 20:18:39 2013
@@ -542,7 +542,7 @@ public class BeanManagerImpl implements 
     {
         webBeansContext.getAnnotationManager().checkInterceptorResolverParams(interceptorBindings);
 
-        Set<Interceptor<?>> intsSet = webBeansContext.getWebBeansInterceptorConfig().findDeployedWebBeansInterceptor(interceptorBindings, webBeansContext);
+        Set<Interceptor<?>> intsSet = webBeansContext.getWebBeansInterceptorConfig().findDeployedWebBeansInterceptor(interceptorBindings);
         Iterator<Interceptor<?>> itSet = intsSet.iterator();
 
         List<Interceptor<?>> interceptorList = new ArrayList<Interceptor<?>>();
@@ -554,7 +554,6 @@ public class BeanManagerImpl implements 
             {
                 interceptorList.add(interceptor);
             }
-
         }
 
         Collections.sort(interceptorList, new InterceptorComparator(webBeansContext));

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=1428573&r1=1428572&r2=1428573&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 Thu Jan  3 20:18:39 2013
@@ -20,9 +20,11 @@ package org.apache.webbeans.intercept;
 
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Decorator;
 import javax.enterprise.inject.spi.InterceptionType;
 import javax.enterprise.inject.spi.Interceptor;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -31,8 +33,10 @@ import java.util.Map;
 import java.util.Set;
 import java.util.logging.Logger;
 
+import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.ClassUtil;
 
 /**
@@ -59,16 +63,33 @@ public class InterceptorResolution
         List<AnnotatedMethod> interceptableAnnotatedMethods = getInterceptableAnnotatedMethods(annotatedType);
 
         InterceptorUtil interceptorUtils = webBeansContext.getInterceptorUtil();
+        AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
+        BeanManager bm = webBeansContext.getBeanManagerImpl();
 
         List<Interceptor> classLevelCdiInterceptors = new ArrayList<Interceptor>();
         List<Interceptor> classLevelEjbInterceptors = new ArrayList<Interceptor>();
 
 
-        //X TODO pick up CDI interceptors from a class level
+        // 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()));
+
         //X TODO pick up EJB interceptors from a class level
         //X TODO pick up the decorators
 
-        //X TODO iterate over all methods and build up the interceptor stack
+        // iterate over all methods and build up the interceptor stack
+        for (AnnotatedMethod interceptableAnnotatedMethod : interceptableAnnotatedMethods)
+        {
+            Set<Annotation> methodInterceptorBindings
+                    = annotationManager.getInterceptorAnnotations(AnnotationUtil.getAnnotationsFromSet(interceptableAnnotatedMethod.getAnnotations()));
+
+            List<Annotation> cummulatedInterceptorBindings = new ArrayList<Annotation>();
+            cummulatedInterceptorBindings.addAll(methodInterceptorBindings);
+            cummulatedInterceptorBindings.addAll(classInterceptorBindings);
+
+        }
+
         //X TODO sort the CDI interceptors
 
         return interceptorInfo;
@@ -109,12 +130,12 @@ public class InterceptorResolution
          * All the Interceptor Beans which are active on this class somewhere.
          * This is only used to create the Interceptor instances.
          */
-        private List<Interceptor> interceptors = new ArrayList<Interceptor>();
+        private Set<Interceptor<?>> interceptors = null;
 
         /**
          * All the Decorator Beans active on this class.
          */
-        private List<Decorator> decorators = new ArrayList<Decorator>();
+        private Set<Decorator<?>> decorators = null;
 
         /**
          * For each method which is either decorated or intercepted we keep an entry.

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=1428573&r1=1428572&r2=1428573&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 Thu Jan  3 20:18:39 2013
@@ -218,7 +218,7 @@ public final class WebBeansInterceptorCo
 
         if (anns.length > 0)
         {
-            componentInterceptors = findDeployedWebBeansInterceptor(anns, component.getWebBeansContext());
+            componentInterceptors = findDeployedWebBeansInterceptor(anns);
 
             // Adding class interceptors
             addComponentInterceptors(componentInterceptors, stack);
@@ -404,7 +404,7 @@ public final class WebBeansInterceptorCo
                 Annotation[] result = new Annotation[interceptorAnns.size()];
                 result = interceptorAnns.toArray(result);
 
-                Set<Interceptor<?>> setInterceptors = findDeployedWebBeansInterceptor(result, webBeansContext);
+                Set<Interceptor<?>> setInterceptors = findDeployedWebBeansInterceptor(result);
 
                 if (componentInterceptors != null)
                 {
@@ -514,7 +514,7 @@ public final class WebBeansInterceptorCo
                 Annotation[] result = new Annotation[interceptorAnns.size()];
                 result = interceptorAnns.toArray(result);
 
-                Set<Interceptor<?>> setInterceptors = findDeployedWebBeansInterceptor(result, webBeansContext);
+                Set<Interceptor<?>> setInterceptors = findDeployedWebBeansInterceptor(result);
 
                 if(componentInterceptors != null)
                 {
@@ -574,7 +574,7 @@ public final class WebBeansInterceptorCo
     /*
      * Find the deployed interceptors with given interceptor binding types.
      */
-    public Set<Interceptor<?>> findDeployedWebBeansInterceptor(Annotation[] anns, WebBeansContext webBeansContext)
+    public Set<Interceptor<?>> findDeployedWebBeansInterceptor(Annotation[] anns)
     {
         Set<Interceptor<?>> set = new HashSet<Interceptor<?>>();
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBean.java?rev=1428573&r1=1428572&r2=1428573&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBean.java Thu Jan  3 20:18:39 2013
@@ -214,7 +214,7 @@ public class WebBeansInterceptorBean<T> 
             if (anns != null && anns.length > 0)
             {
                 // For example : @Transactional @Action Interceptor
-                Set<Interceptor<?>> metas = webBeansContext.getWebBeansInterceptorConfig().findDeployedWebBeansInterceptor(anns, webBeansContext);
+                Set<Interceptor<?>> metas = webBeansContext.getWebBeansInterceptorConfig().findDeployedWebBeansInterceptor(anns);
                 set.addAll(metas);
 
                 // For each @Transactional and @Action Interceptor
@@ -222,7 +222,7 @@ public class WebBeansInterceptorBean<T> 
                 {
                     Annotation[] simple = new Annotation[1];
                     simple[0] = ann;
-                    metas = webBeansContext.getWebBeansInterceptorConfig().findDeployedWebBeansInterceptor(simple, webBeansContext);
+                    metas = webBeansContext.getWebBeansInterceptorConfig().findDeployedWebBeansInterceptor(simple);
                     set.addAll(metas);
                 }