/** {@inheritDoc} */
 @Override
 public Object getGCMStatistics(String itfName, String methodName, Class<?>[] parameterTypes)
     throws NoSuchMethodException {
   String supposedCorrespondingKey =
       PAMonitorControllerHelper.generateKey(itfName, methodName, parameterTypes);
   MethodStatistics methodStats = (MethodStatistics) statistics.get(supposedCorrespondingKey);
   if (methodStats != null) {
     return methodStats;
   } else if ((parameterTypes == null) || (parameterTypes.length == 0)) {
     String correspondingKey = null;
     String[] keys = statistics.keySet().toArray(new String[] {});
     for (int i = 0; i < keys.length; i++) {
       if (keys[i].startsWith(supposedCorrespondingKey)) {
         if (correspondingKey == null) {
           correspondingKey = keys[i];
         } else {
           throw new NoSuchMethodException(
               "The method name: "
                   + methodName
                   + " of the interface "
                   + itfName
                   + " is ambiguous: more than 1 method found");
         }
       }
     }
     if (correspondingKey != null) {
       return statistics.get(correspondingKey);
     } else {
       throw new NoSuchMethodException(
           "The method: "
               + methodName
               + "() of the interface "
               + itfName
               + " cannot be found so no statistics are available");
     }
   } else {
     String msg = "The method: " + methodName + "(";
     for (int i = 0; i < parameterTypes.length; i++) {
       msg += parameterTypes[i].getName();
       if (i + 1 < parameterTypes.length) {
         msg += ", ";
       }
     }
     msg += ") of the interface " + itfName + " cannot be found so no statistics are available";
     throw new NoSuchMethodException(msg);
   }
 }
  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);
      }
    }
  }