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);
}
});
// 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);
}
});
// 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<AbstractParameterMetaData> parameters = lifecycle.getParameters();
if (parameters == null)
{
parameters = new ArrayList<AbstractParameterMetaData>();
lifecycle.setParameters(parameters);
}
parameters.add(parameter);
}
});