/** * @return * @see org.apache.karaf.features.Feature#getBundles() */ @Override public List<BundleInfo> getBundles() { return feature.getBundles(); }
@Override public List<BundleInfo> getBundles() { return this.feature.getBundles(); }
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; } }
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; }
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; }
/** * 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; }
/** * 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; }
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()); } } }
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()); } } }
/** * 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; }
/** * 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; }
/** * 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; }
/** * {@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(); }
outputStreamWriter.write(" installed: " + features.isInstalled(feature)); outputStreamWriter.write("\nBundles:\n"); for (BundleInfo bundle : feature.getBundles()) { outputStreamWriter.write("\t" + bundle.getLocation()); if (bundle.getStartLevel() != 0) {
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); } } }
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); } }
if (bundle) { List<String> bundleLocation = new LinkedList<>(); List<BundleInfo> bundles = resolved.getBundles(); for (BundleInfo bundleInfo : bundles) { bundleLocation.add(bundleInfo.getLocation());
for (final BundleInfo info : feature.getBundles()) { if (!onlyDependencies || (onlyDependencies && info.isDependency())) { final File resolvedLocation = resolver.resolve(info.getLocation());
for (final BundleInfo info : feature.getBundles()) { if (!onlyDependencies || (onlyDependencies && info.isDependency())) { final File resolvedLocation = resolver.resolve(info.getLocation());
/** * 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; }