beanType.setHandler(new DefaultElementHandler()
{
public Object startElement(Object parent, QName name, ElementBinding element)
{
return new Holder();
}
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
{
Holder holder = (Holder) o;
String className = null;
for (int i = 0; i < attrs.getLength(); ++i)
{
String localName = attrs.getLocalName(i);
if ("class".equals(localName))
className = attrs.getValue(i);
}
if (className == null)
throw new IllegalArgumentException("No class attribute for " + elementName);
try
{
BeanInfo beanInfo = ConfigurationUtil.getBeanInfo(className);
Object object = beanInfo.newInstance();
holder.setValue(object);
}
catch (RuntimeException e)
{
throw e;
}
catch (Error e)
{
throw e;
}
catch (Throwable t)
{
throw new RuntimeException("Error instantiating class " + className, t);
}
}
public Object endElement(Object o, QName qName, ElementBinding element)
{
Holder holder = (Holder) o;
return holder.getValue();
}
});
// bean has properties
beanType.pushInterceptor(propertyQName, new DefaultElementInterceptor()
{
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