}
public ComponentAdapter getComponentAdapterOfType(Class componentType)
{
// See http://jira.codehaus.org/secure/ViewIssue.jspa?key=PICO-115
ComponentAdapter adapterByKey = getComponentAdapter(componentType);
if (adapterByKey != null)
{
return adapterByKey;
}
List found = getComponentAdaptersOfType(componentType);
if (found.size() == 1)
{
return ((ComponentAdapter)found.get(0));
}
else if (found.size() == 0)
{
if (parent != null)
{
return parent.getComponentAdapterOfType(componentType);
}
else
{
return null;
}
}
else
{
Class[] foundClasses = new Class[found.size()];
for (int i = 0; i < foundClasses.length; i++)
{
ComponentAdapter componentAdapter = (ComponentAdapter)found.get(i);
foundClasses[i] = componentAdapter.getComponentImplementation();
}
throw new AmbiguousComponentResolutionException(componentType, foundClasses);
}
}