You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by gp...@apache.org on 2010/08/16 20:18:56 UTC

svn commit: r986086 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/container/ webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ webbeans-impl/src/main/ja...

Author: gpetracek
Date: Mon Aug 16 18:18:55 2010
New Revision: 986086

URL: http://svn.apache.org/viewvc?rev=986086&view=rev
Log:
OWB-407 intermediate result (style #1)

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ViolationMessageBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/InjectionExceptionUtils.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java
    openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=986086&r1=986085&r2=986086&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java Mon Aug 16 18:18:55 2010
@@ -28,7 +28,6 @@ import java.lang.reflect.ParameterizedTy
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -40,7 +39,6 @@ import javax.enterprise.inject.Typed;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.Specializes;
-import javax.enterprise.inject.UnsatisfiedResolutionException;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.AnnotatedType;
@@ -83,6 +81,7 @@ import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.SecurityUtil;
 import org.apache.webbeans.util.WebBeansUtil;
+import static org.apache.webbeans.util.InjectionExceptionUtils.throwUnsatisfiedResolutionException;
 
 /**
  * Defines the web beans components common properties.
@@ -776,8 +775,7 @@ public final class DefinitionUtil
             Set<Bean<?>> set = InjectionResolver.getInstance().implResolveByType(type, annot);
             if (set.isEmpty())
             {
-                throw new UnsatisfiedResolutionException("Producer method component of the disposal method : " + declaredMethod.getName() + 
-                              " in class : " + clazz.getName() + ". Cannot find bean " + type + " with qualifier " + Arrays.toString(annot));
+                throwUnsatisfiedResolutionException(clazz, declaredMethod, annot);
             }
             
             Bean<?> bean = set.iterator().next();
@@ -785,8 +783,7 @@ public final class DefinitionUtil
 
             if (bean == null || !(bean instanceof ProducerMethodBean))
             {
-                throw new UnsatisfiedResolutionException("Producer method component of the disposal method : " + declaredMethod.getName() + " in class : "
-                                                         + clazz.getName() + "is not found");
+                throwUnsatisfiedResolutionException(clazz, declaredMethod);
             }
 
             else

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=986086&r1=986085&r2=986086&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 Mon Aug 16 18:18:55 2010
@@ -42,7 +42,6 @@ import javax.enterprise.context.NormalSc
 import javax.enterprise.context.spi.Context;
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.AmbiguousResolutionException;
 import javax.enterprise.inject.Default;
 import javax.enterprise.inject.Stereotype;
 import javax.enterprise.inject.spi.*;
@@ -91,6 +90,7 @@ import org.apache.webbeans.util.ClassUti
 import org.apache.webbeans.util.WebBeansAnnotatedTypeUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 import org.apache.webbeans.xml.WebBeansXMLConfigurator;
+import static org.apache.webbeans.util.InjectionExceptionUtils.*;
 
 /**
  * Implementation of the {@link BeanManager} contract of the web beans
@@ -415,7 +415,7 @@ public class BeanManagerImpl implements 
 
         if (set.size() > 1)
         {
-            throw new AmbiguousResolutionException("There are more than one WebBeans with name : " + name);
+            throwAmbiguousResolutionExceptionForBeanName(set, name);
         }
 
         component = (AbstractOwbBean<?>) set.iterator().next();
@@ -989,7 +989,7 @@ public class BeanManagerImpl implements 
         
         if(set.size() > 0 && set.size() > 1)
         {
-            throw new AmbiguousResolutionException("Ambigious resolution");
+            throwAmbiguousResolutionException(set);
         }
         
         return (Bean<? extends X>)set.iterator().next();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java?rev=986086&r1=986085&r2=986086&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java Mon Aug 16 18:18:55 2010
@@ -24,8 +24,6 @@ import java.lang.reflect.Type;
 import java.util.Iterator;
 import java.util.Set;
 
-import javax.enterprise.inject.AmbiguousResolutionException;
-import javax.enterprise.inject.UnsatisfiedResolutionException;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 
@@ -33,6 +31,7 @@ import org.apache.webbeans.util.Annotati
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
+import static org.apache.webbeans.util.InjectionExceptionUtils.*;
 
 public final class ResolutionUtil
 {
@@ -92,38 +91,14 @@ public final class ResolutionUtil
     
     public static void checkResolvedBeans(Set<Bean<?>> resolvedSet, Class<?> type, Annotation[] qualifiers, InjectionPoint injectionPoint)
     {
-        StringBuffer qualifierMessage = new StringBuffer("[");
-        
-        int i = 0;
-        for(Annotation annot : qualifiers)
-        {
-            i++;            
-            qualifierMessage.append(annot);
-            
-            if(i != qualifiers.length)
-            {                
-                qualifierMessage.append(",");
-            }
-        }
-        
-        qualifierMessage.append("]");
-        
         if (resolvedSet.isEmpty())
         {
-            StringBuffer message = new StringBuffer("Api type [" + type.getName() + "] is not found with the qualifiers ");            
-            message.append(qualifierMessage);
-
-            if (injectionPoint != null) 
-            { 
-                message.append(" for injection into " + injectionPoint.toString());
-            }
-            
-            throw new UnsatisfiedResolutionException(message.toString());
+            throwUnsatisfiedResolutionException(type, injectionPoint, qualifiers);
         }
 
         if (resolvedSet.size() > 1)
         {
-            throw new AmbiguousResolutionException("There is more than one api type with : " + type.getName() + " with qualifiers : " + qualifierMessage);
+            throwAmbiguousResolutionException(resolvedSet, type, qualifiers);
         }
 
         Bean<?> bean = resolvedSet.iterator().next();

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ViolationMessageBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ViolationMessageBuilder.java?rev=986086&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ViolationMessageBuilder.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ViolationMessageBuilder.java Mon Aug 16 18:18:55 2010
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.exception.helper;
+
+public class ViolationMessageBuilder
+{
+    private StringBuilder violationMessage;
+
+    private final String lineSeparator = System.getProperty("line.separator");
+
+    public static ViolationMessageBuilder newViolation()
+    {
+        return new ViolationMessageBuilder();
+    }
+
+    public static ViolationMessageBuilder newViolation(String... text)
+    {
+        return new ViolationMessageBuilder().append(text);
+    }
+
+    public ViolationMessageBuilder append(String... text)
+    {
+        appendText(text, false);
+        return this;
+    }
+
+    public ViolationMessageBuilder addLine(String... text)
+    {
+        if(text == null)
+        {
+            return this;
+        }
+        
+        appendText(text, true);
+        return this;
+    }
+
+    private void appendText(String[] text, boolean appendLineSeparator)
+    {
+        if(this.violationMessage == null)
+        {
+            this.violationMessage = new StringBuilder();
+        }
+        else if(appendLineSeparator)
+        {
+            this.violationMessage.append(lineSeparator);
+        }
+
+        for(String t : text)
+        {
+            this.violationMessage.append(t);
+        }
+    }
+
+    public boolean containsViolation()
+    {
+        return this.violationMessage != null;
+    }
+
+    @Override
+    public String toString()
+    {
+        return containsViolation() ? this.violationMessage.toString() : "no violation recorded";
+    }
+}

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/InjectionExceptionUtils.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/InjectionExceptionUtils.java?rev=986086&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/InjectionExceptionUtils.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/InjectionExceptionUtils.java Mon Aug 16 18:18:55 2010
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.util;
+
+import org.apache.webbeans.exception.helper.ViolationMessageBuilder;
+import static org.apache.webbeans.exception.helper.ViolationMessageBuilder.newViolation;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.AmbiguousResolutionException;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
+import javax.enterprise.inject.ResolutionException;
+import javax.enterprise.inject.UnproxyableResolutionException;
+import java.util.Set;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+
+public class InjectionExceptionUtils
+{
+    public static void throwUnproxyableResolutionException(ViolationMessageBuilder violationMessage)
+    {
+        throw new UnproxyableResolutionException(
+                newViolation("WebBeans with api type with normal scope must be proxiable to inject.")
+                        .addLine(violationMessage.toString())
+                        .toString());
+    }
+    
+    public static void throwBeanNotFoundException(Class type, Annotation... qualifiers)
+    {
+        ViolationMessageBuilder violationMessage =
+                newViolation("Cannot find beans for class ", type.getCanonicalName());
+
+        violationMessage.addLine(createQualifierMessage(qualifiers));
+
+        throw new ResolutionException(violationMessage.toString());
+    }
+
+    public static void throwUnsatisfiedResolutionException(String message, Method producerMethod)
+    {
+        ViolationMessageBuilder violationMessage = newViolation(message);
+
+        violationMessage.addLine(createProducerMethodMessage(producerMethod));
+
+        throw new UnsatisfiedResolutionException(violationMessage.toString());
+    }
+
+    public static void throwUnsatisfiedResolutionException(Type type, Method producerMethod, Annotation... qualifiers)
+    {
+        ViolationMessageBuilder violationMessage = newViolation(createProducerMethodMessage(producerMethod));
+
+        violationMessage.append(" in class: ", ClassUtil.getClass(type).getName());
+        violationMessage.addLine(createQualifierMessage(qualifiers));
+
+        throw new UnsatisfiedResolutionException(violationMessage.toString());
+    }
+
+    private static String createProducerMethodMessage(Method producerMethod)
+    {
+        return "Producer method component of the disposal method : " + producerMethod.getName() + "is not found";
+    }
+
+    public static void throwUnsatisfiedResolutionException(
+            Class type, InjectionPoint injectionPoint, Annotation... qualifiers)
+    {
+        ViolationMessageBuilder violationMessage =
+                newViolation("Api type [", type.getName(), "] is not found with the qualifiers ");
+
+        violationMessage.addLine(createQualifierMessage(qualifiers));
+
+        if (injectionPoint != null)
+        {
+            violationMessage.addLine("for injection into ", injectionPoint.toString());
+        }
+
+        throw new UnsatisfiedResolutionException(violationMessage.toString());
+    }
+
+    public static void throwAmbiguousResolutionExceptionForBeanName(Set<Bean<?>> beans, String beanName)
+    {
+        throwAmbiguousResolutionExceptionForBeans(beans,
+                newViolation("There are more than one WebBeans with name : ", beanName));
+    }
+
+    public static void throwAmbiguousResolutionException(Set<Bean<?>> beans)
+    {
+        throwAmbiguousResolutionException(beans, null);
+    }
+
+    public static void throwAmbiguousResolutionException(Set<Bean<?>> beans, Class type, Annotation... qualifiers)
+    {
+        String qualifierMessage = createQualifierMessage(qualifiers);
+
+        ViolationMessageBuilder violationMessage;
+
+        if(type != null)
+        {
+            violationMessage = newViolation("There is more than one api type with : ",
+                    ClassUtil.getClass(type).getName(), " with qualifiers : ", qualifierMessage);
+        }
+        else
+        {
+            violationMessage = newViolation("Ambigious resolution");
+        }
+
+        throwAmbiguousResolutionExceptionForBeans(beans, violationMessage);
+    }
+
+    private static void throwAmbiguousResolutionExceptionForBeans(
+            Set<Bean<?>> beans, ViolationMessageBuilder violationMessage)
+    {
+        violationMessage.addLine("found beans: ");
+
+        addBeanInfo(beans, violationMessage);
+
+        throw new AmbiguousResolutionException(violationMessage.toString());
+    }
+
+    private static void addBeanInfo(Set<Bean<?>> beans, ViolationMessageBuilder violationMessage)
+    {
+        for(Bean<?> currentBean : beans)
+        {
+            violationMessage.addLine(currentBean.toString());
+        }
+    }
+
+    private static String createQualifierMessage(Annotation... qualifiers)
+    {
+        if(qualifiers == null || qualifiers.length == 0)
+        {
+            return null;
+        }
+
+        //reused source-code
+        StringBuilder qualifierMessage = new StringBuilder("Qualifiers: [");
+
+        int i = 0;
+        for(Annotation annot : qualifiers)
+        {
+            i++;
+            qualifierMessage.append(annot);
+
+            if(i != qualifiers.length)
+            {
+                qualifierMessage.append(",");
+            }
+        }
+
+        qualifierMessage.append("]");
+
+        return qualifierMessage.toString();
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=986086&r1=986085&r2=986086&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java Mon Aug 16 18:18:55 2010
@@ -26,7 +26,6 @@ import java.lang.reflect.ParameterizedTy
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -41,7 +40,6 @@ import javax.enterprise.inject.Default;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.Specializes;
-import javax.enterprise.inject.UnsatisfiedResolutionException;
 import javax.enterprise.inject.spi.AnnotatedConstructor;
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedMethod;
@@ -80,6 +78,7 @@ import org.apache.webbeans.intercept.Web
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.spi.api.ResourceReference;
+import static org.apache.webbeans.util.InjectionExceptionUtils.throwUnsatisfiedResolutionException;
 
 public final class WebBeansAnnotatedTypeUtil
 {
@@ -260,9 +259,7 @@ public final class WebBeansAnnotatedType
                 Set<Bean<?>> set = InjectionResolver.getInstance().implResolveByType(type, annot);
                 if (set.isEmpty())
                 {
-                    throw new UnsatisfiedResolutionException("Producer method component of the disposal method : " + declaredMethod.getName() + 
-                                  " in class : " + declaredMethod.getDeclaringClass().getName() + ". Cannot find bean " + type + " with qualifier "
-                                  + Arrays.toString(annot));
+                    throwUnsatisfiedResolutionException(type, declaredMethod, annot);
                 }
                 
                 Bean<?> foundBean = set.iterator().next();
@@ -270,8 +267,7 @@ public final class WebBeansAnnotatedType
 
                 if (foundBean == null || !(foundBean instanceof ProducerMethodBean))
                 {
-                    throw new UnsatisfiedResolutionException("Producer method component of the disposal method : " + declaredMethod.getName() + " in class : "
-                                                             + annotatedMethod.getDeclaringType().getJavaClass() + "is not found");
+                    throwUnsatisfiedResolutionException(annotatedMethod.getDeclaringType().getJavaClass(), declaredMethod, annot);
                 }
 
                 pr = (ProducerMethodBean<?>) foundBean;

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=986086&r1=986085&r2=986086&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 Mon Aug 16 18:18:55 2010
@@ -63,7 +63,6 @@ import javax.enterprise.inject.New;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.Stereotype;
-import javax.enterprise.inject.UnproxyableResolutionException;
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
 import javax.enterprise.inject.spi.AnnotatedField;
@@ -139,6 +138,7 @@ import org.apache.webbeans.decorator.Web
 import org.apache.webbeans.event.ObserverMethodImpl;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.exception.helper.ViolationMessageBuilder;
 import org.apache.webbeans.exception.inject.DefinitionException;
 import org.apache.webbeans.exception.inject.InconsistentSpecializationException;
 import org.apache.webbeans.exception.inject.NullableDependencyException;
@@ -169,6 +169,7 @@ import org.apache.webbeans.portable.even
 import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansPlugin;
+import static org.apache.webbeans.util.InjectionExceptionUtils.throwUnproxyableResolutionException;
 
 /**
  * Contains some utility methods used in the all project.
@@ -2021,37 +2022,51 @@ public final class WebBeansUtil
         {
             Set<Type> types = bean.getTypes();
 
+            ViolationMessageBuilder violationMessage = ViolationMessageBuilder.newViolation();
+
             for(Type type : types)
             {
                 Class<?> beanClass = ClassUtil.getClass(type);
 
                 if(!beanClass.isInterface() && beanClass != Object.class)
                 {
-                    boolean throwException = false;
-                    if(ClassUtil.isPrimitive(beanClass)
-                            || ClassUtil.isArray(beanClass))
+                    if(ClassUtil.isPrimitive(beanClass))
                     {
-                        throwException = true;
+                        violationMessage.addLine("It isn't possible to use a primitive type (" + beanClass.getName(), ")");
                     }
 
-                    if(!throwException)
+                    if(ClassUtil.isArray(beanClass))
+                    {
+                        violationMessage.addLine("It isn't possible to use an array type (", beanClass.getName(), ")");
+                    }
+
+                    if(!violationMessage.containsViolation())
                     {
                         Constructor<?> cons = ClassUtil.isContaintNoArgConstructor(beanClass);
 
-                        if (ClassUtil.isFinal(beanClass.getModifiers())
-                                || ClassUtil.hasFinalMethod(beanClass) ||
-                                (cons == null || ClassUtil.isPrivate(cons.getModifiers())))
+                        if (ClassUtil.isFinal(beanClass.getModifiers()))
+                        {
+                            violationMessage.addLine(beanClass.getName(), " is a final class! CDI doesn't allow that.");
+                        }
+                        if (ClassUtil.hasFinalMethod(beanClass))
+                        {
+                            violationMessage.addLine(beanClass.getName(), " has final methods! CDI doesn't allow that.");
+                        }
+                        if (cons == null)
+                        {
+                            violationMessage.addLine(beanClass.getName(), " has no explicit no-arg constructor!",
+                                    "A public or protected constructor without args is required!");
+                        }
+                        else if (ClassUtil.isPrivate(cons.getModifiers()))
                         {
-                            throwException = true;
+                            violationMessage.addLine(beanClass.getName(), " has a >private< no-arg constructor! CDI doesn't allow that.");
                         }
                     }
 
                     //Throw Exception
-                    if(throwException)
+                    if(violationMessage.containsViolation())
                     {
-                        throw new UnproxyableResolutionException("WebBeans with api type with normal scope " +
-                                "must be proxiable to inject, but class : " + beanClass.getName()
-                                + " is not proxiable type");
+                        throwUnproxyableResolutionException(violationMessage);
                     }
                 }
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java?rev=986086&r1=986085&r2=986086&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java Mon Aug 16 18:18:55 2010
@@ -32,7 +32,6 @@ import javax.annotation.PreDestroy;
 import javax.decorator.Decorator;
 import javax.enterprise.context.NormalScope;
 import javax.enterprise.inject.Specializes;
-import javax.enterprise.inject.UnsatisfiedResolutionException;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Interceptor;
@@ -67,6 +66,7 @@ import org.apache.webbeans.util.ClassUti
 import org.apache.webbeans.util.SecurityUtil;
 import org.apache.webbeans.util.WebBeansConstants;
 import org.apache.webbeans.util.WebBeansUtil;
+import static org.apache.webbeans.util.InjectionExceptionUtils.*;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -715,7 +715,7 @@ public final class XMLDefinitionUtil
      * @param errorMessage          error message used in exceptions
      * @throws WebBeansConfigurationException if more than one Disposal element
      *                                        exist for the given disposal method element
-     * @throws UnsatisfiedResolutionException if no producer method found for
+     * @throws javax.enterprise.inject.UnsatisfiedResolutionException if no producer method found for
      *                                        given disposal method
      */
     public static <T> void defineXMLDisposalMethod(XMLManagedBean<T> component, Method disposalMethod, Element disposalMethodElement, String errorMessage)
@@ -771,8 +771,7 @@ public final class XMLDefinitionUtil
 
                 if (producerComponent == null)
                 {
-                    throw new UnsatisfiedResolutionException(errorMessage + "Producer method component of the disposal method : "
-                                                             + disposalMethod.getName() + "is not found");
+                    throwUnsatisfiedResolutionException(errorMessage, disposalMethod);
                 }
 
                 producerComponent.setDisposalMethod(disposalMethod);

Modified: openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java?rev=986086&r1=986085&r2=986086&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java (original)
+++ openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java Mon Aug 16 18:18:55 2010
@@ -21,7 +21,6 @@ package org.apache.webbeans.cditest.owb;
 import java.lang.annotation.Annotation;
 import java.util.Set;
 
-import javax.enterprise.inject.AmbiguousResolutionException;
 import javax.enterprise.inject.ResolutionException;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
@@ -30,6 +29,7 @@ import org.apache.webbeans.cditest.CdiTe
 import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.lifecycle.LifecycleFactory;
 import org.apache.webbeans.spi.ContainerLifecycle;
+import static org.apache.webbeans.util.InjectionExceptionUtils.*;
 
 /**
  * OpenWebBeans specific implementation of {@link CdiTestContainer}.
@@ -153,12 +153,12 @@ public class CdiTestOpenWebBeansContaine
         Set<Bean<?>> beans = getBeanManager().getBeans(type, qualifiers);
         if (beans == null || beans.isEmpty()) 
         {
-            throw new ResolutionException("cannot find beans for class " + type.getCanonicalName());
+            throwBeanNotFoundException(type, qualifiers);
         }
 
         if (beans.size() > 1) 
         {
-            throw new AmbiguousResolutionException("cannot find beans for class " + type.getCanonicalName());
+            throwAmbiguousResolutionException(beans, type, qualifiers);
         }
 
         @SuppressWarnings("unchecked")