constructorType.pushInterceptor(parameterQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) parent;
AbstractParameterMetaData parameter = (AbstractParameterMetaData) child;
List parameters = constructor.getParameters();
if (parameters == null)
{
parameters = new ArrayList();
constructor.setParameters(parameters);
}
parameters.add(parameter);
}
});
// parameter binding
TypeBinding parameterType = schemaBinding.getType(parameterTypeQName);
configureValueBindings(parameterType);
parameterType.setHandler(new DefaultElementHandler()
{
public Object startElement(Object parent, QName name, ElementBinding element)
{
return new AbstractParameterMetaData();
}
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
{
AbstractParameterMetaData parameter = (AbstractParameterMetaData) o;
for (int i = 0; i < attrs.getLength(); ++i)
{
String localName = attrs.getLocalName(i);
if ("class".equals(localName))
parameter.setType(attrs.getValue(i));
}
}
});
// parameter can take a value
parameterType.setSimpleType(new CharactersHandler()
{
public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
{
return new StringValueMetaData(value);
}
public void setValue(QName qName, ElementBinding element, Object owner, Object value)
{
AbstractParameterMetaData parameter = (AbstractParameterMetaData) owner;
parameter.setValue((StringValueMetaData) value);
}
});
// bean has a create
beanType.pushInterceptor(createQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
bean.setCreate(lifecycle);
}
});
// beanfactory has a create
beanFactoryType.pushInterceptor(createQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
GenericBeanFactoryMetaData bean = (GenericBeanFactoryMetaData) parent;
AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
bean.setBeanCreate(lifecycle);
}
});
// bean has a start
beanType.pushInterceptor(startQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
bean.setStart(lifecycle);
}
});
// beanfactory has a start
beanFactoryType.pushInterceptor(startQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
GenericBeanFactoryMetaData bean = (GenericBeanFactoryMetaData) parent;
AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
bean.setBeanStart(lifecycle);
}
});
// bean has a stop
beanType.pushInterceptor(stopQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
bean.setStop(lifecycle);
}
});
// bean has a destroy
beanType.pushInterceptor(destroyQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
bean.setDestroy(lifecycle);
}
});
// lifecycle binding
TypeBinding lifecycleType = schemaBinding.getType(lifecycleTypeQName);
lifecycleType.setHandler(new DefaultElementHandler()
{
public Object startElement(Object parent, QName name, ElementBinding element)
{
return new AbstractLifecycleMetaData();
}
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
{
AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) o;
for (int i = 0; i < attrs.getLength(); ++i)
{
String localName = attrs.getLocalName(i);
if ("method".equals(localName))
lifecycle.setMethodName(attrs.getValue(i));
}
}
});
// lifecycle has a list parameters
lifecycleType.pushInterceptor(parameterQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) parent;
AbstractParameterMetaData parameter = (AbstractParameterMetaData) child;
List parameters = lifecycle.getParameters();
if (parameters == null)
{
parameters = new ArrayList();
lifecycle.setParameters(parameters);