/** {@inheritDoc} */
  public List<ServiceDetector> getDetectorsForForeignSource(final String foreignSourceName) {
    final ForeignSource foreignSource =
        m_foreignSourceRepository.getForeignSource(foreignSourceName);
    assertNotNull(foreignSource, "Expected a foreignSource with name %s", foreignSourceName);

    final List<PluginConfig> detectorConfigs = foreignSource.getDetectors();
    if (detectorConfigs == null) {
      return new ArrayList<ServiceDetector>(m_pluginRegistry.getAllPlugins(ServiceDetector.class));
    }

    final List<ServiceDetector> detectors = new ArrayList<ServiceDetector>(detectorConfigs.size());
    for (final PluginConfig detectorConfig : detectorConfigs) {
      final ServiceDetector detector =
          m_pluginRegistry.getPluginInstance(ServiceDetector.class, detectorConfig);
      if (detector == null) {
        errorf(this, "Configured plugin does not exist: %s", detectorConfig);
      } else {
        detector.setServiceName(detectorConfig.getName());
        detector.init();
        detectors.add(detector);
      }
    }

    return detectors;
  }
  /**
   * getPluginsForForeignSource
   *
   * @param pluginClass a {@link java.lang.Class} object.
   * @param foreignSourceName a {@link java.lang.String} object.
   * @param <T> a T object.
   * @return a {@link java.util.List} object.
   */
  public <T> List<T> getPluginsForForeignSource(
      final Class<T> pluginClass, final String foreignSourceName) {
    final ForeignSource foreignSource =
        m_foreignSourceRepository.getForeignSource(foreignSourceName);
    assertNotNull(foreignSource, "Expected a foreignSource with name %s", foreignSourceName);

    final List<PluginConfig> configs = foreignSource.getPolicies();
    if (configs == null) {
      return Collections.emptyList();
    }

    final List<T> plugins = new ArrayList<T>(configs.size());
    for (final PluginConfig config : configs) {
      final T plugin = m_pluginRegistry.getPluginInstance(pluginClass, config);
      if (plugin == null) {
        LogUtils.tracef(
            this,
            "Configured plugin is not appropropriate for policy class %s: %s",
            pluginClass,
            config);
      } else {
        plugins.add(plugin);
      }
    }

    return plugins;
  }