protected void setComponent(DefaultHost host, Component comp) {
   // TODO setComponent method in the host?
   if (comp instanceof NetLayer) {
     host.setNetwork((NetLayer) comp);
   } else if (comp instanceof TransLayer) {
     host.setTransport((TransLayer) comp);
   } else if (comp instanceof OverlayNode) {
     host.setOverlayNode((OverlayNode) comp);
   } else if (comp instanceof Application) {
     host.setApplication((Application) comp);
   } else if (comp instanceof ContentStorage) {
     host.setContentStorage((DefaultContentStorage) comp);
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see de.tud.kom.p2psim.api.scenario.HostBuilder#parse(org.dom4j.Element,
   * de.tud.kom.p2psim.api.scenario.Configurator)
   */
  public void parse(Element elem, Configurator config) {
    DefaultConfigurator defaultConfigurator = (DefaultConfigurator) config;

    // create groups
    for (Iterator iter = elem.elementIterator(); iter.hasNext(); ) {
      Element groupElem = (Element) iter.next();
      String groupID = groupElem.attributeValue(GROUP_ID_TAG);
      if (groupID == null) {
        throw new IllegalArgumentException(
            "Id of host/group " + groupElem.asXML() + " must not be null");
      }

      // either a group of hosts or a single host (=group with size 1)
      int groupSize;
      if (groupElem.getName().equals(HOST_TAG)) {
        groupSize = 1;
      } else if (groupElem.getName().equals(GROUP_TAG)) {
        String attributeValue = config.parseValue(groupElem.attributeValue(GROUP_SIZE_TAG));
        groupSize = Integer.parseInt(attributeValue);
      } else {
        throw new IllegalArgumentException("Unexpected tag " + groupElem.getName());
      }
      List<Host> group = new ArrayList<Host>(groupSize);

      // create hosts and instances of specified components for each host
      for (int i = 0; i < groupSize; i++) {

        DefaultHost host = new DefaultHost();

        // initialize properties
        DefaultHostProperties hostProperties = new DefaultHostProperties();
        host.setProperties(hostProperties);
        // minimal information for host properties is the group id
        hostProperties.setGroupID(groupID);

        // initialize layers and properties
        for (Iterator layers = groupElem.elementIterator(); layers.hasNext(); ) {
          Element layerElem = (Element) layers.next();
          if (layerElem.getName().equals(Configurator.HOST_PROPERTIES_TAG)) {
            defaultConfigurator.configureAttributes(hostProperties, layerElem);
          } else {
            // layer component factory
            ComponentFactory layer =
                (ComponentFactory) defaultConfigurator.configureComponent(layerElem);
            Component comp = layer.createComponent(host);

            setComponent(host, comp);
          }
        }
        group.add(host);
      }
      log.debug("Created a group with " + group.size() + " hosts");
      hosts.addAll(group);
      groups.put(groupID, group);
    }
    log.info("CREATED " + hosts.size() + " hosts");
    if (hosts.size() != experimentSize) {
      log.warn(
          "Only "
              + hosts.size()
              + " hosts were specified, though the experiment size was set to "
              + experimentSize);
    }
  }