/**
   * Returns the array of components bound the "multicastItfName" multicast interface, or null if it
   * fails to getting them.
   *
   * @param component The client component
   * @param multicastItfName The name of the multicast interface
   * @return Array of bound components, or null if it fails
   */
  public static Component[] getMulticastBindComponenents(
      Component component, String multicastItfName) {
    try {
      Object[] destinationItfs =
          Utils.getPAMulticastController(component).lookupGCMMulticast(multicastItfName);
      Component[] destinationComps = new Component[destinationItfs.length];

      for (int i = 0; i < destinationItfs.length; i++) {
        destinationComps[i] = ((PAInterface) destinationItfs[i]).getFcItfOwner();
      }

      return destinationComps;

    } catch (NoSuchInterfaceException e) {
      e.printStackTrace();
      return null;
    }
  }
  private void registerMethods() {
    PAActiveObject.setImmediateService(
        "getGCMStatistics",
        new Class[] {String.class, String.class, (new Class<?>[] {}).getClass()});
    PAActiveObject.setImmediateService("getAllGCMStatistics");

    statistics = Collections.synchronizedMap(new HashMap<String, Object>());
    keysList = new HashMap<String, String>();
    NameController nc = null;
    try {
      nc = GCM.getNameController(owner);
    } catch (NoSuchInterfaceException e) {
      e.printStackTrace();
    }
    String name = nc.getFcName();
    Object[] itfs = owner.getFcInterfaces();
    for (int i = 0; i < itfs.length; i++) {
      Interface itf = (Interface) itfs[i];
      InterfaceType itfType = (InterfaceType) itf.getFcItfType();
      try {
        if (!Utils.isControllerItfName(itf.getFcItfName()) && (!itfType.isFcClientItf())) {
          List<MonitorController> subcomponentMonitors = new ArrayList<MonitorController>();
          if (isComposite()) {
            Iterator<Component> bindedComponentsIterator = null;
            if (!((GCMInterfaceType) itfType).isGCMMulticastItf()) {
              List<Component> bindedComponent = new ArrayList<Component>();
              bindedComponent.add(
                  ((PAInterface) ((PAInterface) itf).getFcItfImpl()).getFcItfOwner());
              bindedComponentsIterator = bindedComponent.iterator();
            } else {
              try {
                PAMulticastControllerImpl multicastController =
                    (PAMulticastControllerImpl)
                        ((PAInterface) GCM.getMulticastController(owner)).getFcItfImpl();
                Iterator<PAInterface> delegatee =
                    multicastController.getDelegatee(itf.getFcItfName()).iterator();
                List<Component> bindedComponents = new ArrayList<Component>();
                while (delegatee.hasNext()) {
                  bindedComponents.add(delegatee.next().getFcItfOwner());
                }
                bindedComponentsIterator = bindedComponents.iterator();
              } catch (NoSuchInterfaceException e) {
                e.printStackTrace();
              }
            }
            try {
              while (bindedComponentsIterator.hasNext()) {
                MonitorController monitor =
                    GCM.getMonitorController(bindedComponentsIterator.next());
                monitor.startGCMMonitoring();
                subcomponentMonitors.add(monitor);
              }
            } catch (NoSuchInterfaceException e) {
              e.printStackTrace();
            }
          }
          Class<?> klass =
              ClassLoader.getSystemClassLoader().loadClass(itfType.getFcItfSignature());
          Method[] methods = klass.getDeclaredMethods();
          for (Method m : methods) {
            Class<?>[] parametersTypes = m.getParameterTypes();
            String key =
                PAMonitorControllerHelper.generateKey(
                    itf.getFcItfName(), m.getName(), parametersTypes);
            keysList.put(m.getName(), key);
            if (subcomponentMonitors.isEmpty()) {
              statistics.put(
                  key,
                  new MethodStatisticsPrimitiveImpl(
                      itf.getFcItfName(), m.getName(), parametersTypes));
            } else {
              statistics.put(
                  key,
                  new MethodStatisticsCompositeImpl(
                      itf.getFcItfName(), m.getName(), parametersTypes, subcomponentMonitors));
            }
            controllerLogger.debug(
                m.getName() + " (server) added to monitoring on component " + name + "!!!");
          }
        }
      } catch (ClassNotFoundException e) {
        throw new ProActiveRuntimeException("The interface " + itfType + "cannot be found", e);
      }
    }
  }