/** * @throws Exception */ @Test public void testAllBundlesActiveAndFeaturesInstalled() throws Exception { // Asssert all bundles except fragments are ACTIVE. for (Bundle b : bundleCtx.getBundles()) { System.out.println(String.format("Checking state of bundle [symbolicName=%s, state=%s]", b.getSymbolicName(), b.getState())); if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) assertTrue(b.getState() == Bundle.ACTIVE); } // Check that according to the FeaturesService, all Ignite features except ignite-log4j are installed. Feature[] features = featuresSvc.getFeatures(IGNITE_FEATURES_NAME_REGEX); assertNotNull(features); assertEquals(EXPECTED_FEATURES, features.length); for (Feature f : features) { if (IGNORED_FEATURES.contains(f.getName())) continue; boolean installed = featuresSvc.isInstalled(f); System.out.println(String.format("Checking if feature is installed [featureName=%s, installed=%s]", f.getName(), installed)); assertTrue(installed); assertEquals(PROJECT_VERSION.replaceAll("-", "."), f.getVersion().replaceAll("-", ".")); } }
/** * @return * @see org.apache.karaf.features.Feature#getBundles() */ @Override public List<BundleInfo> getBundles() { return feature.getBundles(); }
/** * @return * @see org.apache.karaf.features.Feature#getId() */ @Override public String getId() { return feature.getId(); }
protected void add(List<Candidate> candidates, Feature feature) { candidates.add(new Candidate( feature.getName(), feature.getName(), null, feature.getDescription(), null, null, true)); }
public FeatureReq(Feature feature) { this(feature.getName(), exactVersion(feature.getVersion()), feature.isBlacklisted()); }
for (Feature resolved:resolvedFeatures) { if (resolved != null) { System.out.println(prefix + " " + resolved.getName() + " " + resolved.getVersion()); } else { System.out.println(prefix + " " + featureName + " " + featureVersion + " *"); if (bundle) { List<String> bundleLocation = new LinkedList<>(); List<BundleInfo> bundles = resolved.getBundles(); for (BundleInfo bundleInfo : bundles) { bundleLocation.add(bundleInfo.getLocation()); for (Conditional cond : resolved.getConditional()) { List<String> condition = cond.getCondition(); List<BundleInfo> conditionalBundles = cond.getBundles(); List<Dependency> dependencies = resolved.getDependencies(); for (Dependency toDisplay : dependencies) { unresolved += displayFeatureTree(admin, toDisplay.getName(), toDisplay.getVersion(), prefix); for (Conditional cond : resolved.getConditional()) { List<Dependency> conditionDependencies = cond.getDependencies(); for (int i = 0, j = conditionDependencies.size(); i < j; i++) {
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); } }
/** * Adds {@link Feature} and its dependencies to the set of {@link Feature}s. */ private void addFeatures(Feature feature, Set<Feature> features) { if (features.contains(feature)) { return; } features.add(feature); for (Feature dependency : feature.getDependencies()) { addFeatures(search(dependency.getName(), dependency.getVersion(), repositories.asMap().values()), features); } }
/** * {@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(); }
for (Dependency dep : feature.getDependencies()) { if (dep.isBlacklisted()) { continue; for (Conditional cond : feature.getConditional()) { if (cond.isBlacklisted()) { continue; String ssName = this.name + "#" + (fcond.hasVersion() ? fcond.getName() + "-" + fcond.getVersion() : fcond.getName()); Subsystem fs = getChild(ssName); if (fs == null) { if (TYPE_FEATURE.equals(type) && allFeatures.containsKey(name)) { for (Feature feature : allFeatures.get(name)) { if (range == null || range.contains(VersionTable.getVersion(feature.getVersion()))) { if (feature != this.feature && !feature.isBlacklisted()) { String ssName = this.name + "#" + (feature.hasVersion() ? feature.getName() + "-" + feature.getVersion() : feature.getName()); Subsystem fs = getChild(ssName); if (fs == null) {
@Override public String getName() { return this.feature.getName(); }
private Extension getExtension(Feature feature) { String name = getName(feature.getName()); String type = getType(feature.getName()); String extId = type + "-" + name; String label = feature.getDescription(); String version = feature.getVersion(); String link = null; if (type.equals("binding")) { link = "https://www.openhab.org/addons/bindings/" + name + "/"; } else if (type.equals("action")) { link = "https://www.openhab.org/addons/actions/" + name + "/"; } else if (type.equals("persistence")) { link = "https://www.openhab.org/addons/persistence/" + name + "/"; } boolean installed = featuresService.isInstalled(feature); return new Extension(extId, type, label, version, link, installed); }
/** * 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; }
/** * Sets a list of features and stores it as map of features where the key is <code>name</code> and value is a * list of features with different versions. * @param featuresList */ public void partitionFeatures(Collection<Feature> featuresList) { features = new HashMap<>(); featuresById = new HashMap<>(); for (Feature feature : featuresList) { features.computeIfAbsent(feature.getName(), name -> new ArrayList<>()).add(feature); featuresById.put(feature.getId(), feature); } } }
final Downloader downloader = manager.createDownloader(); if (feature != null) { for (Conditional cond : feature.getConditional()) { if (!cond.isBlacklisted()) { for (final BundleInfo bi : cond.getBundles()) { for (BundleInfo bi : feature.getBundles()) { infos.put(bi, null); for (Library library : feature.getLibraries()) { if (library.isExport()) { final String loc = library.getLocation(); for (Conditional cond : feature.getConditional()) { if (cond.isBlacklisted()) { continue; final Conditional cond = entry.getValue(); ResourceImpl res = bundles.get(loc); int sl = bi.getStartLevel() <= 0 ? feature.getStartLevel() : bi.getStartLevel(); if (cond != null) { for (Library library : feature.getLibraries()) { if (library.isExport()) { final String loc = library.getLocation(); for (String uri : feature.getResourceRepositories()) { BaseRepository repo = repos.getRepository(feature.getRepositoryUrl(), uri); for (Resource resource : repo.getResources()) {
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); } } }
/** * 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; }
/** * 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; }
@Override public String getVersion() { return this.feature.getVersion(); }
String fVersion = featureUpdate.getPreviousVersion(); Feature f = featuresService.getFeature(fName, fVersion); for (BundleInfo bundleInfo : f.getBundles()) { if (/*!bundleInfo.isDependency() && */locationsOfBundleKeys.containsKey(bundleInfo.getLocation())) { bundleKeysFromFeatures.add(locationsOfBundleKeys.get(bundleInfo.getLocation())); for (Conditional cond : f.getConditional()) { for (BundleInfo bundleInfo : cond.getBundles()) { if (/*!bundleInfo.isDependency() && */locationsOfBundleKeys.containsKey(bundleInfo.getLocation())) {