Advanced Features

Containment Includes

A container directive may include other containers via the <include> statement. This tutorial describes how to use include elements to wire together complex block defintions.

Sample Block

The following block defintion contains:

  • a typical component directive

  • inclusion of a block named "my-block"

  • a container named 'subcontainer', containing:

    • another component
    • another include
<container name="tutorial">

     <classloader>
       <classpath>
         <repository>
           <resource id="tutorial:tutorial" version="1.0"/>
         </repository>
       </classpath>
     </classloader>

     <component name="test1" class="tutorial.TestComponent" activation="startup"/>

     <!--
     Deomonstration of an include the establishes a subsidiary block named "my-block"
     based on the block defintion from the resource repository.
     -->

     <include name="my-block" id="cornerstone-store:cornerstone-store-impl" version="1.0"/>

     <container name="subcontainer">

       <component name="test2" class="tutorial.TestComponent" 
         activation="startup"/>

       <!--
       Inclusion of the block xml file. 
       -->
       <include name="another-block" id="my-group:block" version="1.0" type="xml"/>

     </container>

</container>