org.apache.karaf.features.Feature.getBundles()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中org.apache.karaf.features.Feature.getBundles()方法的一些代码示例,展示了Feature.getBundles()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Feature.getBundles()方法的具体详情如下:
包路径:org.apache.karaf.features.Feature
类名称:Feature
方法名:getBundles

Feature.getBundles介绍

暂无

代码示例

代码示例来源:origin: org.opendaylight.controller/config-persister-feature-adapter

/**
 * @return
 * @see org.apache.karaf.features.Feature#getBundles()
 */
@Override
public List<BundleInfo> getBundles() {
  return feature.getBundles();
}

代码示例来源:origin: apache/karaf

@Override
public List<BundleInfo> getBundles() {
  return this.feature.getBundles();
}

代码示例来源:origin: org.onosproject/onos-core-net

private boolean isFullyStarted(Feature feature) {
  if (needToCheck(feature)) {
    try {
      return feature.getBundles().stream()
        .map(info -> bundleContext.getBundle())
        .allMatch(this::isFullyStarted);
    } catch (NullPointerException npe) {
      // FIXME: Remove this catch block when Felix fixes the bug
      // Due to a bug in the Felix implementation, this can throw an NPE.
      // Catch the error and do something sensible with it.
      return false;
    }
  } else {
    return true;
  }
}

代码示例来源:origin: io.fabric8/fabric-commands

private Set<String> getFeatureLocations() throws Exception {
  Set<String> bundleLocations = new LinkedHashSet<String>();
  for (Feature feature : featuresService.listFeatures()) {
    try {
      for (BundleInfo info : feature.getBundles()) {
        bundleLocations.add(info.getLocation());
      }
    } catch (Exception e) {
      //Ignore
    }
  }
  return bundleLocations;
}

代码示例来源:origin: org.fusesource.fabric/fabric-commands

private Set<String> getFeatureLocations() throws Exception {
  Set<String> bundleLocations = new LinkedHashSet<String>();
  for (Feature feature : featuresService.listFeatures()) {
    try {
      for (BundleInfo info : feature.getBundles()) {
        bundleLocations.add(info.getLocation());
      }
    } catch (Exception e) {
      //Ignore
    }
  }
  return bundleLocations;
}

代码示例来源:origin: io.fabric8.fab/fab-osgi

/**
 * Extract the required bundle locations from a feature, omitting bundles that are marked with <code>dependency="true"</code>
 *
 * @param feature the Karaf feature
 * @return the list of required bundle locations
 */
public static List<String> getRequiredLocations(Feature feature) {
  List<String> result = new LinkedList<String>();
  for (BundleInfo info : feature.getBundles()) {
    if (!info.isDependency()) {
      result.add(info.getLocation());
    }
  }
  return result;
}

代码示例来源:origin: org.fusesource.fabric.fab/fab-osgi

/**
 * Extract the required bundle locations from a feature, omitting bundles that are marked with <code>dependency="true"</code>
 *
 * @param feature the Karaf feature
 * @return the list of required bundle locations
 */
public static List<String> getRequiredLocations(Feature feature) {
  List<String> result = new LinkedList<String>();
  for (BundleInfo info : feature.getBundles()) {
    if (!info.isDependency()) {
      result.add(info.getLocation());
    }
  }
  return result;
}

代码示例来源:origin: apache/karaf

private void displayBundleInformation(Feature feature, String contentType) {
  List<BundleInfo> bundleInfos = feature.getBundles();
  if (bundleInfos.isEmpty()) {
    System.out.println(contentType + " has no bundles.");
  } else {
    System.out.println(contentType + " contains followed bundles:");
    for (BundleInfo featureBundle : bundleInfos) {
      int startLevel = featureBundle.getStartLevel();
      StringBuilder sb = new StringBuilder();
      sb.append(INDENT).append(featureBundle.getLocation());
      if(startLevel > 0) {
        sb.append(" start-level=").append(startLevel);
      }
      if (featureBundle.isOverriden() != BundleInfo.BundleOverrideMode.NONE) {
        sb.append(" (overriden from " + featureBundle.getOriginalLocation() + ")");
      }
      System.out.println(sb.toString());
    }
  }
}

代码示例来源:origin: org.apache.karaf.features/org.apache.karaf.features.command

private void displayBundleInformation(Feature feature, String contentType) {
  List<BundleInfo> bundleInfos = feature.getBundles();
  if (bundleInfos.isEmpty()) {
    System.out.println(contentType + " has no bundles.");
  } else {
    System.out.println(contentType + " contains followed bundles:");
    for (BundleInfo featureBundle : bundleInfos) {
      int startLevel = featureBundle.getStartLevel();
      StringBuilder sb = new StringBuilder();
      sb.append(INDENT).append(featureBundle.getLocation());
      if(startLevel > 0) {
        sb.append(" start-level=").append(startLevel);
      }
      if (featureBundle.isOverriden() != BundleInfo.BundleOverrideMode.NONE) {
        sb.append(" (overriden from " + featureBundle.getOriginalLocation() + ")");
      }
      System.out.println(sb.toString());
    }
  }
}

代码示例来源:origin: org.apache.karaf.cellar/org.apache.karaf.cellar.bundle

/**
 * Get the list of features where the bundle is belonging.
 *
 * @param bundleLocation the bundle location.
 * @return the list of feature where the bundle is present.
 * @throws Exception in case of retrieval failure.
 */
protected List<Feature> retrieveFeature(String bundleLocation) throws Exception {
  Feature[] features = featuresService.listFeatures();
  List<Feature> matchingFeatures = new ArrayList<Feature>();
  for (Feature feature : features) {
    List<BundleInfo> bundles = feature.getBundles();
    for (BundleInfo bundleInfo : bundles) {
      String location = bundleInfo.getLocation();
      if (location.equalsIgnoreCase(bundleLocation)) {
        matchingFeatures.add(feature);
        LOGGER.debug("CELLAR BUNDLE: found a feature {} containing bundle {}", feature.getName(), bundleLocation);
      }
    }
  }
  return matchingFeatures;
}

代码示例来源:origin: apache/karaf-cellar

/**
 * Get the list of features where the bundle is belonging.
 *
 * @param bundleLocation the bundle location.
 * @return the list of feature where the bundle is present.
 * @throws Exception in case of retrieval failure.
 */
protected List<Feature> retrieveFeature(String bundleLocation) throws Exception {
  Feature[] features = featuresService.listFeatures();
  List<Feature> matchingFeatures = new ArrayList<Feature>();
  for (Feature feature : features) {
    List<BundleInfo> bundles = feature.getBundles();
    for (BundleInfo bundleInfo : bundles) {
      String location = bundleInfo.getLocation();
      if (location.equalsIgnoreCase(bundleLocation)) {
        matchingFeatures.add(feature);
        LOGGER.debug("CELLAR BUNDLE: found a feature {} containing bundle {}", feature.getName(), bundleLocation);
      }
    }
  }
  return matchingFeatures;
}

代码示例来源:origin: org.apache.karaf.features/org.apache.karaf.features.obr

/**
 * get all bundles from a given feature, including the bundles from dependency
 * features
 *
 * @param feature
 */
public List<BundleInfo> getAllBundles(Feature feature) throws Exception {
  List<BundleInfo> bundles = new ArrayList<BundleInfo>();
  bundles.addAll(feature.getBundles());
  for (Dependency dependency : feature.getDependencies()) {
    Feature dependencyfeature = getFeaturesService().getFeature(dependency.getName(), dependency.getVersion());
    bundles.addAll(getAllBundles(dependencyfeature));
  }
  return bundles;
  
}

代码示例来源:origin: apache/karaf

/**
 * {@inheritDoc}
 */
protected void writeDump(OutputStreamWriter outputStreamWriter) throws Exception {
  // creates header
  outputStreamWriter.write("Repositories:\n");
  // list repositories
  for (Repository repo : features.listRepositories()) {
    outputStreamWriter.write(repo.getURI() + " (" + repo.getName() + ")\n");
  }
  // list features
  outputStreamWriter.write("\nfeatures:\n");
  for (Feature feature : features.listFeatures()) {
    outputStreamWriter.write(feature.getName() + " " + feature.getVersion());
    outputStreamWriter.write(" installed: " + features.isInstalled(feature));
    outputStreamWriter.write("\nBundles:\n");
    for (BundleInfo bundle : feature.getBundles()) {
      outputStreamWriter.write("\t" + bundle.getLocation());
      if (bundle.getStartLevel() != 0) {
        outputStreamWriter.write(" start level " + bundle.getStartLevel());
      }
      outputStreamWriter.write("\n\n");
    }
  }
  // flush & close stream
  outputStreamWriter.close();
}

代码示例来源:origin: org.apache.karaf.diagnostic/org.apache.karaf.diagnostic.common

outputStreamWriter.write(" installed: " + features.isInstalled(feature));
outputStreamWriter.write("\nBundles:\n");
for (BundleInfo bundle : feature.getBundles()) {
  outputStreamWriter.write("\t" + bundle.getLocation());
  if (bundle.getStartLevel() != 0) {

代码示例来源:origin: apache/karaf

private void copyFeatureToJar(JarOutputStream jos, Feature feature, Map<URI, Integer> locationMap)
  throws URISyntaxException {
  // add bundles
  for (BundleInfo bundleInfo : feature.getBundles()) {
    URI location = new URI(bundleInfo.getLocation().trim());
    copyResourceToJar(jos, location, locationMap);
  }
  // add config files
  for (ConfigFileInfo configFileInfo : feature.getConfigurationFiles()) {
    URI location = new URI(configFileInfo.getLocation().trim());
    copyResourceToJar(jos, location, locationMap);
  }
  // add bundles and config files in conditionals
  for (Conditional conditional : feature.getConditional()) {
    for (BundleInfo bundleInfo : conditional.getBundles()) {
      URI location = new URI(bundleInfo.getLocation().trim());
      copyResourceToJar(jos, location, locationMap);
    }
    for (ConfigFileInfo configFileInfo : conditional.getConfigurationFiles()) {
      URI location = new URI(configFileInfo.getLocation().trim());
      copyResourceToJar(jos, location, locationMap);
    }
  }
}

代码示例来源:origin: apache/karaf

public JmxFeature(Feature feature, boolean installed, boolean required) {
  try {
    String[] itemNames = FeaturesServiceMBean.FEATURE;
    Object[] itemValues = new Object[itemNames.length];
    itemValues[0] = feature.getName();
    itemValues[1] = feature.getVersion();
    itemValues[2] = getDependencyIdentifierTable(feature.getDependencies());
    itemValues[3] = getBundleUris(feature.getBundles());
    itemValues[4] = getConfigList(feature.getConfigurations());
    itemValues[5] = getConfigFileList(feature.getConfigurationFiles());
    itemValues[6] = installed;
    itemValues[7] = feature.isBlacklisted();
    itemValues[8] = required;
    data = new CompositeDataSupport(FEATURE, itemNames, itemValues);
  } catch (OpenDataException e) {
    throw new IllegalStateException("Cannot form feature open data", e);
  }
}

代码示例来源:origin: org.apache.karaf.features/org.apache.karaf.features.command

if (bundle) {
  List<String> bundleLocation = new LinkedList<>();
  List<BundleInfo> bundles = resolved.getBundles();
  for (BundleInfo bundleInfo : bundles) {
    bundleLocation.add(bundleInfo.getLocation());

代码示例来源:origin: apache/karaf

for (final BundleInfo info : feature.getBundles()) {
  if (!onlyDependencies || (onlyDependencies && info.isDependency())) {
    final File resolvedLocation = resolver.resolve(info.getLocation());

代码示例来源:origin: org.apache.karaf.features/org.apache.karaf.features.command

for (final BundleInfo info : feature.getBundles()) {
  if (!onlyDependencies || (onlyDependencies && info.isDependency())) {
    final File resolvedLocation = resolver.resolve(info.getLocation());

代码示例来源:origin: apache/karaf

/**
 * Constructs {@link Resource} for given non-conditional feature.
 */
public static FeatureResource build(Feature feature, String featureRange, Map<String, ? extends Resource> locToRes) throws BundleException {
  FeatureResource resource = new FeatureResource(feature);
  for (BundleInfo info : feature.getBundles()) {
    if (!info.isDependency() && !info.isBlacklisted()) {
      Resource res = locToRes.get(info.getLocation());
      if (res == null) {
        throw new IllegalStateException("Resource not found for url " + info.getLocation());
      }
      addIdentityRequirement(resource, res);
    }
  }
  for (Dependency dep : feature.getDependencies()) {
    if (!dep.isDependency() && !dep.isBlacklisted()) {
      addDependency(resource, dep, featureRange);
    }
  }
  for (org.apache.karaf.features.Capability cap : feature.getCapabilities()) {
    resource.addCapabilities(ResourceBuilder.parseCapability(resource, cap.getValue()));
  }
  for (org.apache.karaf.features.Requirement req : feature.getRequirements()) {
    resource.addRequirements(ResourceBuilder.parseRequirement(resource, req.getValue()));
  }
  return resource;
}

相关文章