public void add(Object parent, Object child, QName name)
{
Holder holder = (Holder) parent;
Object parentValue = holder.getValue();
Property prop = (Property) child;
String property = prop.getProperty();
Object value = prop.getValue();
try
{
BeanInfo info = ConfigurationUtil.getBeanInfo(parentValue.getClass());
value = ConfigurationUtil.convertValue(parentValue, property, prop.getType(), value);
info.setProperty(parentValue, property, value);
}
catch (RuntimeException e)
{
throw e;
}
catch (Error e)
{
throw e;
}
catch (Throwable t)
{
throw new RuntimeException("Error setting property " + property + " on object" + parentValue + " with value " + value, t);
}
}
});
// property binding
TypeBinding propertyType = schema.getType(propertyTypeQName);
propertyType.setHandler(new DefaultElementHandler()
{
public Object startElement(Object parent, QName name, ElementBinding element)
{
return new Property();
}
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
{
Property property = (Property) o;
for (int i = 0; i < attrs.getLength(); ++i)
{
String localName = attrs.getLocalName(i);
if ("name".equals(localName))
property.setProperty(attrs.getValue(i));
else if ("class".equals(localName))
property.setType(attrs.getValue(i));
}
}
});
return schema;