[jboss-dev-forums] [Design of JBossXB] - Mixing wildcards and elements
kabir.khan@jboss.com
do-not-reply at jboss.com
Mon Apr 28 14:34:17 EDT 2008
Alex,
Can you please take a quick look at the XmlLoadableAopTestCase in the aop-mc-int project?
Basically we have
| @JBossXmlSchema(namespace="urn:jboss:aop-beans:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
| @XmlRootElement(name="aspect")
| public class AspectBeanMetaDataFactory extends AspectManagerAwareBeanMetaDataFactory
| implements BeanMetaDataFactory
| {
| ...
| private List<Element> elements;
|
|
| public List<Element> getElements()
| {
| return elements;
| }
|
| @XmlAnyElement(lax=true)
| public void setElements(List<Element> elements)
| {
| this.elements = elements;
| }
|
| @Override
| public List<BeanMetaData> getBeans()
| {
| ArrayList<BeanMetaData> result = new ArrayList<BeanMetaData>();
| this.name = super.getBean();
| }
|
| }
|
| @XmlRootElement(name="beanfactory")
| @XmlType(name="beanfactoryType", propOrder={"aliases", "annotations", "classLoader", "constructor", "properties", "create", "start", "depends", "demands", "supplies", "installs", "uninstalls", "installCallbacks", "uninstallCallbacks"})
| public class GenericBeanFactoryMetaData extends JBossObject implements BeanMetaDataFactory, Serializable
| {
| ...
| protected Set<PropertyMetaData> properties;
|
| public Set<PropertyMetaData> getProperties()
| {
| return properties;
| }
|
| @XmlElement(name="property", type=AbstractPropertyMetaData.class)
| public void setProperties(Set<PropertyMetaData> properties)
| {
| this.properties = properties;
| }
|
| public List<BeanMetaData> getBeans()
| {
| ...
| if (properties != null && properties.size() > 0)
| {
| PropertyMap propertyMap = new PropertyMap();
| for (PropertyMetaData property : properties) //CCE as explained below
| {
| propertyMap.put(property.getName(), property.getValue());
| }
| builder.addPropertyMetaData("properties", propertyMap);
| }
| ...
| }
| }
|
In XmlLoadableAopTestCase.xml I have the following defined:
| <aspect class="org.jboss.test.microcontainer.beans.XmlLoadableAspect">
| <somexml>hello</somexml>
| <attribute name="IntAttr">12</attribute>
| <!-- <property name="property">Test1</property> -->
| </aspect>
|
"attribute" and "somexml" are wildcards, while "property" is declared on GBFMD. As it is the test is fine. If I remove somexml and attribute, and uncomment property it also parses fine. If I enable all three elements, I get a CCE at the point shown in GBFMD.getBEans(), since the properties map now contains one element of type org.apache.xerces.dom.ElementNSImpl instead of PropertyMetaData. I tried to reproduce this in the jbossxb project, but it worked as expected there, so I have probably missed some minor detail?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147322#4147322
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147322
More information about the jboss-dev-forums
mailing list