Author: gpetracek
Date: Tue May 21 19:02:31 2013
New Revision: 1484905

URL: http://svn.apache.org/r1484905
Log:
OWB-774 additional hint in case of an AmbiguousResolutionException and cleanup

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

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/InjectionExceptionUtil.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/InjectionExceptionUtil.java?rev=1484905&r1=1484904&r2=1484905&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/InjectionExceptionUtil.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/InjectionExceptionUtil.java
 Tue May 21 19:02:31 2013
@@ -28,8 +28,6 @@ import javax.enterprise.inject.Unsatisfi
 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 InjectionExceptionUtil
 {
@@ -46,21 +44,6 @@ public class InjectionExceptionUtil
                         .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)
     {
@@ -123,9 +106,20 @@ public class InjectionExceptionUtil
 
     private static void addBeanInfo(Set<Bean<?>> beans, 
ViolationMessageBuilder violationMessage)
     {
+        String sourcePath;
         for(Bean<?> currentBean : beans)
         {
-            violationMessage.addLine(currentBean.toString());
+            try
+            {
+                Class beanClass = currentBean.getBeanClass();
+                sourcePath = beanClass.getResource(beanClass.getSimpleName() + 
".class").toExternalForm();
+            }
+            catch (RuntimeException e)
+            {
+                sourcePath = "unknown path";
+            }
+
+            violationMessage.addLine(currentBean.toString() + " from " + 
sourcePath);
         }
     }
 


Reply via email to