public GBeanData findGBeanData(Set patterns) throws GBeanNotFoundException {
if (patterns == null) throw new NullPointerException("patterns is null");
Set result = findGBeanDatas(this, patterns);
if (result.size() > 1) {
throw new GBeanNotFoundException("More than one match to referencePatterns", patterns);
} else if (result.size() == 1) {
return (GBeanData) result.iterator().next();
}
// search all parents
for (Iterator iterator = allServiceParents.iterator(); iterator.hasNext();) {
Configuration configuration = (Configuration) iterator.next();
result.addAll(findGBeanDatas(configuration, patterns));
// if we already found a match we have an ambiguous query
if (result.size() > 1) {
List names = new ArrayList(result.size());
for (Iterator iterator1 = result.iterator(); iterator1.hasNext();) {
GBeanData gBeanData = (GBeanData) iterator1.next();
names.add(gBeanData.getAbstractName());
}
throw new GBeanNotFoundException("More than one match to referencePatterns: " + names.toString(), patterns);
}
}
if (result.isEmpty()) {
throw new GBeanNotFoundException("No matches for referencePatterns", patterns);
}
return (GBeanData) result.iterator().next();
}