[weld-commits] Weld SVN: r6044 - in core/trunk/impl/src/main: java/org/jboss/weld/logging/messages and 4 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Fri Mar 12 01:46:09 EST 2010


Author: nickarls
Date: 2010-03-12 01:46:09 -0500 (Fri, 12 Mar 2010)
New Revision: 6044

Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
   core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java
   core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
   core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties
Log:
WELD-468

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java	2010-03-11 12:44:39 UTC (rev 6043)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java	2010-03-12 06:46:09 UTC (rev 6044)
@@ -23,14 +23,11 @@
 import static org.jboss.weld.logging.messages.ValidatorMessage.AMBIGUOUS_EL_NAME;
 import static org.jboss.weld.logging.messages.ValidatorMessage.BEAN_NAME_IS_PREFIX;
 import static org.jboss.weld.logging.messages.ValidatorMessage.BEAN_SPECIALIZED_TOO_MANY_TIMES;
-import static org.jboss.weld.logging.messages.ValidatorMessage.DECORATOR_CLASS_NOT_BEAN_CLASS_OF_DECORATOR;
-import static org.jboss.weld.logging.messages.ValidatorMessage.DECORATOR_SPECIFIED_TWICE;
 import static org.jboss.weld.logging.messages.ValidatorMessage.DECORATORS_CANNOT_HAVE_DISPOSER_METHODS;
 import static org.jboss.weld.logging.messages.ValidatorMessage.DECORATORS_CANNOT_HAVE_PRODUCER_FIELDS;
 import static org.jboss.weld.logging.messages.ValidatorMessage.DECORATORS_CANNOT_HAVE_PRODUCER_METHODS;
-import static org.jboss.weld.logging.messages.ValidatorMessage.INTERCEPTORS_CANNOT_HAVE_DISPOSER_METHODS;
-import static org.jboss.weld.logging.messages.ValidatorMessage.INTERCEPTORS_CANNOT_HAVE_PRODUCER_FIELDS;
-import static org.jboss.weld.logging.messages.ValidatorMessage.INTERCEPTORS_CANNOT_HAVE_PRODUCER_METHODS;
+import static org.jboss.weld.logging.messages.ValidatorMessage.DECORATOR_CLASS_NOT_BEAN_CLASS_OF_DECORATOR;
+import static org.jboss.weld.logging.messages.ValidatorMessage.DECORATOR_SPECIFIED_TWICE;
 import static org.jboss.weld.logging.messages.ValidatorMessage.DISPOSAL_METHODS_WITHOUT_PRODUCER;
 import static org.jboss.weld.logging.messages.ValidatorMessage.INJECTION_INTO_NON_BEAN;
 import static org.jboss.weld.logging.messages.ValidatorMessage.INJECTION_INTO_NON_DEPENDENT_BEAN;
@@ -42,12 +39,14 @@
 import static org.jboss.weld.logging.messages.ValidatorMessage.INJECTION_POINT_HAS_WILDCARD;
 import static org.jboss.weld.logging.messages.ValidatorMessage.INJECTION_POINT_MUST_HAVE_TYPE_PARAMETER;
 import static org.jboss.weld.logging.messages.ValidatorMessage.INJECTION_POINT_WITH_TYPE_VARIABLE;
+import static org.jboss.weld.logging.messages.ValidatorMessage.INTERCEPTORS_CANNOT_HAVE_DISPOSER_METHODS;
+import static org.jboss.weld.logging.messages.ValidatorMessage.INTERCEPTORS_CANNOT_HAVE_PRODUCER_FIELDS;
+import static org.jboss.weld.logging.messages.ValidatorMessage.INTERCEPTORS_CANNOT_HAVE_PRODUCER_METHODS;
 import static org.jboss.weld.logging.messages.ValidatorMessage.INTERCEPTOR_NOT_ANNOTATED_OR_REGISTERED;
 import static org.jboss.weld.logging.messages.ValidatorMessage.INTERCEPTOR_SPECIFIED_TWICE;
 import static org.jboss.weld.logging.messages.ValidatorMessage.NEW_WITH_QUALIFIERS;
 import static org.jboss.weld.logging.messages.ValidatorMessage.NON_FIELD_INJECTION_POINT_CANNOT_USE_NAMED;
 import static org.jboss.weld.logging.messages.ValidatorMessage.NON_SERIALIZABLE_BEAN_INJECTED_INTO_PASSIVATING_BEAN;
-import static org.jboss.weld.logging.messages.ValidatorMessage.NOT_PROXYABLE;
 import static org.jboss.weld.logging.messages.ValidatorMessage.PASSIVATING_BEAN_WITH_NONSERIALIZABLE_DECORATOR;
 import static org.jboss.weld.logging.messages.ValidatorMessage.PASSIVATING_BEAN_WITH_NONSERIALIZABLE_INTERCEPTOR;
 
@@ -124,7 +123,7 @@
       boolean normalScoped = beanManager.getServices().get(MetaAnnotationStore.class).getScopeModel(bean.getScope()).isNormal();
       if (normalScoped && !Beans.isBeanProxyable(bean))
       {
-         throw new UnproxyableResolutionException(NOT_PROXYABLE, bean);
+         throw Proxies.getUnproxyableTypesException(bean.getTypes());
       }
    }
 

Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java	2010-03-11 12:44:39 UTC (rev 6043)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java	2010-03-12 06:46:09 UTC (rev 6044)
@@ -17,7 +17,10 @@
 
 package org.jboss.weld.logging.messages;
 
+import java.lang.reflect.Modifier;
+
 import org.jboss.weld.logging.MessageId;
+import org.jboss.weld.util.reflection.Reflections;
 
 import ch.qos.cal10n.BaseName;
 import ch.qos.cal10n.Locale;
@@ -37,7 +40,7 @@
  */
 public enum ValidatorMessage
 {
-   @MessageId("001400") NOT_PROXYABLE,
+//   @MessageId("001400") NOT_PROXYABLE,
    @MessageId("001401") BEAN_SPECIALIZED_TOO_MANY_TIMES,
    @MessageId("001402") PASSIVATING_BEAN_WITH_NONSERIALIZABLE_INTERCEPTOR,
    @MessageId("001403") PASSIVATING_BEAN_WITH_NONSERIALIZABLE_DECORATOR,
@@ -67,9 +70,14 @@
    @MessageId("001427") NON_FIELD_INJECTION_POINT_CANNOT_USE_NAMED,
    @MessageId("001428") DECORATORS_CANNOT_HAVE_PRODUCER_METHODS,
    @MessageId("001429") DECORATORS_CANNOT_HAVE_PRODUCER_FIELDS,
-   @MessageId("001430")DECORATORS_CANNOT_HAVE_DISPOSER_METHODS,
+   @MessageId("001430") DECORATORS_CANNOT_HAVE_DISPOSER_METHODS,
    @MessageId("001431") INTERCEPTORS_CANNOT_HAVE_PRODUCER_METHODS,
    @MessageId("001432") INTERCEPTORS_CANNOT_HAVE_PRODUCER_FIELDS,
-   @MessageId("001433")INTERCEPTORS_CANNOT_HAVE_DISPOSER_METHODS;
-
+   @MessageId("001433") INTERCEPTORS_CANNOT_HAVE_DISPOSER_METHODS,
+   @MessageId("001434") NOT_PROXYABLE_UNKNOWN,
+   @MessageId("001435") NOT_PROXYABLE_NO_CONSTRUCTOR,
+   @MessageId("001436") NOT_PROXYABLE_PRIVATE_CONSTRUCTOR,
+   @MessageId("001437") NOT_PROXYABLE_FINAL_TYPE_OR_METHOD,
+   @MessageId("001438") NOT_PROXYABLE_PRIMITIVE,
+   @MessageId("001439") NOT_PROXYABLE_ARRAY_TYPE;   
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java	2010-03-11 12:44:39 UTC (rev 6043)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java	2010-03-12 06:46:09 UTC (rev 6044)
@@ -21,7 +21,6 @@
 import static org.jboss.weld.logging.messages.BeanManagerMessage.DUPLICATE_ACTIVE_CONTEXTS;
 import static org.jboss.weld.logging.messages.BeanManagerMessage.NON_NORMAL_SCOPE;
 import static org.jboss.weld.logging.messages.BeanManagerMessage.NOT_INTERCEPTOR_BINDING_TYPE;
-import static org.jboss.weld.logging.messages.BeanManagerMessage.NOT_PROXYABLE;
 import static org.jboss.weld.logging.messages.BeanManagerMessage.NOT_STEREOTYPE;
 import static org.jboss.weld.logging.messages.BeanManagerMessage.NO_DECORATOR_TYPES;
 import static org.jboss.weld.logging.messages.BeanManagerMessage.SPECIFIED_TYPE_NOT_BEAN_TYPE;
@@ -810,7 +809,7 @@
       boolean normalScoped = getServices().get(MetaAnnotationStore.class).getScopeModel(bean.getScope()).isNormal();
       if (normalScoped && !Beans.isBeanProxyable(bean))
       {
-         throw new UnproxyableResolutionException(NOT_PROXYABLE, bean);
+         throw Proxies.getUnproxyableTypesException(bean.getTypes());
       }
       return bean;
    }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java	2010-03-11 12:44:39 UTC (rev 6043)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java	2010-03-12 06:46:09 UTC (rev 6044)
@@ -18,6 +18,12 @@
 
 import static org.jboss.weld.logging.messages.UtilMessage.CANNOT_PROXY_NON_CLASS_TYPE;
 import static org.jboss.weld.logging.messages.UtilMessage.INSTANCE_NOT_A_PROXY;
+import static org.jboss.weld.logging.messages.ValidatorMessage.NOT_PROXYABLE_ARRAY_TYPE;
+import static org.jboss.weld.logging.messages.ValidatorMessage.NOT_PROXYABLE_FINAL_TYPE_OR_METHOD;
+import static org.jboss.weld.logging.messages.ValidatorMessage.NOT_PROXYABLE_NO_CONSTRUCTOR;
+import static org.jboss.weld.logging.messages.ValidatorMessage.NOT_PROXYABLE_PRIMITIVE;
+import static org.jboss.weld.logging.messages.ValidatorMessage.NOT_PROXYABLE_PRIVATE_CONSTRUCTOR;
+import static org.jboss.weld.logging.messages.ValidatorMessage.NOT_PROXYABLE_UNKNOWN;
 import static org.jboss.weld.util.reflection.Reflections.EMPTY_CLASSES;
 
 import java.io.Serializable;
@@ -36,6 +42,7 @@
 import javassist.util.proxy.ProxyObject;
 
 import org.jboss.weld.exceptions.ForbiddenArgumentException;
+import org.jboss.weld.exceptions.UnproxyableResolutionException;
 import org.jboss.weld.util.reflection.Reflections;
 import org.jboss.weld.util.reflection.SecureReflections;
 
@@ -59,7 +66,6 @@
       
    }
    
-   
    public static class TypeInfo
    {
 
@@ -215,19 +221,24 @@
     */
    public static boolean isTypeProxyable(Type type)
    {
+      return getUnproxyableTypeException(type) == null;
+   }
+   
+   public static UnproxyableResolutionException getUnproxyableTypeException(Type type)
+   {
       if (type instanceof Class<?>)
       {
-         return isClassProxyable((Class<?>) type);
+         return getUnproxyableClassException((Class<?>) type);
       }
       else if (type instanceof ParameterizedType)
       {
          Type rawType = ((ParameterizedType) type).getRawType();
          if (rawType instanceof Class<?>)
          {
-            return isClassProxyable((Class<?>) rawType);
+            return getUnproxyableClassException((Class<?>) rawType);
          }
       }
-      return false;
+      return new UnproxyableResolutionException(NOT_PROXYABLE_UNKNOWN, type);
    }
    
 
@@ -239,25 +250,31 @@
     */
    public static boolean isTypesProxyable(Iterable<? extends Type> types)
    {
+      return getUnproxyableTypesException(types) == null;
+   }
+
+   public static UnproxyableResolutionException getUnproxyableTypesException(Iterable<? extends Type> types)
+   {
       for (Type apiType : types)
       {
          if (Object.class.equals(apiType))
          {
             continue;
          }
-         if (!isTypeProxyable(apiType))
+         UnproxyableResolutionException e = getUnproxyableTypeException(apiType);
+         if (e != null)
          {
-            return false;
+            return e;
          }
       }
-      return true;
+      return null;
    }
-      
-   private static boolean isClassProxyable(Class<?> clazz)
+   
+   private static UnproxyableResolutionException getUnproxyableClassException(Class<?> clazz)
    {
       if (clazz.isInterface())
       {
-         return true;
+         return null;
       }
       else
       {
@@ -268,31 +285,31 @@
          }
          catch (NoSuchMethodException e)
          {
-            return false;
+            return new UnproxyableResolutionException(NOT_PROXYABLE_NO_CONSTRUCTOR, clazz);
          }
          if (constructor == null)
          {
-            return false;
+            return new UnproxyableResolutionException(NOT_PROXYABLE_NO_CONSTRUCTOR, clazz);
          }
          else if (Modifier.isPrivate(constructor.getModifiers()))
          {
-            return false;
+            return new UnproxyableResolutionException(NOT_PROXYABLE_PRIVATE_CONSTRUCTOR, clazz, constructor);
          }
          else if (Reflections.isTypeOrAnyMethodFinal(clazz))
          {
-            return false;
+            return new UnproxyableResolutionException(NOT_PROXYABLE_FINAL_TYPE_OR_METHOD, clazz, Reflections.getFinalMethodOrType(clazz));
          }
          else if (clazz.isPrimitive())
          {
-            return false;
+            return new UnproxyableResolutionException(NOT_PROXYABLE_PRIMITIVE, clazz);
          }
          else if (Reflections.isArrayType(clazz))
          {
-            return false;
+            return new UnproxyableResolutionException(NOT_PROXYABLE_ARRAY_TYPE, clazz);
          }
          else
          {
-            return true;
+            return null;
          }
       }
    }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java	2010-03-11 12:44:39 UTC (rev 6043)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java	2010-03-12 06:46:09 UTC (rev 6044)
@@ -155,18 +155,23 @@
     */
    public static boolean isTypeOrAnyMethodFinal(Class<?> type)
    {
+      return getFinalMethodOrType(type) != null;
+   }
+   
+   public static Object getFinalMethodOrType(Class<?> type) 
+   {
       if (isFinal(type))
       {
-         return true;
+         return type;
       }
       for (Method method : type.getDeclaredMethods())
       {
          if (isFinal(method))
          {
-            return true;
+            return method;
          }
       }
-      return false;
+      return null;      
    }
 
    public static boolean isPackagePrivate(int mod)

Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties	2010-03-11 12:44:39 UTC (rev 6043)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties	2010-03-12 06:46:09 UTC (rev 6044)
@@ -1,4 +1,3 @@
-NOT_PROXYABLE=Normal scoped bean {0} is not proxyable
 BEAN_SPECIALIZED_TOO_MANY_TIMES=Two beans cannot specialize the same bean {0}
 PASSIVATING_BEAN_WITH_NONSERIALIZABLE_INTERCEPTOR=The bean {0} declared a passivating scope but has a non-serializable interceptor {1}
 PASSIVATING_BEAN_WITH_NONSERIALIZABLE_DECORATOR=The bean {0} declared a passivating scope but has non-serializable decorator {1}
@@ -32,3 +31,9 @@
 INTERCEPTORS_CANNOT_HAVE_PRODUCER_METHODS=An interceptor cannot have producer methods, but at least one was found on {0}.
 INTERCEPTORS_CANNOT_HAVE_PRODUCER_FIELDS=An interceptor cannot have producer fields, but at least one was found on {0}.
 INTERCEPTORS_CANNOT_HAVE_DISPOSER_METHODS=An interceptor cannot disposer methods, but at least one was found on {0}.
+NOT_PROXYABLE_UNKNOWN=Normal scoped bean {0} is not proxyable for an unknown reason.
+NOT_PROXYABLE_NO_CONSTRUCTOR=Normal scoped bean {0} is not proxyable because it has no no-args constructor.
+NOT_PROXYABLE_PRIVATE_CONSTRUCTOR=Normal scoped bean {0} is not proxyable because it has a private no-args constructor {1}.
+NOT_PROXYABLE_FINAL_TYPE_OR_METHOD=Normal scoped bean {0} is not proxyable because it has a private field or method {1}.
+NOT_PROXYABLE_PRIMITIVE=Normal scoped bean {0} is not proxyable because it is a primitive
+NOT_PROXYABLE_ARRAY_TYPE=Normal scoped bean {0} is not proxyable because it is an array type
\ No newline at end of file



More information about the weld-commits mailing list