[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Getting content of XML element

kabir.khan@jboss.com do-not-reply at jboss.com
Tue Mar 25 15:14:53 EDT 2008


Revisiting this, as first implemented by Bill there are pluggable metadata loaders. The simplest case using the "standard" metadata loader is shown here:


  |    <metadata tag="test" class="org.jboss.test.aop.bean.POJOConstructorTest">
  |       <constructor expr="POJOConstructorTest()">
  |          <data>empty</data>
  |       </constructor>
  |       <method expr="* another()">
  |          <data>another()</data>
  |       </method>
  |       <field expr="void another(int, int)">
  |          <data>another(int, int)</data>
  |       </field>
  |    </metadata>
  | 

and

  |    <metadata tag="introduction-tag" class="org.jboss.test.aop.bean.NoInterceptorsPOJO">
  |       <class/> <!-- just tagging the class -->
  |    </metadata>
  | 

and

  |    <metadata tag="transaction" class="org.jboss.test.aop.bean.TxPOJO">
  |       <default>
  |          <trans-attribute>NotSupported</trans-attribute>
  |       </default>
  |       <method name="never">
  |          <trans-attribute>Never</trans-attribute>
  |       </method>
  |       <method name="supports">
  |          <trans-attribute>Supports</trans-attribute>
  |       </method>
  |    </metadata>
  |    

Although there are a few standard tags within the metadata (default, method, field, constructor), the actual content of these is free-form. E.g. The first example uses the nested element "data" and the third uses the nested element "trans-attribute". 

Then we have more complicated things like the following, it uses the org.jboss.aspects.security.SecurityClassMetaDataLoader to parse the xml shown into aop metadata.



  |    <metadata tag="security" class="org.jboss.test.aop.bean.SecuredPOJO">
  |       <security-domain>other</security-domain>
  |       <method-permission>
  |          <role-name>allowed</role-name>
  |          <method>
  |             <method-name>someMethod</method-name>
  |          </method>
  |       </method-permission>
  |       <method-permission>
  |          <unchecked/>
  |          <method>
  |             <method-name>unchecked</method-name>
  |          </method>
  |       </method-permission>
  |       <field-permission>
  |          <role-name>allowed</role-name>
  |          <field>
  |             <field-name>someField</field-name>
  |          </field>
  |       </field-permission>
  |       <field-permission>
  |          <unchecked/>
  |          <field>
  |             <field-name>uncheckedField</field-name>
  |          </field>
  |       </field-permission>
  |       <constructor-permission>
  |          <unchecked/>
  |          <constructor>
  |             <constructor-params/>
  |          </constructor>
  |       </constructor-permission>
  |       <constructor-permission>
  |          <role-name>allowed</role-name>
  |          <constructor>
  |             <constructor-params>
  |                <constructor-param>int</constructor-param>
  |             </constructor-params>
  |          </constructor>
  |       </constructor-permission>
  | 
  |       <exclude-list>
  |          <description>Methods that connect be used</description>
  |          <method>
  |             <method-name>excluded</method-name>
  |          </method>
  |          <field>
  |             <field-name>excludedField</field-name>
  |          </field>
  |          <constructor>
  |             <constructor-params>
  |                <constructor-param>java.lang.String</constructor-param>
  |             </constructor-params>
  |          </constructor>
  |       </exclude-list>
  |    </metadata>
  | 

All the examples are from the AS 5 testsuite, and I think we need to continue supporting this stuff? From base-aspects.xml:


  |    <!-- custom configuration for AOP Security -->
  |    <metadata-loader tag="security" class="org.jboss.aspects.security.SecurityClassMetaDataLoader"/>
  | 

I think the simple cases can be rewritten using Element for the nested data/transaction-attribute elements? They only map onto name/value pairs - the name of the tag being the name, and the content being the value.

The SecurityClassMetaDataLoader needs replacing with something else, but it should be able to parse the style of xml shown. I don't see any other way at the moment than being able to take Element?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4138808#4138808

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4138808



More information about the jboss-dev-forums mailing list