beanType.pushInterceptor(constructorQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) child;
bean.setConstructor(constructor);
}
});
// beanfactory has a constructor
beanFactoryType.pushInterceptor(constructorQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) child;
Set<AbstractPropertyMetaData> properties = bean.getProperties();
properties.add(new AbstractPropertyMetaData("constructor", new AbstractValueMetaData(constructor)));
}
});
// constructor binding
TypeBinding constructorType = schemaBinding.getType(constructorTypeQName);
constructorType.setHandler(new DefaultElementHandler()
{
public Object startElement(Object parent, QName name, ElementBinding element)
{
return new AbstractConstructorMetaData();
}
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
{
AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) o;
for (int i = 0; i < attrs.getLength(); ++i)
{
String localName = attrs.getLocalName(i);
if ("factoryClass".equals(localName))
constructor.setFactoryClass(attrs.getValue(i));
else if ("factoryMethod".equals(localName))
constructor.setFactoryMethod(attrs.getValue(i));
}
}
});
// constructor has a factory
constructorType.pushInterceptor(factoryQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) parent;
AbstractDependencyValueMetaData factory = (AbstractDependencyValueMetaData) child;
constructor.setFactory(factory);
}
});
// constructor has a list parameters
constructorType.pushInterceptor(parameterQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) parent;
AbstractParameterMetaData parameter = (AbstractParameterMetaData) child;
List<AbstractParameterMetaData> parameters = constructor.getParameters();
if (parameters == null)
{
parameters = new ArrayList<AbstractParameterMetaData>();
constructor.setParameters(parameters);
}
parameters.add(parameter);
}
});