Exemple #1
0
  /**
   * Calculates the number of services of the specified type running on each of the specified
   * Cybernodes.
   *
   * @param cybernodes the Cybernodes to consider
   * @param type the service type to look for
   * @return the resulting array. Every element of this array stores the number of services of the
   *     specified type running on a specific Cybernode. The order of elements corresponds to the
   *     one of services in the <code>cybernodes</code> parameter.
   * @throws RemoteException if there was a communication failure while attempting to access one of
   *     the Cybernodes from the specified list.
   */
  public static int[] calcServices(Cybernode[] cybernodes, Class type) throws RemoteException {

    int[] res = new int[cybernodes.length];
    for (int i = 0; i < cybernodes.length; i++) {
      Cybernode cybernode = cybernodes[i];
      ServiceRecord[] records = cybernode.getServiceRecords(ServiceRecord.ACTIVE_SERVICE_RECORD);
      for (ServiceRecord record : records) {
        ServiceElement element = record.getServiceElement();
        ClassBundle[] exportBundles = element.getExportBundles();
        for (ClassBundle bundle : exportBundles) {
          if (bundle.getClassName().equals(type.getName())) {
            res[i]++;
            break;
          }
        }
      }
    }
    return res;
  }
 /** Override toString */
 public String toString() {
   StringBuilder buffer = new StringBuilder();
   if (interfaceNames != null) {
     for (int i = 0; i < interfaceNames.length; i++) {
       if (i > 0) buffer.append(", ");
       buffer.append(interfaceNames[i]);
     }
   } else {
     buffer.append("<null>");
   }
   String iFaces = buffer.toString();
   buffer.delete(0, buffer.length());
   if (groups == null) {
     buffer.append("<null>");
   } else {
     for (int i = 0; i < groups.length; i++) {
       if (i > 0) buffer.append(", ");
       buffer.append(groups[i]);
     }
   }
   String gps = buffer.toString();
   String fdh = "<null>";
   if (fdhBundle != null) fdh = fdhBundle.getClassName();
   String ops = "<null>";
   if (opStringName != null) ops = opStringName;
   return ("Type="
       + type.toString()
       + ", "
       + "Name="
       + getName()
       + ", "
       + "Interfaces="
       + iFaces
       + ", "
       + "Groups="
       + gps
       + ", "
       + "Version="
       + version
       + ", "
       + "MatchOnName="
       + matchOnName
       + ", "
       + "OperationalString="
       + ops
       + ", "
       + "Property="
       + propertyName
       + ", "
       + "associationMatchFilter="
       + associationMatchFilter
       + ", "
       + "proxyClass="
       + proxyClass
       + ", "
       + "serviceStrategyClass="
       + serviceStrategyClass
       + ", "
       + "lazyInject="
       + lazyInject
       + ", "
       + "serviceDiscoveryTimeout="
       + serviceDiscoveryTimeout
       + ", "
       + "serviceDiscoveryTimeUnits="
       + serviceDiscoveryTimeUnits
       + ", "
       + "FDH="
       + fdh);
 }