deploymentType.pushInterceptor(classloaderQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractKernelDeployment deployment = (AbstractKernelDeployment) parent;
AbstractClassLoaderMetaData classloader = (AbstractClassLoaderMetaData) child;
deployment.setClassLoader(classloader);
// add classloaders as value beans
List<BeanMetaDataFactory> beans = deployment.getBeanFactories();
if (beans == null)
{
beans = new ArrayList<BeanMetaDataFactory>();
deployment.setBeanFactories(beans);
}
beans.add(classloader);
}
});
// deployment has a list beans
deploymentType.pushInterceptor(beanQName, new DefaultElementInterceptor()
{
public void add(Object parent, Object child, QName name)
{
AbstractKernelDeployment deployment = (AbstractKernelDeployment) parent;
AbstractBeanMetaData bean = (AbstractBeanMetaData) child;
List<BeanMetaDataFactory> beans = deployment.getBeanFactories();
if (beans == null)
{
beans = new ArrayList<BeanMetaDataFactory>();
deployment.setBeanFactories(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<BeanMetaDataFactory> beans = deployment.getBeanFactories();
if (beans == null)
{
beans = new ArrayList<BeanMetaDataFactory>();
deployment.setBeanFactories(beans);
}
beans.add(bean);
}
});
// bean binding
TypeBinding beanType = schemaBinding.getType(beanTypeQName);
/*
ClassMetaData classMetaData = new ClassMetaData();
classMetaData.setImpl(AbstractBeanMetaData.class.getName());
beanType.setClassMetaData(classMetaData);
QName CLASS = new QName("class");
AttributeBinding attribute = beanType.getAttribute(CLASS);
PropertyMetaData propertyMetaData = new PropertyMetaData();
propertyMetaData.setName("bean");
attribute.setPropertyMetaData(propertyMetaData);
QName MODE = new QName("mode");
attribute = beanType.getAttribute(MODE);
ValueAdapter modeAdapter = new ValueAdapter()
{
public Object cast(Object o, Class c)
{
String string = (String) o;
return new ControllerMode(string);
}
};
attribute.setValueAdapter(modeAdapter);
*/
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)
{
}