openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r940317 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Date Sun, 02 May 2010 20:41:59 GMT
Author: gerdogdu
Date: Sun May  2 20:41:59 2010
New Revision: 940317

URL: http://svn.apache.org/viewvc?rev=940317&view=rev
Log:
Small correction on unproxiable test. Found while running TCK.

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=940317&r1=940316&r2=940317&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Sun May  2 20:41:59 2010
@@ -1875,41 +1875,57 @@ public final class WebBeansUtil
         return beans;
     }
     
+    /**
+     * Checks the unproxiable condition.
+     * @param bean managed bean
+     * @param scopeType scope type
+     * @throws WebBeansConfigurationException if 
+     *  bean is not proxied by the container
+     */
     public static void checkUnproxiableApiType(Bean<?> bean, Class<? extends Annotation>
scopeType)
     {
         Asserts.assertNotNull("bean", "bean parameter can not be null");
         Asserts.assertNotNull(scopeType, "scopeType parameter can not be null");
-
-        Set<Type> types = bean.getTypes();
-        Class<?> superClass = null;
-        for (Type t : types)
-        {
-            Class<?> type = ClassUtil.getClazz(t);
-            
-            if (!type.isInterface())
-            {
-                if ((superClass == null) || (superClass.isAssignableFrom(type) &&
type != Object.class))
-                {
-                    superClass = type;
-                }
-
-            }
-        }
         
-        if (superClass != null && !superClass.equals(Object.class))
+        //Unproxiable test for NormalScoped beans
+        if (WebBeansUtil.isScopeTypeNormal(scopeType))
         {
-            Constructor<?> cons = ClassUtil.isContaintNoArgConstructor(superClass);
-
-            if (ClassUtil.isPrimitive(superClass) || ClassUtil.isArray(superClass) || ClassUtil.isFinal(superClass.getModifiers())
|| ClassUtil.hasFinalMethod(superClass) || (cons == null || ClassUtil.isPrivate(cons.getModifiers())))
+            Set<Type> types = bean.getTypes();
+            
+            for(Type type : types)
             {
-                if (scopeType.isAnnotationPresent(NormalScope.class))
+                Class<?> beanClass = ClassUtil.getClass(type);
+                
+                if(!beanClass.isInterface() && beanClass != Object.class)
                 {
-                    throw new UnproxyableResolutionException("WebBeans with api type with
normal scope must be proxiable to inject, but class : " + superClass.getName() + " is not
proxiable type");
-                }
+                    boolean throwException = false;
+                    if(ClassUtil.isPrimitive(beanClass) 
+                            || ClassUtil.isArray(beanClass))
+                    {
+                        throwException = true;
+                    }
+                    
+                    if(!throwException)
+                    {
+                        Constructor<?> cons = ClassUtil.isContaintNoArgConstructor(beanClass);
+
+                        if (ClassUtil.isFinal(beanClass.getModifiers()) 
+                                || ClassUtil.hasFinalMethod(beanClass) || 
+                                (cons == null || ClassUtil.isPrivate(cons.getModifiers())))
+                        {
+                            throwException = true;
+                        }
+                    }
+                    
+                    //Throw Exception
+                    if(throwException)
+                    {
+                        throw new UnproxyableResolutionException("WebBeans with api type
with normal scope " +
+                                "must be proxiable to inject, but class : " + beanClass.getName()
+ " is not proxiable type");          
+                    }                                
+                }                
             }
-
-        }
-
+        }              
     }
 
     public static void checkNullable(Class<?> type, AbstractOwbBean<?> component)



Mime
View raw message