DPML
Component Development
HomeUtilitiesStationMetroDepotTransit
Overview

In the earlier tutorials dealing with Transit Plugins we covered the general subject of a deployment unit descriptor that associated an object instantiation strategy with a classloader chain definition. The Metro platform provides an alternative deployment strategy and runtime handler that delivers a complete context driven IOC object instantiation model.

In addition to instantiation there are several aspects of a class that effect its deployment. These aspects include thread-safety, a depoyment and decommissioning lifecycle, garbage collection policy, etc. Each of these concerns are expresssed as well defined semantic features within the Metro component model.

Totorial Objective

The objective of this tutorial is the demonstration of how we can introduce a new instantiation strategy into a part deployment descriptor. Subsequent tutorials will use the resource established here as the baseline for the introduction of the core Metro component model concepts.

Supporting classes:

Demo.java A minimal component implementation.
DemoTestCase.java Testcase that validates component deployment.
Component Creation

The creation of a new component defintion is basically the same as the procedure used to create a plugin. In the following Depot project definition we are declaring a new project with publication of a jar and a part artifact. The significant difference from a regular plugin is the usage of a custom part strategy.

<index ..... >

  <project name="acme-demo-hello" basedir="hello">
    <types>
      <type id="jar"/>
      <component xmlns="link:xsd:dpml/lang/dpml-component#1.0" 
         type="org.acme.Demo" 
         name="demo"/>
    </types>
    <dependencies>
      <test>
        <include ref="ant/ant-junit"/>
        <include ref="dpml/transit/dpml-transit-main"/>
      </test>
    </dependencies>
  </project>
  
  ...
  
</index>

The custom part definition introduced under the link:xsd:dpml/lang/dpml-component#1.0 namespace is declaring the production of a new part datastructure under which the class org.acme.Demo is to handled by the Metro runtime platform. The above definition also includes the declaration of test phase dependencies that we will need in order to launch the component.

The generated part datastructure is show below (the custom Metro deployment strategy is hilighted in red).

<part xmlns="link:xsd:dpml/lang/dpml-part#1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <info/>

  <component xmlns="link:xsd:dpml/lang/dpml-component#1.0"
      type="org.acme.Demo"
      name="demo"
      collection="system"
      activation="system">
  </component>

  <classpath>
    <private>
      <uri>artifact:jar:dpmlx/tutorials/components/acme-demo-hello#SNAPSHOT</uri>
    </private>
  </classpath>

</part>
Summary

In this example the Demo implementation class contains nothing significant - however, the important point of this tutorial is the association of a different runtime handler for the class within our part definition. Our next tutorial extends this project with the introduction of context management and in particular, the way in which a component class declares context assumptions, and the mechanisms used by the Metro runtime to fullfill those requirements.