1 2 3 4 Previous Next 52 Replies Latest reply: Mar 25, 2008 10:03 AM by Kabir Khan Go to original post RSS
  • 15. Re: Implementing JAXB style parsing for aop-mc-int
    Kabir Khan Master

    The output is too long to paste here, but I think this part of the dumped schema is relevant:

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     targetNamespace="urn:jboss:aop-beans:1.0"
     xmlns="urn:jboss:aop-beans:1.0"
    >
    
     <element name="{urn:jboss:aop-beans:1.0}bean" type="{urn:jboss:aop-beans:1.0}abstract-bean-meta-data">
     </element>
     <element name="{urn:jboss:bean-deployer:2.0}bean" type="{urn:jboss:aop-beans:1.0}abstract-bean-meta-data">
     </element>
    ....
     <complexType name="{urn:jboss:aop-beans:1.0}abstract-bean-meta-data" base="xsd:anyType">
     <sequence>
     <sequence minOccurs="0">
     <element name="{urn:jboss:aop-beans:1.0}alias" minOccurs="0" type="{http://www.w3.org/2001/XMLSchema}string">
     </element>
     </sequence>
     <sequence minOccurs="0">
     <element name="{urn:jboss:aop-beans:1.0}annotation" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-annotation-meta-data">
     </element>
     </sequence>
     <element name="{urn:jboss:aop-beans:1.0}classloader" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-class-loader-meta-data">
     </element>
     <element name="{urn:jboss:aop-beans:1.0}constructor" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-constructor-meta-data">
     </element>
     <sequence minOccurs="0">
     <element name="{urn:jboss:aop-beans:1.0}property" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-property-meta-data">
     </element>
     </sequence>
     <element name="{urn:jboss:aop-beans:1.0}create" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-lifecycle-meta-data">
     </element>
     <element name="{urn:jboss:aop-beans:1.0}start" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-lifecycle-meta-data">
     </element>
     <element name="{urn:jboss:aop-beans:1.0}stop" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-lifecycle-meta-data">
     </element>
     <element name="{urn:jboss:aop-beans:1.0}destroy" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-lifecycle-meta-data">
     </element>
     <sequence minOccurs="0">
     <element name="{urn:jboss:aop-beans:1.0}depends" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-dependency-meta-data">
     </element>
     </sequence>
     <sequence minOccurs="0">
     <element name="{urn:jboss:aop-beans:1.0}demand" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-demand-meta-data">
     </element>
     </sequence>
     <sequence minOccurs="0">
     <element name="{urn:jboss:aop-beans:1.0}supply" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-supply-meta-data">
     </element>
     </sequence>
     <sequence minOccurs="0">
     <element name="{urn:jboss:aop-beans:1.0}install" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-install-meta-data">
     </element>
     </sequence>
     <sequence minOccurs="0">
     <element name="{urn:jboss:aop-beans:1.0}uninstall" minOccurs="0" type="{urn:jboss:aop-beans:1.0}abstract-install-meta-data">
     </element>
     </sequence>
     <sequence minOccurs="0">
     <element name="{urn:jboss:aop-beans:1.0}incallback" minOccurs="0" type="{urn:jboss:aop-beans:1.0}install-callback-meta-data">
     </element>
     </sequence>
     <sequence minOccurs="0">
     <element name="{urn:jboss:aop-beans:1.0}uncallback" minOccurs="0" type="{urn:jboss:aop-beans:1.0}uninstall-callback-meta-data">
     </element>
     </sequence>
     </sequence>
     <attribute name="autowire-type" type="CDATA" optional="true"/>
     <attribute name="abstract" type="{http://www.w3.org/2001/XMLSchema}boolean" optional="true"/>
     <attribute name="class" type="{http://www.w3.org/2001/XMLSchema}string" optional="true"/>
     <attribute name="mode" type="CDATA" optional="true"/>
     <attribute name="autowire-candidate" type="{http://www.w3.org/2001/XMLSchema}boolean" optional="true"/>
     <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" optional="true"/>
     <attribute name="parent" type="{http://www.w3.org/2001/XMLSchema}string" optional="true"/>
     </complexType>
    ...
    

    My AOPDeployment class
    @JBossXmlSchema(namespace="urn:jboss:aop-beans:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
    @XmlRootElement(name="aop")
    @XmlType(propOrder={"annotations", "classLoader", "beanFactories", "create", "start", "stop", "destroy", "aliases"})
    public class AOPDeployment extends AbstractKernelDeployment
    {
     private static final long serialVersionUID = 1L;
    
    
     @XmlElements
     ({
     @XmlElement(name="bean", type=AbstractBeanMetaData.class),
     @XmlElement(name="bean", namespace="urn:jboss:bean-deployer:2.0", type=AbstractBeanMetaData.class),
     @XmlElement(name="beanfactory", type=GenericBeanFactoryMetaData2.class),
     @XmlElement(name="beanfactory", namespace="urn:jboss:bean-deployer:2.0", type=GenericBeanFactoryMetaData2.class),
     @XmlElement(name="lazy", type=AbstractLazyMetaData.class),
     @XmlElement(name="lazy", namespace="urn:jboss:bean-deployer:2.0", type=AbstractLazyMetaData.class),
     @XmlElement(name="aspect", type=AspectBeanMetaDataFactory.class),
     @XmlElement(name="interceptor", type=InterceptorBeanMetaDataFactory.class),
     @XmlElement(name="bind", type=BindBeanMetaDataFactory.class),
     @XmlElement(name="stack", type=StackBeanMetaDataFactory.class),
     @XmlElement(name="typedef", type=TypeDefBeanMetaDataFactory.class),
     @XmlElement(name="cflow-stack", type=CFlowStackBeanMetaDataFactory.class)
     })
     @XmlAnyElement
     public void setBeanFactories(List<BeanMetaDataFactory> beanFactories)
     {
     super.setBeanFactories(beanFactories);
     }
    }
    

    If that is not enough, the code is commited and aop-mc-int/src/tests/org.jboss.test.microcontainer.beans.test.AspectSimpleJaxbAopTestCase demonstrates the problem



  • 16. Re: Implementing JAXB style parsing for aop-mc-int
    Adrian Brock Master

     

    "kabir.khan@jboss.com" wrote:

    My AOPDeployment class
     @XmlElement(name="bean", namespace="urn:jboss:bean-deployer:2.0",
    



    You took me too literally. :-)

    The example above was only intended to show
    how the annotations work (you were using them wrong), it wasn't intended to be copied.

    That's why I said

    Illustrative example (trying to show how it works):


    I've removed the elements that are in the MC namespace
    which should be handled by the wildcard (@XmlAnyElement) not explicitly listed.

    What you've defined is a {urn:jboss:aop-beans:1.0}bean and a
    {urn:jboss:bean-deployer:2.0}bean in your namespace that are children
    of deployment. But that doesn't override the child elements which will still be
    in your namespace.

    i.e. both with have {urn:jboss:aop-beans:1.0}constructor

    You should let the MC schema define the {urn:jboss:bean-deployer:2.0}bean
    and use it as a "wildcard".

  • 17. Re: Implementing JAXB style parsing for aop-mc-int
    Adrian Brock Master

    Question: Do you really want an aop:bean? Is that just for ease of use?

    It doesn't actually make much difference, except you'll have to reproduce all the MC schema
    in your schema using your namespace (and maintain it every time it changes ;-)

  • 18. Re: Implementing JAXB style parsing for aop-mc-int
    Adrian Brock Master

    Also, you changed the .classpath of aop-mc-int to use AOP CR4, but the
    build/pom.xml still says AOP CR3, so I reverted this change.

  • 19. Re: Implementing JAXB style parsing for aop-mc-int
    Kabir Khan Master

     

    "adrian@jboss.org" wrote:
    Question: Do you really want an aop:bean? Is that just for ease of use?


    No, I didn't understand properly and blindly followed your example :-) Now it makes a lot more sense wrt @XmlAnyElement.

    I now have
     @XmlElements
     ({
     @XmlElement(name="aspect", type=AspectBeanMetaDataFactory.class),
     @XmlElement(name="interceptor", type=InterceptorBeanMetaDataFactory.class),
     @XmlElement(name="bind", type=BindBeanMetaDataFactory.class),
     @XmlElement(name="stack", type=StackBeanMetaDataFactory.class),
     @XmlElement(name="typedef", type=TypeDefBeanMetaDataFactory.class),
     @XmlElement(name="cflow-stack", type=CFlowStackBeanMetaDataFactory.class)
     })
     @XmlAnyElement
     public void setBeanFactories(List<BeanMetaDataFactory> beanFactories)
     {
     super.setBeanFactories(beanFactories);
     }
    

    and that works great. Thanks for your help

  • 20. Re: Implementing JAXB style parsing for aop-mc-int
    Kabir Khan Master

    Next stumbling block is trying to deploy things like

    <?xml version="1.0" encoding="UTF-8"?>
    
    <deployment xmlns="urn:jboss:bean-deployer:2.0">
    
     <bean name="AspectManager" class="org.jboss.aop.AspectManager">
     <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
     </bean>
    
     <aop:aspect xmlns:aop="urn:jboss:aop-beans:1.0" class="org.jboss.test.microcontainer.beans.TestAspectWithDependency">
     <property xmlns="urn:jboss:bean-deployer:2.0" name="dependency"><inject bean="Dependency"/></property>
     </aop:aspect>
    
     ....
    </deployment>
    


    I get an error trying to handle the "property" element:
    org.jboss.xb.binding.JBossXBException: Failed to parse source: file:/C:/cygwin/home/Kabir/sourcecontrol/microcontainer/aop-mc-int/target/tests-classes/org/jboss/test/microcontainer/beans/test/AspectWithDependencyJaxbDeploymentTestCaseNotAutomatic1.xml@10,69
     at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:177)
     at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:139)
     at org.jboss.test.xb.builder.JBossXBTestDelegate.unmarshal(JBossXBTestDelegate.java:122)
     at org.jboss.test.aop.junit.JBossXBDeployer.unmarshal(JBossXBDeployer.java:81)
     at org.jboss.test.aop.junit.JBossXBDeployer.deploy(JBossXBDeployer.java:124)
     at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.deploy(MicrocontainerTestDelegate.java:289)
     at org.jboss.test.kernel.junit.MicrocontainerTest.deploy(MicrocontainerTest.java:233)
     at org.jboss.test.microcontainer.beans.test.AspectWithDependencyTest.testInterceptorWithDependencyCorrectOrder(AspectWithDependencyTest.java:55)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at junit.framework.TestCase.runTest(TestCase.java:154)
     at junit.framework.TestCase.runBare(TestCase.java:127)
     at junit.framework.TestResult$1.protect(TestResult.java:106)
     at junit.framework.TestResult.runProtected(TestResult.java:124)
     at junit.framework.TestResult.run(TestResult.java:109)
     at junit.framework.TestCase.run(TestCase.java:118)
     at junit.framework.TestSuite.runTest(TestSuite.java:208)
     at junit.framework.TestSuite.run(TestSuite.java:203)
     at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
     at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
     at junit.framework.TestResult.runProtected(TestResult.java:124)
     at junit.extensions.TestSetup.run(TestSetup.java:23)
     at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: org.jboss.xb.binding.JBossXBRuntimeException: {urn:jboss:bean-deployer:2.0}property not found as a child of {urn:jboss:aop-beans:1.0}aspect
     at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:396)
     at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:407)
     at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
     at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
     at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
     at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
     at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
     at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:173)
     ... 29 more
    


    In my original schema, I had the type for aspect extending the beans abstractBeanfactoryType:
     <xsd:complexType name="aopBeanfactoryType">
     <xsd:annotation>
     <xsd:documentation>
     Similar to the beans beanfactoryType, but with an optional class
     </xsd:documentation>
     </xsd:annotation>
     <xsd:complexContent>
     <xsd:extension base="mc:abstractBeanfactoryType">
     <xsd:attribute name="class" type="xsd:token" use="required"/>
     </xsd:extension>
     </xsd:complexContent>
     </xsd:complexType>
    
     <xsd:complexType name="aspectOrInterceptorType">
     <xsd:annotation>
     <xsd:documentation>
     <![CDATA[
     aspects or interceptors
     ]]>
     </xsd:documentation>
     </xsd:annotation>
     <xsd:complexContent>
     <xsd:extension base="aopBeanfactoryType">
     <xsd:attribute name="scope" type="xsd:string" use="optional"/>
     <xsd:attribute name="factory" type="xsd:string" use="optional"/>
     <xsd:attribute name="manager-bean" type="xsd:string" use="optional"/>
     <xsd:attribute name="manager-property" type="xsd:string" use="optional"/>
     </xsd:extension>
     </xsd:complexContent>
     </xsd:complexType>
    


    Is there a way to mimic that using the JAXB style parsing?

    org.jboss.aop.microcontainer.beans.beanmetadatafactory.AspectBeanMetaDataFactory does not handle the property field in any special way:

    @JBossXmlSchema(namespace="urn:jboss:aop-beans:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
    @XmlRootElement(name="aspect")
    @XmlType(propOrder={"aliases", "annotations", "classLoader", "constructor", "properties", "create", "start", "depends", "demands", "supplies", "installs", "uninstalls"})
    public class AspectBeanMetaDataFactory extends AspectManagerAwareBeanMetaDataFactory
     implements BeanMetaDataFactory
    {
     ...
    }
    
    


    AspectBeanMetaDataFactory extends AspectManagerAwareBeanMetaDataFactory extends GenericBeanFactoryMetaData extends AbstractBeanMetaData
    @JBossXmlSchema(namespace="urn:jboss:bean-deployer:2.0", elementFormDefault=XmlNsForm.QUALIFIED)
    @XmlRootElement(name="bean")
    @XmlType(propOrder={"aliases", "annotations", "classLoader", "constructor", "properties", "create", "start", "stop", "destroy", "depends", "demands", "supplies", "installs", "uninstalls", "installCallbacks", "uninstallCallbacks"})
    public class AbstractBeanMetaData extends AbstractFeatureMetaData
     implements BeanMetaData, BeanMetaDataFactory, MutableLifecycleHolder, Serializable
    {
     private static final long serialVersionUID = 3L;
    
     @XmlElement(name="property", namespace="urn:jboss:bean-deployer:2.0", type=AbstractPropertyMetaData.class)
     public void setProperties(Set<PropertyMetaData> properties)
     {
     this.properties = properties;
     flushJBossObjectCache();
     }
    
    


    If I include a setProperties() method in AspectBeanMetaDataFactory to include the namespace it gets a bit further
    @JBossXmlSchema(namespace="urn:jboss:aop-beans:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
    @XmlRootElement(name="aspect")
    @XmlType(propOrder={"aliases", "annotations", "classLoader", "constructor", "properties", "create", "start", "depends", "demands", "supplies", "installs", "uninstalls"})
    public class AspectBeanMetaDataFactory extends AspectManagerAwareBeanMetaDataFactory
     implements BeanMetaDataFactory
    {
     ...
     @XmlElement(name="property", namespace="urn:jboss:bean-deployer:2.0", type=AbstractPropertyMetaData.class)
     public void setProperties(Set<PropertyMetaData> properties)
     {
     this.properties = properties;
     flushJBossObjectCache();
     }
    

    it then chokes on the nested "inject" field.

    org.jboss.xb.binding.JBossXBException: Failed to parse source: file:/C:/cygwin/home/Kabir/sourcecontrol/microcontainer/aop-mc-int/target/tests-classes/org/jboss/test/microcontainer/beans/test/AspectWithDependencyJaxbDeploymentTestCaseNotAutomatic1.xml@10,96
     at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:177)
     at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:139)
     at org.jboss.test.xb.builder.JBossXBTestDelegate.unmarshal(JBossXBTestDelegate.java:122)
     at org.jboss.test.aop.junit.JBossXBDeployer.unmarshal(JBossXBDeployer.java:81)
     at org.jboss.test.aop.junit.JBossXBDeployer.deploy(JBossXBDeployer.java:124)
     at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.deploy(MicrocontainerTestDelegate.java:289)
     at org.jboss.test.kernel.junit.MicrocontainerTest.deploy(MicrocontainerTest.java:233)
     at org.jboss.test.microcontainer.beans.test.AspectWithDependencyTest.testInterceptorWithDependencyCorrectOrder(AspectWithDependencyTest.java:55)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at junit.framework.TestCase.runTest(TestCase.java:154)
     at junit.framework.TestCase.runBare(TestCase.java:127)
     at junit.framework.TestResult$1.protect(TestResult.java:106)
     at junit.framework.TestResult.runProtected(TestResult.java:124)
     at junit.framework.TestResult.run(TestResult.java:109)
     at junit.framework.TestCase.run(TestCase.java:118)
     at junit.framework.TestSuite.runTest(TestSuite.java:208)
     at junit.framework.TestSuite.run(TestSuite.java:203)
     at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
     at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
     at junit.framework.TestResult.runProtected(TestResult.java:124)
     at junit.extensions.TestSetup.run(TestSetup.java:23)
     at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: org.jboss.xb.binding.JBossXBRuntimeException: {urn:jboss:bean-deployer:2.0}inject not found as a child of {urn:jboss:bean-deployer:2.0}property
     at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:396)
     at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:407)
     at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
     at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
     at org.apache.xerces.xinclude.XIncludeHandler.emptyElement(Unknown Source)
     at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
     at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
     at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
     at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:173)
     ... 29 more
    


    I could possibly fix that by adding namespaces to things, but it does not feel like the right approach to me? This sounds similar to what I think you meant here, but I am not sure?
    "adrian@jboss.org" wrote:

    It doesn't actually make much difference, except you'll have to reproduce all the MC schema
    in your schema using your namespace (and maintain it every time it changes ;-)



    I also tried modifying the xml
    <?xml version="1.0" encoding="UTF-8"?>
    
    <deployment xmlns="urn:jboss:bean-deployer:2.0">
    
     <bean name="AspectManager" class="org.jboss.aop.AspectManager">
     <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
     </bean>
    
     <aop:aspect xmlns:aop="urn:jboss:aop-beans:1.0" class="org.jboss.test.microcontainer.beans.TestAspectWithDependency">
     <property xmlns="urn:jboss:bean-deployer:2.0" name="dependency"><inject xmlns="urn:jboss:bean-deployer:2.0" bean="Dependency"/></property>
     </aop:aspect>
     ...
    </deployment>
    


    but that yields the same problem
    org.jboss.xb.binding.JBossXBException: Failed to parse source: file:/C:/cygwin/home/Kabir/sourcecontrol/microcontainer/aop-mc-int/target/tests-classes/org/jboss/test/microcontainer/beans/test/AspectWithDependencyJaxbDeploymentTestCaseNotAutomatic1.xml@10,132
    ...
    Caused by: org.jboss.xb.binding.JBossXBRuntimeException: {urn:jboss:bean-deployer:2.0}inject not found as a child of {urn:jboss:bean-deployer:2.0}property
     at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:396)
     at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:407)
     at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
     at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
     at org.apache.xerces.xinclude.XIncludeHandler.emptyElement(Unknown Source)
     at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
     at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
     at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
     at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:173)
     ... 29 more
    
    


    The test to reproduce this is org.jboss.test.microcontainer.beans.test.AspectWithDependencyJaxbDeploymentTestCase.

  • 21. Re: Implementing JAXB style parsing for aop-mc-int
    Adrian Brock Master

    Kabir,

    Why have you written BeanMetaUtil?
    There already is a BeanMetaDataBuilder class inside the MC.

    You shouldn't have to reference any org.jboss.beans.metadata.plugins classes
    outside the MC project.

    Doing so, is just asking for trouble. :-)

  • 22. Re: Implementing JAXB style parsing for aop-mc-int
    Adrian Brock Master

    Also, why are using GenericBeanMetaData?

    I've deprecated this old class to avoid confusion, it can't possibly work
    with JBoss/AXB

  • 23. Re: Implementing JAXB style parsing for aop-mc-int
    Adrian Brock Master

    Even if you fix it to extends GenericBeanMetaDataFactory2 (or use your own factory),
    what you are trying to do isn't going to work at the moment.

    1) With the way the MC beans are currently marked up, there is no global
    type "property" in the MC schema. i.e. there is no @XmlRootElement
    or type name here:

    @XmlType(propOrder={"annotations", "value"})
    public class AbstractPropertyMetaData
    


    It should be something like this to conform with the schema document
    @XmlRootElement(name="property")
    @XmlType(name="property" propOrder={"annotations", "value"})
    


    This is obviously wrong and needs fixing.
    The same is true for a number of other types.

    2) But even if we did this, the way the builder is currently working
    is that if it finds a class in your class hierarchy, it will add it to your namespace.

    One way to fix this would be to mark it up as
    @XmlRootElement(name="property" namespace="urn:jboss:bean-deployer:2.0")
    @XmlType(name="property" namespace="urn:jboss:bean-deployer:2.0")
    

    but we don't want to do this, because then the MC couldn't re-use this class across
    versions.

    I know Alex added a feature where he introduced an xmlns annotation,
    but I don't know if it solves this problem. We'd need to ask him.

    3) The third point is that you just leave it as it
    and have all the mc elements and types in your namespace
    which means that users won't have to specify xmlns tags.

    <aspect xmlns:aop="urn:jboss:aop-beans:1.0" class="org.jboss.test.microcontainer.beans.TestAspectWithDependency">
     <property name="dependency"><inject bean="Dependency"/></property>
    </aspect>
    


  • 24. Re: Implementing JAXB style parsing for aop-mc-int
    Adrian Brock Master

    We could actually make (3) a lot easier to manage
    if we used xsd:redefine
    http://www.w3.org/TR/xmlschema-1/#modify-schema
    and shared a common schema to define the shared elements.

    i.e. create an mc-common.xsd with no target namespace
    and all the shared elements/types
    then we each redefine it into our own namespace.

    I think (3) would also reduce the amout of typing and baggage
    the user has to do, since they don't have to xmlns everywhere. ;-)

  • 25. Re: Implementing JAXB style parsing for aop-mc-int
    Kabir Khan Master

     

    "adrian@jboss.org" wrote:
    |
    There already is a BeanMetaDataBuilder class inside the MC.


    OK, that looks a lot nicer :-)

  • 27. Re: Implementing JAXB style parsing for aop-mc-int
    Kabir Khan Master

    Reading this thread http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134204#4134204 I came back to this. Regarding 3) What would this xsd:refine map to in jaxb annotations? My understanding was that using jaxb it generates a schema from the annotations?

    Apart from that, if I have understood you correctly, mc-commons.xsd would contain the current bean_deployer_2_0.xsd.

    I would then be able to do

    <aop>
     <bean name="Bean" class="Foo"/>
     <aspect class="MyAspect" scope="PER_VM">
     <property name="thing">XXX</property>
     </aspect>
    </aop>
    


    If I wanted to do this the other way around, I would need to use xmlns on the aop specific elements
    <deployment>
     <bean name="Bean" class="Foo"/>
     <aspect xmlns:aop="urn:jboss:aop-beans:1.0" class="MyAspect" scope="PER_VM">
     <property name="thing">XXX</property>
     </aspect>
    </deployment>
    


    I'm not sure what the xmlns should be for property, but apart from that is my understanding correct?

  • 28. Re: Implementing JAXB style parsing for aop-mc-int
    Kabir Khan Master

    The root element probably still needs the namespace, so my 2 previous examples should read

    <aop xmlns:aop="urn:jboss:aop-beans:1.0">
     <bean name="Bean" class="Foo"/>
     <aspect class="MyAspect" scope="PER_VM">
     <property name="thing">XXX</property>
     </aspect>
    </aop>
    


    <deployment xmlns="urn:jboss:bean-deployer:2.0">
     <bean name="Bean" class="Foo"/>
     <aspect xmlns:aop="urn:jboss:aop-beans:1.0" class="MyAspect" scope="PER_VM">
     <property xmlns="???" name="thing">XXX</property>
     </aspect>
    </deployment>
    


  • 29. Re: Implementing JAXB style parsing for aop-mc-int
    Adrian Brock Master

     

    "kabir.khan@jboss.com" wrote:
    Reading this thread http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134204#4134204 I came back to this. Regarding 3) What would this xsd:refine map to in jaxb annotations? My understanding was that using jaxb it generates a schema from the annotations?


    It doesn't map to anything .

    The xsd:redefine, just specifies what is the default behaviour the JBossXBBuilder
    which is to include types reachable from your hierarchy in your namespace
    (absent any explicit namepace= in the annotations).


    Apart from that, if I have understood you correctly, mc-commons.xsd would contain the current bean_deployer_2_0.xsd.


    Yes, except the root elements (deployment, bean, etc.) and without a namspace


    I would then be able to do
    <aop>
     <bean name="Bean" class="Foo"/>
     <aspect class="MyAspect" scope="PER_VM">
     <property name="thing">XXX</property>
     </aspect>
    </aop>
    



    Correct


    If I wanted to do this the other way around, I would need to use xmlns on the aop specific elements
    <deployment>
     <bean name="Bean" class="Foo"/>
     <aspect xmlns:aop="urn:jboss:aop-beans:1.0" class="MyAspect" scope="PER_VM">
     <property name="thing">XXX</property>
     </aspect>
    </deployment>
    


    I'm not sure what the xmlns should be for property, but apart from that is my understanding correct?


    The idea is you don't need one.

    What you defined is probably not correct unless your schema allows urn:jboss:bean-deployer:2.0:property
    as an element of aspect.

    The correct usage would be either

    explicit
    <deployment>
     <bean name="Bean" class="Foo"/>
     <aspect xmlns:aop="urn:jboss:aop-beans:1.0" class="MyAspect" scope="PER_VM">
     <aop:property name="thing">XXX</aop:property>
     </aspect>
    </deployment>
    


    or change the default namespace
    <deployment>
     <bean name="Bean" class="Foo"/>
     <!-- HERE - simple xmlns -->
     <aspect xmlns="urn:jboss:aop-beans:1.0" class="MyAspect" scope="PER_VM">
     <property name="thing">XXX</property>
     </aspect>
    </deployment>