}
}
try {
Class<Object> clazz = null;
Name nameAnnotation = null;
if (className != null) {
//get the class implied by the namespaced XML element name
clazz = Reflections.classForName(className);
nameAnnotation = clazz.getAnnotation(Name.class);
}
//if the name attribute is not explicitly specified in the XML,
//imply the name from the @Name annotation on the class implied
//by the XML element name
if (name == null && nameAnnotation!=null) {
name = nameAnnotation.value();
}
//if this class already has the @Name annotation, the XML element
//is just adding configuration to the existing component, don't
//add another ComponentDescriptor (this is super-important to
//allow overriding!)
if (nameAnnotation!=null && nameAnnotation.value().equals(name)) {
Install install = clazz.getAnnotation(Install.class);
if (install == null || install.value()) {
className = null;
}
}