nameQuery = new AbstractNameQuery(null, Collections.singletonMap("name", shortName), type.getName());
}
Set<GBeanInstance> instances = listGBeans(nameQuery);
if (instances.size() == 0) {
throw new GBeanNotFoundException("No GBeans found", Collections.singleton(nameQuery), null);
}
if (instances.size() > 1) {
if (type == null) {
throw new GBeanNotFoundException("More then one GBean was found with shortName '" + shortName + "'", Collections.singleton(nameQuery), mapToNames(instances));
}
if (shortName == null) {
throw new GBeanNotFoundException("More then one GBean was found with type '" + type.getName() + "'", Collections.singleton(nameQuery), mapToNames(instances));
}
throw new GBeanNotFoundException("More then one GBean was found with shortName '" + shortName + "' and type '" + type.getName() + "'", Collections.singleton(nameQuery), mapToNames(instances));
}
return instances.iterator().next();
}