private boolean hasNfInternalServerInterfaces() { InterfaceType[] nfItfTypes = ((PAComponentType) this.componentParameters.getComponentType()).getNfFcInterfaceTypes(); for (InterfaceType nfItfType : nfItfTypes) { if (!nfItfType.isFcClientItf() && ((PAGCMInterfaceType) nfItfType).isInternal()) { return true; } } return false; }
/** * Retrieves an interface from its name. NF Interfaces (both client/server) must have a name * ending in "-controller". * * @see org.objectweb.fractal.api.Component#getFcInterface(String) */ public Object getFcInterface(String interfaceName) throws NoSuchInterfaceException { if (interfaceName.endsWith("-controller") && !(Constants.ATTRIBUTE_CONTROLLER.equals(interfaceName))) { if (this.nfItfs == null) { // Check: is it needed to do this?... the addControllers method, or equivalent, should have // been called at construction, // and also maybe we're not using a controller config file addControllers( this.componentParameters.getControllerDescription().getControllersSignatures()); } if (this.nfItfs.containsKey(interfaceName)) { return this.nfItfs.get(interfaceName); } // TODO: Check how are the collective NF interfaces handled here ... should they also finish // by "-controller" ? throw new NoSuchInterfaceException(interfaceName); } if (this.fItfs.containsKey(interfaceName)) { return this.fItfs.get(interfaceName); } else { if (interfaceName.equals(Constants.COMPONENT)) { return this; } // maybe the member of a collection itf? InterfaceType itfType = ((ComponentType) this.getFcType()).getFcInterfaceType(interfaceName); if ((itfType != null) && itfType.isFcCollectionItf()) { try { // generate the corresponding interface locally Interface interface_reference = RepresentativeInterfaceClassGenerator.instance() .generateFunctionalInterface(interfaceName, this, (PAGCMInterfaceType) itfType); ((StubObject) interface_reference).setProxy(this.proxy); // keep it in the list of functional interfaces this.fItfs.put(interfaceName, interface_reference); return interface_reference; } catch (Throwable e) { logger.info("Could not generate " + interfaceName + " collection interface", e); } } } throw new NoSuchInterfaceException(interfaceName); }
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); } } }