1 10 package org.picocontainer.defaults; 11 12 import org.picocontainer.PicoIntrospectionException; 13 14 import java.util.Arrays ; 15 16 26 public class AmbiguousComponentResolutionException extends PicoIntrospectionException { 27 private Class component; 28 private Class ambiguousDependency; 29 private final Object [] ambiguousComponentKeys; 30 31 32 38 public AmbiguousComponentResolutionException(Class ambiguousDependency, Object [] componentKeys) { 39 super(""); 40 this.ambiguousDependency = ambiguousDependency; 41 this.ambiguousComponentKeys = new Class [componentKeys.length]; 42 for (int i = 0; i < componentKeys.length; i++) { 43 ambiguousComponentKeys[i] = componentKeys[i]; 44 } 45 } 46 47 50 public String getMessage() { 51 StringBuffer msg = new StringBuffer (); 52 msg.append(component); 53 msg.append(" has ambiguous dependency on "); 54 msg.append(ambiguousDependency); 55 msg.append(", "); 56 msg.append("resolves to multiple classes: "); 57 msg.append(Arrays.asList(getAmbiguousComponentKeys())); 58 return msg.toString(); 59 } 60 61 64 public Object [] getAmbiguousComponentKeys() { 65 return ambiguousComponentKeys; 66 } 67 68 public void setComponent(Class component) { 69 this.component = component; 70 } 71 } 72 | Popular Tags |