openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r832501 - in /incubator/openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/intercept/ main/java/org/apache/webbeans/intercept/webbeans/ main/java/org/apache/webbeans/util/ test/java/org/apache/webbeans/test/servlet/
Date Tue, 03 Nov 2009 18:37:08 GMT
Author: gerdogdu
Date: Tue Nov  3 18:37:07 2009
New Revision: 832501

URL: http://svn.apache.org/viewvc?rev=832501&view=rev
Log:
Patches for OWB-157,159,160. Thanks to Eric Covener.

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=832501&r1=832500&r2=832501&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
Tue Nov  3 18:37:07 2009
@@ -86,6 +86,7 @@
     public static void configure(BaseBean<?> component, List<InterceptorData>
stack)
     {
         Class<?> clazz = component.getReturnType();
+        Set<Interceptor<?>> componentInterceptors = null;
         
         if (AnnotationUtil.hasInterceptorBindingMetaAnnotation(clazz.getDeclaredAnnotations()))
         {
@@ -127,14 +128,14 @@
             anns = new Annotation[bindingTypeSet.size()];
             anns = bindingTypeSet.toArray(anns);
 
-            Set<Interceptor<?>> set = findDeployedWebBeansInterceptor(anns);
+            componentInterceptors = findDeployedWebBeansInterceptor(anns);
 
             // Adding class interceptors
-            addComponentInterceptors(set, stack);
+            addComponentInterceptors(componentInterceptors, stack);
         }
 
         // Method level interceptors.
-        addMethodInterceptors(clazz, stack);
+        addMethodInterceptors(clazz, stack, componentInterceptors);
 
     }
 
@@ -154,7 +155,7 @@
 
     }
 
-    private static void addMethodInterceptors(Class<?> clazz, List<InterceptorData>
stack)
+    private static void addMethodInterceptors(Class<?> clazz, List<InterceptorData>
stack, Set<Interceptor<?>> componentInterceptors)
     {
         Method[] methods = clazz.getDeclaredMethods();
 
@@ -195,6 +196,12 @@
                 result = set.toArray(result);
 
                 Set<Interceptor<?>> setInterceptors = findDeployedWebBeansInterceptor(result);
+                
+                if(componentInterceptors != null)
+                {
+                    setInterceptors.removeAll(componentInterceptors);   
+                }
+
                 Iterator<Interceptor<?>> it = setInterceptors.iterator();
 
                 while (it.hasNext())
@@ -242,14 +249,14 @@
         while (it.hasNext())
         {
             interceptor = (WebBeansInterceptor<?>) it.next();
-
+      
             if (interceptor.hasBinding(bindingTypes, listAnnot))
             {
                 set.add(interceptor);
                 set.addAll(interceptor.getMetaInceptors());
             }
         }
-
+        
         return set;
     }
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=832501&r1=832500&r2=832501&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
Tue Nov  3 18:37:07 2009
@@ -113,12 +113,12 @@
     }
 
     /**
-     * Checks whether this interceptor has given binding types with
+     * Checks whether all of this interceptors binding types are present on the bean, with

      * {@link NonBinding} member values.
      * 
-     * @param bindingTypes binding types
-     * @param annots binding types annots.
-     * @return true if binding types exist ow false
+     * @param bindingTypes binding types of bean
+     * @param annots binding types annots of bean
+     * @return true if all binding types of this interceptor exist ow false
      */
     public boolean hasBinding(List<Class<? extends Annotation>> bindingTypes,
List<Annotation> annots)
     {
@@ -135,24 +135,22 @@
             return false;
         }
 
-        int i = 0;
-        for (Class<? extends Annotation> bindingType : bindingTypes)
+        /* This interceptor is enabled if all of its interceptor bindings are present on
the bean */
+        for (Class<? extends Annotation> bindingType : this.interceptorBindingSet.keySet())
         {
-            Annotation target = this.interceptorBindingSet.get(bindingType);
-
-            if (target == null)
-            {
-                return false;
-            }
-
-            if (!AnnotationUtil.hasAnnotationMember(bindingType, annots.get(i), target))
-            {
-                return false;
-            }
-
-            i++;
+        	int index = bindingTypes.indexOf(bindingType);
+        	if (index < 0) 
+        	{
+        	    return false; /* at least one of this interceptors types is not in the beans
bindingTypes */	
+        	}
+        	
+        	if (!AnnotationUtil.hasAnnotationMember(bindingTypes.get(index), annots.get(index),
this.interceptorBindingSet.get(bindingType)))
+        	
+        	{
+        		return false;
+        	}
         }
-
+        
         return true;
     }
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=832501&r1=832500&r2=832501&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Tue Nov  3 18:37:07 2009
@@ -1789,7 +1789,8 @@
 
             if (component != null)
             {
-                WebBeansInterceptorConfig.configureInterceptorClass((ManagedBean<Object>)
component, clazz.getDeclaredAnnotations());
+                WebBeansInterceptorConfig.configureInterceptorClass((ManagedBean<Object>)
component, 
+                		AnnotationUtil.getInterceptorBindingMetaAnnotations(clazz.getDeclaredAnnotations()));
             }
         }
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java?rev=832501&r1=832500&r2=832501&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java
Tue Nov  3 18:37:07 2009
@@ -71,6 +71,7 @@
 import org.apache.webbeans.test.sterotype.StereoWithSessionScope;
 import org.apache.webbeans.test.sterotype.StereoWithSessionScope2;
 import org.apache.webbeans.test.unittests.xml.XMLTest;
+import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 import org.apache.webbeans.xml.XMLUtil;
@@ -430,7 +431,8 @@
             {
                 InterceptorUtil.checkInterceptorConditions(clazz);
                 component = ManagedBeanConfigurator.define(clazz, WebBeansType.INTERCEPTOR);
-                WebBeansInterceptorConfig.configureInterceptorClass((ManagedBean<Object>)
component, clazz.getDeclaredAnnotations());
+                WebBeansInterceptorConfig.configureInterceptorClass((ManagedBean<Object>)
component, 
+                        AnnotationUtil.getInterceptorBindingMetaAnnotations(clazz.getDeclaredAnnotations()));
             }
 
         }



Mime
View raw message