Element constructorElement = constructors.get(0);
List<Element> arguments = dom.elements(constructorElement, ARGUMENT_ELEMENT);
if(arguments != null && arguments.size() >= 1) {
List<Class<?>> argsClass = new ArrayList<Class<?>>();
for(Element argument : arguments) {
XmlManagedNode xmlManagedNode = parseXmlManagedNode(argument, dom);
if(xmlManagedNode != null) {
xmlBeanDefinition.getContructorParameters().add(xmlManagedNode);
}
String initArgsType = argument.getAttribute(TYPE_ATTRIBUTE);
if(VerifyUtils.isNotEmpty(initArgsType)) {
try {
argsClass.add(XmlBeanReader.class.getClassLoader().loadClass(initArgsType));
} catch (ClassNotFoundException e) {
error("The '" + initArgsType + "' not found");
}
} else {
error("The '" + className + "' constructor argument node MUST has type attribute");
}
}
try {
xmlBeanDefinition.setConstructor(clazz.getConstructor(argsClass.toArray(new Class<?>[0])));
} catch (Throwable e) {
error("The '" + className + "' gets constructor error");
}
} else {
error("The '" + className + "' constructor node MUST be more than one argument node!");
}
} else {
try {
xmlBeanDefinition.setConstructor(clazz.getConstructor(new Class<?>[0]));
} catch (Throwable e) {
error("The '" + className + "' gets constructor error");
}
}
// gets all interface name
String[] names = ReflectUtils.getInterfaceNames(clazz);
xmlBeanDefinition.setInterfaceNames(names);
log.debug("class [{}] names size [{}]", className, names.length);
// gets all properties
List<Element> properties = dom.elements(ele, PROPERTY_ELEMENT);
if (properties != null) {
for (Element property : properties) {
String name = property.getAttribute(NAME_ATTRIBUTE);
XmlManagedNode xmlManagedNode = parseXmlManagedNode(property, dom);
if(xmlManagedNode != null && VerifyUtils.isNotEmpty(name)) {
xmlBeanDefinition.getProperties().put(name, xmlManagedNode);
}
}
}