Beispiel #1
0
  /**
   * Modifies a copy of the parent's implementation advertisement to reflect the addition or
   * replacement of services. The newServices Hashtable must have ModuleClassID keys and
   * ModuleImplAdvertisement values. I've deferred adding applications or protocols for the moment
   * [email protected] Dec 3 2001.
   *
   * @return -- advert for the new peergroup which the StdPeerGroup module will implement.
   * @param parent -- a running instance of the new group's parent
   * @param newGroupModuleSpecID -- since new or replacement services are involved
   * @param newDescription -- the new group's reason to be
   * @param newServices -- advert's for the new services
   * @throws IllegalArgumentException -- for a bad key or value type
   * @throws Exception --- if the parent can't produce a copy of its own impl advert
   */
  public static ModuleImplAdvertisement buildPeerGroupImplAdvertisement(
      StdPeerGroup parent,
      ModuleSpecID newGroupModuleSpecID,
      String newDescription,
      Map newServices)
      throws Exception {
    Map newApps = null, newProtos = null;

    // illegal types will cause an IllegalArgumentException
    typeCheckKeys(newServices);
    typeCheckValues(newServices);
    // get a copy of parent's general purpose advert as a template
    ModuleImplAdvertisement implAdv = parent.getAllPurposePeerGroupImplAdvertisement();

    implAdv.setDescription(newDescription);
    implAdv.setModuleSpecID(newGroupModuleSpecID);
    // extract embedded ad for standard modules
    TextElement paramElement = (TextElement) implAdv.getParam();
    StdPeerGroupParamAdv paramAdv = new StdPeerGroupParamAdv(paramElement);
    // alter services
    Map services = paramAdv.getServices();

    typeCheckKeys(services);
    // mergeTables will override old services with new if base classes are the same
    services = mergeTables(services, newServices);
    paramAdv.setServices(services);
    paramElement = (TextElement) paramAdv.getDocument(MimeMediaType.XMLUTF8);
    implAdv.setParam(paramElement);
    return implAdv;
  }