5 Replies Latest reply on Nov 29, 2004 7:38 PM by Adrian Brock

    Simple XML deployer

    Dimitris Andreadis Master

      I think I can start with the jbossXB mapping and a subset of the existing -service.xml and enhance this gradually? Something like:

      <bean name="bla" class="org.jboss.bla.Bla">
       <constructor>
       <arg type="java.lang.String">value</arg>
       ...
       </constructor>
      
       <attribute name="yada">value</attribute>
       ...
       <demands> ???
       </demands>
       ...
       <supplies/>
       ...
      </bean>


      1) Do we need to create subclasses of the org.jboss.metadata.pluings.AbstractXXX classes? If yes what's a suitable package for them?
      2) What goes in Supplies?
      3) Instead of Supplies/Demands wouldn't Provides/Depends be more consistent with what we have now?
      4) What are we supposed to store in the AbstractFeatureMetadata map
      5) Is the AbstractValueMetadata 'Object getValue()/setValue(Object)' really needed? Wouldn't be better for derived classes to provide a typed version, e.g. 'String getValue()' for StringValueMetadata
      6) Do we need an .xsd or .dtd for the parsed xml?

        • 1. Re: Simple XML deployer
          Adrian Brock Master

          I've written a simple XML deployer.
          The implementation is in
          org.jboss.kernel.plugins.deployment.xml.XMLKernelDeployer

          It uses Alexey's new MappingObjectModel from JBossXB, very nice :-)

          You can define your parser in just a few lines of code;
          e.g. currently I have

           objectModelFactory = new MappingObjectModelFactory();
           objectModelFactory.mapElementToClass("deployment", AbstractKernelDeployment.class);
           objectModelFactory.mapElementToClass("beans", ArrayList.class);
           objectModelFactory.mapElementToClass("bean", AbstractBeanMetaData.class);
           objectModelFactory.mapElementToClass("constructorParams", ArrayList.class);
           objectModelFactory.mapElementToClass("dependency", AbstractDependencyValueMetaData.class);
           objectModelFactory.mapElementToField("dependentState", AbstractDependencyValueMetaData.class, "dependentState", StateConverter.instance);
           objectModelFactory.mapElementToClass("parameter", AbstractParameterMetaData.class);
           objectModelFactory.mapElementToField("dependency", AbstractParameterMetaData.class, "value", TypeConverter.STRING);
           objectModelFactory.mapElementToClass("value", StringValueMetaData.class);
           objectModelFactory.mapElementToClass("attributes", HashSet.class);
           objectModelFactory.mapElementToClass("attribute", AbstractAttributeMetaData.class);
           objectModelFactory.mapElementToField("dependency", AbstractAttributeMetaData.class, "value", TypeConverter.STRING);
           objectModelFactory.mapElementToClass("demands", HashSet.class);
           objectModelFactory.mapElementToClass("demand", AbstractDemandMetaData.class);
           objectModelFactory.mapElementToField("whenRequired", AbstractDemandMetaData.class, "whenRequired", StateConverter.instance);
           objectModelFactory.mapElementToClass("supplies", HashSet.class);
           objectModelFactory.mapElementToClass("supply", AbstractSupplyMetaData.class);
           objectModelFactory.mapElementToClass("interceptors", ArrayList.class);
           objectModelFactory.mapElementToClass("interceptor", AbstractInterceptorMetaData.class);
          


          There are some examples used by the tests in
          jboss-head/kernel/src/resources/test/org/jboss/test/kernel/xml/test

          • 2. Re: Simple XML deployer
            Scott Stark Master

            What is the context for this starting point?

            • 3. Re: Simple XML deployer
              Adrian Brock Master

              The other use of the featuremetadata is to provide metadata to each context.
              But I need to discuss this with Bill because he has two mechanisms for this:

              1) getMetaData(...)
              2) resolveAnnotation(...)

              The annotation approach is obviously superior because it is type checked,
              but we also need the mechanism to work in java1.4

              Use cases, detyped approach:
              1) ModelMBean descriptor

              <attribute name="Blah">InitialValue
               <metadata domain="modelmbean" type="cache-timeout">NEVER</metadata>
              </attribute>
              

              2) Aspect context configuration
              <attribute name="Blah">InitialValue
               <metadata domain="transaction" type="demarcation">Required</metadata>
               <metadata domain="authorization" type="roles">admin</metadata>
              </attribute>
              


              NOTE: The above xml is intended to express the idea, not specify how we are
              actually going to do it/use it.
              Remember, what we are configuring here using XML with be done programmatically
              by the other deployers (sar, aop, ejb, etc.).

              • 4. Re: Simple XML deployer
                Adrian Brock Master

                I've written a simple XML deployer.
                The implementation is in
                org.jboss.kernel.plugins.deployment.xml.XMLKernelDeployer

                It uses Alexey's new MappingObjectModel from JBossXB, very nice :-)

                You can define your parser in just a few lines of code;
                e.g. currently I have

                 objectModelFactory = new MappingObjectModelFactory();
                 objectModelFactory.mapElementToClass("deployment", AbstractKernelDeployment.class);
                 objectModelFactory.mapElementToClass("beans", ArrayList.class);
                 objectModelFactory.mapElementToClass("bean", AbstractBeanMetaData.class);
                 objectModelFactory.mapElementToClass("constructorParams", ArrayList.class);
                 objectModelFactory.mapElementToClass("dependency", AbstractDependencyValueMetaData.class);
                 objectModelFactory.mapElementToField("dependentState", AbstractDependencyValueMetaData.class, "dependentState", StateConverter.instance);
                 objectModelFactory.mapElementToClass("parameter", AbstractParameterMetaData.class);
                 objectModelFactory.mapElementToField("dependency", AbstractParameterMetaData.class, "value", TypeConverter.STRING);
                 objectModelFactory.mapElementToClass("value", StringValueMetaData.class);
                 objectModelFactory.mapElementToClass("attributes", HashSet.class);
                 objectModelFactory.mapElementToClass("attribute", AbstractAttributeMetaData.class);
                 objectModelFactory.mapElementToField("dependency", AbstractAttributeMetaData.class, "value", TypeConverter.STRING);
                 objectModelFactory.mapElementToClass("demands", HashSet.class);
                 objectModelFactory.mapElementToClass("demand", AbstractDemandMetaData.class);
                 objectModelFactory.mapElementToField("whenRequired", AbstractDemandMetaData.class, "whenRequired", StateConverter.instance);
                 objectModelFactory.mapElementToClass("supplies", HashSet.class);
                 objectModelFactory.mapElementToClass("supply", AbstractSupplyMetaData.class);
                 objectModelFactory.mapElementToClass("interceptors", ArrayList.class);
                 objectModelFactory.mapElementToClass("interceptor", AbstractInterceptorMetaData.class);
                


                There are some examples used by the tests in
                jboss-head/kernel/src/resources/test/org/jboss/test/kernel/xml/test

                • 5. Re: Simple XML deployer
                  Adrian Brock Master

                  On a related note, the interface
                  org.jboss.kernel.spi.deployment.KernelDeployment
                  is the start of the M2 deployer code.

                  The method KernelDeployment.getBeans()
                  doesn't have to have a fixed list of BeanMetaData like in the abstract implementation.

                  It can be "dynamically" generated from a more convenient metamodel like the
                  ejb metadata or web metadata or some intermediate form.