Esempio n. 1
0
  /**
   * Function that is called when configuration of the dependencies is required.
   *
   * @param c dependency manager Component object, used for configuring the dependencies exported
   *     and imported
   * @param imp Implementation class that is being configured, needed as long as the same routine
   *     can configure multiple implementations
   */
  @Override
  public void configureGlobalInstance(Component c, Object imp) {
    if (imp.equals(GlobalResourceManager.class)) {
      // Export the services.
      String[] classes = {
        IVTNGlobal.class.getName(),
        IVTNResourceManager.class.getName(),
        ICoordinatorChangeAware.class.getName(),
      };
      c.setInterface(classes, null);

      // Create service dependencies.
      c.add(
          createServiceDependency()
              .setService(IClusterGlobalServices.class)
              .setCallbacks("setClusterGlobalService", "unsetClusterGlobalService")
              .setRequired(true));
    }
  }
Esempio n. 2
0
  /**
   * Called when this class is registered as OSGi service.
   *
   * @param aComponent the bundle context to use, cannot be <code>null</code>.
   */
  protected void init(final Component aComponent) {
    final String pmFilter =
        String.format("(%s=%s)", Constants.SERVICE_PID, DeviceProfileManager.SERVICE_PID);

    aComponent //
        .add(
            this.dependencyManager
                .createServiceDependency() //
                .setService(ManagedServiceFactory.class, pmFilter) //
                .setAutoConfig("deviceProfileManagerServiceFactory") //
                .setInstanceBound(true) //
                .setRequired(true)) //
        .add(
            this.dependencyManager
                .createServiceDependency() //
                .setService(ConnectorService.class) //
                .setAutoConfig("connectorService") //
                .setInstanceBound(true) //
                .setRequired(true) //
            );
  }
Esempio n. 3
0
  /**
   * Function that is called when configuration of the dependencies is required.
   *
   * @param c dependency manager Component object, used for configuring the dependencies exported
   *     and imported
   * @param imp Implementation class that is being configured, needed as long as the same routine
   *     can configure multiple implementations
   * @param containerName The containerName being configured, this allow also optional per-container
   *     different behavior if needed, usually should not be the case though.
   */
  @Override
  public void configureInstance(Component c, Object imp, String containerName) {
    if (imp.equals(VTNManagerImpl.class)) {
      Dictionary<String, Object> props = new Hashtable<String, Object>();
      Set<String> propSet = new HashSet<String>();
      propSet.add(VTNManagerImpl.CACHE_EVENT);
      propSet.add(VTNManagerImpl.CACHE_MAC);
      props.put("cachenames", propSet);
      props.put("salListenerName", "vtnmanager");

      // Export the services.
      ArrayList<String> list = new ArrayList<String>();
      list.add(IVTNManager.class.getName());
      list.add(ICacheUpdateAware.class.getName());
      list.add(IConfigurationContainerAware.class.getName());
      list.add(IHostFinder.class.getName());
      if (containerName.equals(GlobalConstants.DEFAULT.toString())) {
        // Register dependency to MD-SAL VTN Manager provider.
        c.add(
            createServiceDependency()
                .setService(VTNManagerProvider.class)
                .setCallbacks("setVTNProvider", "unsetVTNProvider")
                .setRequired(true));
      }

      // Export IVTNFlowDebugger only if "vtn.debug" system property
      // is defined as "true".
      String debug = System.getProperty("vtn.debug");
      if (debug != null && Boolean.parseBoolean(debug)) {
        list.add(IVTNFlowDebugger.class.getName());
      }

      c.setInterface(list.toArray(new String[list.size()]), props);

      // Create service dependencies.
      c.add(
          createServiceDependency()
              .setService(IVTNResourceManager.class)
              .setCallbacks("setResourceManager", "unsetResourceManager")
              .setRequired(true));

      c.add(
          createContainerServiceDependency(containerName)
              .setService(IVTNManagerAware.class)
              .setCallbacks("addVTNManagerAware", "removeVTNManagerAware")
              .setRequired(false));

      c.add(
          createContainerServiceDependency(containerName)
              .setService(IVTNModeListener.class)
              .setCallbacks("addVTNModeListener", "removeVTNModeListener")
              .setRequired(false));

      c.add(
          createContainerServiceDependency(containerName)
              .setService(IClusterContainerServices.class)
              .setCallbacks("setClusterContainerService", "unsetClusterContainerService")
              .setRequired(true));

      // VTN manager can run without any host listener.
      c.add(
          createContainerServiceDependency(containerName)
              .setService(IfHostListener.class)
              .setCallbacks("addHostListener", "removeHostListener")
              .setRequired(false));
    }
  }