コード例 #1
0
  final void deactivateInternal(int reason, boolean disable, int trackingCount) {
    if (m_disposed) {
      return;
    }
    if (m_factoryInstance) {
      disposeInternal(reason);
      return;
    }
    log(LogService.LOG_DEBUG, "Deactivating component", null);

    // catch any problems from deleting the component to prevent the
    // component to remain in the deactivating state !
    obtainActivationReadLock("deactivateInternal");
    try {
      doDeactivate(reason, disable);
    } finally {
      releaseActivationReadLock("deactivateInternal");
    }
    if (isFactory()) {
      clear();
    }
  }
コード例 #2
0
  final void activateInternal(int trackingCount) {
    log(LogService.LOG_DEBUG, "ActivateInternal", null);
    if (m_disposed) {
      log(LogService.LOG_DEBUG, "ActivateInternal: disposed", null);
      return;
    }
    if (m_activated) {
      log(LogService.LOG_DEBUG, "ActivateInternal: already activated", null);
      return;
    }
    if (!isEnabled()) {
      log(LogService.LOG_DEBUG, "Component is not enabled; not activating component", null);
      return;
    }
    if (!isActivatorActive()) {
      log(
          LogService.LOG_DEBUG,
          "Bundle's component activator is not active; not activating component",
          null);
      return;
    }

    log(
        LogService.LOG_DEBUG,
        "Activating component from state {0}",
        new Object[] {getState()},
        null);

    // Before creating the implementation object, we are going to
    // test if we have configuration if such is required
    if (!hasConfiguration() && getComponentMetadata().isConfigurationRequired()) {
      log(LogService.LOG_DEBUG, "Missing required configuration, cannot activate", null);
      return;
    }

    // Before creating the implementation object, we are going to
    // test that the bundle has enough permissions to register services
    if (!hasServiceRegistrationPermissions()) {
      log(
          LogService.LOG_DEBUG,
          "Component is not permitted to register all services, cannot activate",
          null);
      return;
    }

    obtainActivationReadLock("activateInternal");
    try {
      // Before creating the implementation object, we are going to
      // test if all the mandatory dependencies are satisfied
      if (!verifyDependencyManagers()) {
        log(LogService.LOG_DEBUG, "Not all dependencies satisfied, cannot activate", null);
        return;
      }

      if (!registerService()) {
        // some other thread is activating us, or we got concurrently deactivated.
        return;
      }

      if ((isImmediate() || getComponentMetadata().isFactory())) {
        getServiceInternal();
      }
    } finally {
      releaseActivationReadLock("activateInternal");
    }
  }