return count;
}
private ConstructorArgumentValues resolveConstructorValues(
IConfigurationElement beanElement) {
ConstructorArgumentValues constructorValues = new ConstructorArgumentValues();
IConfigurationElement[] constructorElements = beanElement
.getChildren("constructor-arg");
for (int i = 0; i < constructorElements.length; i++) {
IConfigurationElement constructorElement = constructorElements[i];
String type = constructorElement.getAttribute("type");
String indexString = constructorElement.getAttribute("index");
if (log.isDebugEnabled()) {
log.debug("found a constructor-arg: [index=" + indexString
+ ";type=" + type + "]");
}
IConfigurationElement[] values = constructorElement.getChildren();
if (values.length > 0) {
IConfigurationElement value = values[0];
ValueHolder constructorValue = null;
if ("ref".equals(value.getName())) {
String ref = value.getAttribute("bean");
if (log.isDebugEnabled()) {
log.debug("constructor-arg references the bean: [name="
+ ref + "]");
}
constructorValue = new ValueHolder(
new RuntimeBeanReference(ref), type);
} else if ("value".equals(value.getName())) {
String valueString = value.getValue();
if (log.isDebugEnabled()) {
log.debug("constructor-arg has a value: ["
+ valueString + "]");
}
constructorValue = new ValueHolder(valueString, type);
} else if ("null".equals(value.getName())) {
if (log.isDebugEnabled()) {
log.debug("constructor-arg has a null value");
}
constructorValue = new ValueHolder(null, type);
}
if (constructorValue != null) {
int index = -1;
try {
index = Integer.parseInt(indexString);
} catch (NumberFormatException e) {
if (log.isWarnEnabled()) {
log.warn("constructor-arg index is invalid: " + e);
}
}
if (index >= 0) {
if (log.isDebugEnabled()) {
log.debug("constructor-arg added to the index: ["
+ index + "]");
}
constructorValues.addIndexedArgumentValue(index,
constructorValue);
} else {
if (log.isDebugEnabled()) {
log.debug("constructor-arg added without index");
}
constructorValues
.addGenericArgumentValue(constructorValue);
}
} else if (log.isWarnEnabled()) {
log
.warn("contructor-arg value is null; could not be added");