deploymentType.pushInterceptor(beanQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractKernelDeployment deployment = (AbstractKernelDeployment) parent;
AbstractBeanMetaData bean = (AbstractBeanMetaData) child;
List beans = deployment.getBeans();
if (beans == null)
{
beans = new ArrayList();
deployment.setBeans(beans);
}
beans.add(bean);
}
});
// deployment has a list beanfactorys
deploymentType.pushInterceptor(beanFactoryQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractKernelDeployment deployment = (AbstractKernelDeployment) parent;
AbstractBeanMetaData bean = (AbstractBeanMetaData) child;
List beans = deployment.getBeans();
if (beans == null)
{
beans = new ArrayList();
deployment.setBeans(beans);
}
beans.add(bean);
}
});
// bean binding
TypeBinding beanType = schemaBinding.getType(beanTypeQName);
beanType.setHandler(new DefaultElementHandler()
{
public Object startElement(Object parent, QName name, ElementBinding element)
{
return new AbstractBeanMetaData();
}
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) o;
for (int i = 0; i < attrs.getLength(); ++i)
{
String localName = attrs.getLocalName(i);
if ("name".equals(localName))
bean.setName(attrs.getValue(i));
else if ("class".equals(localName))
bean.setBean(attrs.getValue(i));
else if ("mode".equals(localName))
bean.setMode(new ControllerMode(attrs.getValue(i)));
}
}
});
// beanfactory binding
TypeBinding beanFactoryType = schemaBinding.getType(beanFactoryTypeQName);
beanFactoryType.setHandler(new DefaultElementHandler()
{
public Object startElement(Object parent, QName name, ElementBinding element)
{
return new GenericBeanFactoryMetaData();
}
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
{
GenericBeanFactoryMetaData bean = (GenericBeanFactoryMetaData) o;
for (int i = 0; i < attrs.getLength(); ++i)
{
String localName = attrs.getLocalName(i);
if ("name".equals(localName))
bean.setName(attrs.getValue(i));
else if ("class".equals(localName))
bean.setBeanClass(attrs.getValue(i));
else if ("mode".equals(localName))
bean.setMode(new ControllerMode(attrs.getValue(i)));
}
}
});
// bean has a classloader
beanType.pushInterceptor(classloaderQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractClassLoaderMetaData classloader = (AbstractClassLoaderMetaData) child;
bean.setClassLoader(classloader);
}
});
// beanfactory has a classloader
beanFactoryType.pushInterceptor(classloaderQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
GenericBeanFactoryMetaData bean = (GenericBeanFactoryMetaData) parent;
AbstractClassLoaderMetaData classloader = (AbstractClassLoaderMetaData) child;
bean.setClassLoader(classloader);
}
});
// bean has a constructor
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)
{
GenericBeanFactoryMetaData bean = (GenericBeanFactoryMetaData) parent;
AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) child;
bean.setBeanConstructor(constructor);
}
});
// classloader binding
TypeBinding classloaderType = schemaBinding.getType(classloaderTypeQName);
configureValueBindings(classloaderType);
classloaderType.setHandler(new DefaultElementHandler()
{
public Object startElement(Object parent, QName name, ElementBinding element)
{
return new AbstractClassLoaderMetaData();
}
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
{
}
});
// 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 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);
}
parameters.add(parameter);
}
});
// bean has a set of properties
beanType.pushInterceptor(propertyQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractPropertyMetaData property = (AbstractPropertyMetaData) child;
Set properties = bean.getProperties();
if (properties == null)
{
properties = new HashSet();
bean.setProperties(properties);
}
properties.add(property);
}
});
// beanfactory has a set of properties
beanFactoryType.pushInterceptor(propertyQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
GenericBeanFactoryMetaData bean = (GenericBeanFactoryMetaData) parent;
AbstractPropertyMetaData property = (AbstractPropertyMetaData) child;
bean.addBeanProperty(property);
}
});
// bean has a set of depends
beanType.pushInterceptor(dependsQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractDependencyMetaData dependency = (AbstractDependencyMetaData) child;
Set demands = bean.getDemands();
if (demands == null)
{
demands = new HashSet();
bean.setDemands(demands);
}
demands.add(dependency);
}
});
// beanfactory has a set of depends
beanFactoryType.pushInterceptor(dependsQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
GenericBeanFactoryMetaData bean = (GenericBeanFactoryMetaData) parent;
AbstractDependencyMetaData dependency = (AbstractDependencyMetaData) child;
Set demands = bean.getDemands();
if (demands == null)
{
demands = new HashSet();
bean.setDemands(demands);
}
demands.add(dependency);
}
});
// bean has a set of demands
beanType.pushInterceptor(demandQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractDemandMetaData demand = (AbstractDemandMetaData) child;
Set demands = bean.getDemands();
if (demands == null)
{
demands = new HashSet();
bean.setDemands(demands);
}
demands.add(demand);
}
});
// beanfactory has a set of demands
beanFactoryType.pushInterceptor(demandQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractDemandMetaData demand = (AbstractDemandMetaData) child;
Set demands = bean.getDemands();
if (demands == null)
{
demands = new HashSet();
bean.setDemands(demands);
}
demands.add(demand);
}
});
// bean has a set of supplies
beanType.pushInterceptor(supplyQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractSupplyMetaData supply = (AbstractSupplyMetaData) child;
Set supplies = bean.getSupplies();
if (supplies == null)
{
supplies = new HashSet();
bean.setSupplies(supplies);
}
supplies.add(supply);
}
});
// beanfactory has a set of supplies
beanFactoryType.pushInterceptor(supplyQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
AbstractSupplyMetaData supply = (AbstractSupplyMetaData) child;
Set supplies = bean.getSupplies();
if (supplies == null)
{
supplies = new HashSet();
bean.setSupplies(supplies);
}
supplies.add(supply);
}
});