1 2 3 Previous Next 41 Replies Latest reply on Nov 23, 2007 1:15 PM by starksm64 Go to original post
      • 15. Re: JBAS-1437 RARMetaDataRepository

        I don't understand this?

        The correct approach is
        xml -> metadata model
        metadata model -> components (jmx/pojo)
        why does the parsing need to be aspectized?

        Evolution of the metadata model is an OOP issue not an AOP issue.

        • 16. Re: JBAS-1437 RARMetaDataRepository

           

          "adrian@jboss.org" wrote:
          I don't understand this?


          If you are talking about multiple processors of the ConnectionFactory metadata
          then that framework already exists in the new deployers.

          • 17. Re: JBAS-1437 RARMetaDataRepository
            weston.price

            The parsing of the *-ds.xml file is not trivial as the format has been butchered through the years to include things that probably should have never been allowed and no one ever seemed to draw a line in the sand to make people stop.

            Using AOP for the parsing of the *-ds.xml format would seem to make some sense for a few reasons

            a) Element name definitions can be injected into the parsing aspects rather than being hardcoded. By element name defintions, I mean the actual mapping of things like <min-pool-size>, <driver-class>. Anyway you look at it, the elements from the DTD have to be mapped somehow, someway to something.

            Before you say it, I know that this can be done via simple MC injection or can simply be thrown it in a properties file for reference, but this just doesn't seem to me to be the best approach. I could be wrong.

            b)As new elements get added to the *-ds.xml (see above), new aspects can just be added to support this. Also, new file formats can be accomodated via aspects since there would be no real behavior in the actual class itself.


            The correct approach is
            xml -> metadata model
            metadata model -> components (jmx/pojo)


            Right, and as long as the appropriate MetaData gets generated from the *-ds.xml, I don't see there being a *wrong* approach. Ideally I would have liked to use some form of DataBinding to do the unmarshalling rather than doing the parsing by hand. However, I wanted to keep my dependencies to a minimum as well as put an end (at least in my stuff) to the JAXB, JBossXB debate which never did seem to get resolved.






            • 18. Re: JBAS-1437 RARMetaDataRepository
              starksm64

              The resolution to the JAXB, JBossXB was that either could be used. It would be better to talk about what your looking for in the context of a testcase.

              • 19. Re: JBAS-1437 RARMetaDataRepository
                weston.price

                This simply involves the parsing/binding of the *-ds.xml file. I was just throwing out an idea to break up the actual parsing into aspects. Example:

                ConnectionPoolParsing aspect knows about the specific elements that make up the ConnectionPoolMetaData.

                ServiceDependency aspect knows about the specific elements that constitute ServiceMean dependencies in the *-ds.xml file.

                These aspects would form a parsing chain that gets applied on parse. Nothign more than that.

                Again, this would be an alternate approach (refactoring) as I have already written the JAXP based parser of the *-ds.xml file to construct the MetaData which works, but is not as elegant/clean as I would have liked.

                • 20. Re: JBAS-1437 RARMetaDataRepository
                  starksm64

                  The natural way to do that is via the use of separate namespaces. If you transformed the raw unpartitioned ds.xml into a version where the separate concernce where under separate namespaces jbossxb naturually would support running separate binding layers for this. Hopefully jaxb could do the same.

                  Alternatively, you just reparse the same file multiple times.

                  I think the only question is what usecases need better helpers to avoid excessive duplication in new deployers.

                  • 21. Re: JBAS-1437 RARMetaDataRepository
                    weston.price

                    Sorry, I am not sure I follow. Right now what I do is simply parse the *-ds.xml file using straight JAXP. While this works, is quick and has no dependencies on any binding framework (JAXB, JBossXB) I started thinking about it a bit more. The problems I see with this are

                    1) The element name mappings have to be hardcoded somewhere. Example:

                    <min-pool-size/>
                    <max-pool-size/>
                    <connection-url/>
                    <xa-datasource-property/>

                    All of this stuff has to resolve to something in the MetaData, and then applied correctly to ServiceMetaData instances to construct and deploy the MBeans for a MCF. Right now I simply have a helper class that maintains a map of these values that the parser consults when processing the *-ds.xml file. It's this mess that I thought about replacing with something more extensible, ie, an aspectized parser where each aspect in the chain knows enough about the *-ds.xml format to construct the MetaData. As new elements get added to the *-ds.xml file, these aspects can be extended to accomodate this.

                    2) The parsing itself looks pretty ugly.

                    Again, JAXP was used more as a convenience than anything else. It was *simple* from the perspective that I could get something up and running, but now I am rethinking the design.

                    • 22. Re: JBAS-1437 RARMetaDataRepository
                      starksm64

                      Right, and I'm saying the natural way to handle this and leverage the existing xml binding deployers is to:

                      1. Transform the ds.xml into an xml doc partitioned with namespaces:

                      <datasources>
                      <xa-datasource>
                       <username />
                       <password />
                       <min-pool-size/>
                      <max-pool-size/>
                      <connection-url/>
                      <xa-datasource-property/>
                      <xa-datasource>
                      </datasources>
                      


                      goes to via a new xsl
                      <dsxml:datasources>
                      <dsxml:xa-datasource>
                       <ns1:username />
                       <ns1:password />
                       <ns1:connection-url/>
                       <ns2:min-pool-size/>
                       <ns2:max-pool-size/>
                       <ns3:xa-datasource-property/>
                      <dsxml:xa-datasource>
                      </dsxml:datasources>
                      


                      where you have jaxb or jbossxb factories for each of the dsxml, ns1, ns2, ns3 namespaces that produce distinct metadata attachments for each namespace.


                      • 23. Re: JBAS-1437 RARMetaDataRepository
                        weston.price

                        I would like to get away from using XSL at all (the original point of the task). The approach you mention could work, but if I was going to go down that route, I would be more inclinded to

                        1) Create a MCF XSD and deprecate the DTD

                        2) Eliminate the problematic elements from the *-ds.xml deployment (ie MBean definitions) that get in the way of making the unmarshalling a simple process, or at least find someway to work around this.

                        This was actually my initial approach but the MBean definitions inside the *-ds.xml got in my way.

                        • 24. Re: JBAS-1437 RARMetaDataRepository
                          starksm64

                           

                          "weston.price@jboss.com" wrote:

                          2) Eliminate the problematic elements from the *-ds.xml deployment (ie MBean definitions) that get in the way of making the unmarshalling a simple process, or at least find someway to work around this.

                          This was actually my initial approach but the MBean definitions inside the *-ds.xml got in my way.


                          Ok, but at that point you have a new an incompatible ds.xml descriptor. What I'm talking about is morphing the legacy ds.xml into ds2.xml that is a perfectly parsable, aspect oriented delight. Its whatever the lesser of two evils is, an essentially hand-coded xml parse/deserializer or xsl.

                          • 25. Re: JBAS-1437 RARMetaDataRepository

                             

                            "weston.price@jboss.com" wrote:

                            1) The element name mappings have to be hardcoded somewhere. Example:

                            <min-pool-size/>
                            <max-pool-size/>
                            <connection-url/>
                            <xa-datasource-property/>

                            All of this stuff has to resolve to something in the MetaData, and then applied correctly to ServiceMetaData instances to construct and deploy the MBeans for a MCF.


                            Why don't you just write a holder that knows how to create a more structured
                            metadata object from the flat scheme.

                            e.g. in JAXB annotations (I'll use fields instead of accessors for brevity)
                            
                            public BaseConnectionFactoryDefinition implements PoolMetaData, etc...
                            {
                             @XmlElement("min-pool-size") public int minPoolSize;
                             @XmlElement("max-pool-size") public int maxPoolSize;
                            
                             public PoolMetaData getPoolMetaData()
                             {
                             return this;
                             }
                            }
                            
                            @XmlRoot("local-tx-datasource")
                            public LocalTxDataSource extendsBaseConnectionFactoryDefinition implements MCFMetaData
                            {
                             @XmlElement("connection-url") public String connectionURL;
                            
                             public LocalDataSourceMetaData getConnectionFactoryMetaData()
                             {
                             return this;
                             }
                            
                             public List<ConnectionPropertyMetaData> getConnectionProperties()
                             {
                             // create connection property metadata
                             }
                            }
                            


                            The idea being that PoolMetaData and MCFMetaData (or whatever you call them)
                            are what the real ds deployer uses when constructing the MBeans/POJOs.

                            It is then simply a case of parsing (using JAXB - or JBossXB with JAXB annotations)
                            and extracting the metadata into deployment attachments.

                            The other big advantage is that somebody can write their own deployer
                            that creates this metadata some other way and still reuse the JCA real deployer.

                            NOTE: This is OOP (inheritance) not AOP.

                            • 26. Re: JBAS-1437 RARMetaDataRepository

                               

                              "adrian@jboss.org" wrote:

                              It is then simply a case of parsing (using JAXB - or JBossXB with JAXB annotations)
                              and extracting the metadata into deployment attachments.


                              The big problem is the embedded MBeans in the -ds.xml file.
                              Like Scott said about namespaces, both JAXB and especially JBossXB
                              (which has even better support) can parse different objects based on the namespace.

                              But in the current -ds.xml the mbean stuff is not in a different namespace
                              and the mbean stuff doesn't have a JAXB or JBossXB based parser.

                              It should be:

                              <connection-factorties xmlns="urn:jboss-jca:5.0">
                              
                               <!-- Our metadata -->
                               <connection-factory>...</connection-factory>
                              
                               <!-- Somebody else's metadata -->
                               <mbean xmlns="urn:jboss-jmx:5.0">...</mbean>
                              
                              </connection-factories>
                              


                              This has two solutions:
                              1) Junk the -ds.xml and move to a -cf.xml which either doesn't support
                              embedded mbeans or does it via a namespace
                              2) Include a "copy" of the mbean model in the jca namespace.

                              When I say "copy", this could just be some form of bridge/wrapper
                              that updates the real ServiceMetadata objects, it is only there is
                              to fool the xml parser machinery into thinking there is an
                              urn:jboss-jca:5.0:mbean element.

                              • 27. Re: JBAS-1437 RARMetaDataRepository
                                weston.price

                                Right, this is definitely a valid approach. It's pretty much the way the MetaData has already been structured. I optimized a bit for datasource deployments, but the structure is essentially the same as what you proposed it just does use JAXB or JBossXB at this point.

                                The generic *-ds.xml stuff, (MCF crap and whatnot) is the easy part. It's the embedded MBean stuff that I can't quite seem to get my head around in the context of JAXB/JBossXB. My approach up to this point is simply to leverage the ServiceDataParsers to manage this but I am sure there is a better way to do this.


                                • 28. Re: JBAS-1437 RARMetaDataRepository
                                  weston.price

                                  Sorry, I posted before reading your latest message about the MBeans. Disregard.

                                  • 29. Re: JBAS-1437 RARMetaDataRepository
                                    weston.price

                                     


                                    1) Junk the -ds.xml and move to a -cf.xml which either doesn't support
                                    embedded mbeans or does it via a namespace


                                    Ok, when I proposed this before I believe we had a bit of a disagreement about it and backward compatibility.

                                    This actually would be my *ideal* approach. Let's just clean up this shit while we have the opportunity, create a real XSD for our MCF deployments and just make people put MBean defintions where the should be..ie anywhere else but MY stuff!