Nesting configuration elements

You can use metatype extensions to define configuration that can be expressed as nested XML elements in the server.xml file.


The following example shows how to support this user configuration in the server.xml file:
<family mother="jane" father="john">
  <child name="susie" age="8" />
  <child name="danny" age="5" />
The metatype XML uses ibm:type="pid" and ibm:reference as shown in following example:
<?xml version="1.0" encoding="UTF-8"?>

  <OCD id="family" name="family">
    <AD id="mother" name="mother" type="String" default="Ma" />
    <AD id="father" name="father" type="String" default="Pa" />
    <AD id="child" name="child" ibm:type="pid" ibm:reference="child-pid"
      required="false" type="String" cardinality="6" />       

  <Designate pid="family">
    <Object ocdref="family" />
  <OCD id="child" name="child" >
    <AD id="name" name="name" type="String" />
    <AD id="age" name="age" type="Integer" />

  <Designate factoryPid="child-pid">
    <Object ocdref="child" />
The following example show how the code that receives the family properties uses the ConfigurationAdmin service to obtain the child property sets:
public void updated(Dictionary<String, ?> properties)
  throws ConfigurationException {

  Set<String> pids = new HashSet<String>();
  String mother = "null";
  String father = "null";

  try {
    if (properties != null) {
      mother = (String) properties.get("mother");
      father = (String) properties.get("father");
      String[] children = (String[]) properties.get("child");
      if (children == null || children.length == 0) {	

      // Get the configuration admin service
      ConfigurationAdmin configAdmin = null;
      ServiceReference configurationAdminReference = 
      if (configurationAdminReference != null) {
        configAdmin = (ConfigurationAdmin)

      for (String childPid : children) {
        // Passing in null as the second argument to getConfiguraton prevents 
        // the configuraton object from being bound to the calling bundle
        Configuration config = configAdmin.getConfiguration(childPid, null);
        String name = (String) config.getProperties().get("name");
        Integer age = (Integer) config.getProperties().get("age");

  catch (Exception e) {