/** * 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()); } } }
if (bundle.isBlacklisted()) { LOGGER.info(" skipping blacklisted maven artifact: " + bundle.getLocation()); return; if (bundle.isOverriden() != BundleInfo.BundleOverrideMode.NONE) { LOGGER.info(" adding overriden maven artifact: " + bundle.getLocation() + " (original location: " + bundle.getOriginalLocation() + ")"); } else { LOGGER.info(" adding maven artifact: " + bundle.getLocation()); String location = bundle.getLocation().trim(); location = removeTrailingSlash(stripUrl(location)); if (!location.startsWith("mvn:")) {
@Override public void bundleBlacklisted(BundleInfo bundleInfo) { LOGGER.info(" skipping blacklisted bundle: {}", bundleInfo.getLocation()); }
if (bi.isBlacklisted()) { iterator.remove(); if (callback != null) { final String loc = bi.getLocation(); downloader.download(loc, provider -> { bundles.put(loc, resource); if (bi.isOverriden() == BundleInfo.BundleOverrideMode.OSGI) { downloader.download(bi.getOriginalLocation(), provider2 -> { ResourceImpl originalResource = createResource(bi.getOriginalLocation(), getMetadata(provider2), removeServiceRequirements); bundles.put(bi.getOriginalLocation(), originalResource); final String loc = bi.getLocation(); final Conditional cond = entry.getValue(); ResourceImpl res = bundles.get(loc); int sl = bi.getStartLevel() <= 0 ? feature.getStartLevel() : bi.getStartLevel(); if (cond != null) { boolean mandatory = !bi.isDependency() && cond == null; if (bi.isDependency()) { addDependency(res, mandatory, bi.isStart(), sl, bi.isBlacklisted()); } else { doAddDependency(res, mandatory, bi.isStart(), sl, bi.isBlacklisted());
/** * 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; }
/** * {@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(); }
if (bundleInfo != null && bundleInfo.isStart() && !noStart) { states.put(resource, FeatureState.Started); } else { BundleInfo bi = bundleInfos.get(region).get(getUri(resource)); if (bi != null) { int sl = bi.getStartLevel() > 0 ? bi.getStartLevel() : dstate.initialBundleStartLevel; startLevels.put(resource, sl); Bundle bundle = deployment.resToBnd.get(resource);
@Override public void bundleBlacklisted(BundleInfo bundleInfo) { LOGGER.info(" skipping blacklisted bundle: {}", bundleInfo.getLocation()); }
if (bundle.isBlacklisted()) { LOGGER.info(" skipping blacklisted maven artifact: " + bundle.getLocation()); return; if (bundle.isOverriden() != BundleInfo.BundleOverrideMode.NONE) { LOGGER.info(" adding overriden maven artifact: " + bundle.getLocation() + " (original location: " + bundle.getOriginalLocation() + ")"); } else { LOGGER.info(" adding maven artifact: " + bundle.getLocation()); String location = bundle.getLocation().trim(); location = removeTrailingSlash(stripUrl(location)); if (!location.startsWith("mvn:")) {
outputStreamWriter.write("\nBundles:\n"); for (BundleInfo bundle : feature.getBundles()) { outputStreamWriter.write("\t" + bundle.getLocation()); if (bundle.getStartLevel() != 0) { outputStreamWriter.write(" start level " + bundle.getStartLevel());
/** * 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; }
static String[] getBundleUris(List<BundleInfo> infos) { String[] array = new String[infos.size()]; for (int i = 0; i < array.length; i++) { array[i] = infos.get(i).getLocation(); } return array; }
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 copyBundlesConditionalToDestRepository(List<? extends BundleInfo> artifactRefsConditional) throws MojoExecutionException { for (BundleInfo artifactRef : artifactRefsConditional) { if (ignoreDependencyFlag || (!ignoreDependencyFlag && !artifactRef.isDependency())) { Artifact artifact = resourceToArtifact(artifactRef.getLocation(), skipNonMavenProtocols); // Avoid getting NPE on artifact.getFile in some cases resolveArtifact(artifact, remoteRepos); if (artifact != null) { copy(artifact, repository); } } } }
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 void copyBundlesConditionalToDestRepository(List<? extends BundleInfo> artifactRefsConditional) throws MojoExecutionException { for (BundleInfo artifactRef : artifactRefsConditional) { if (ignoreDependencyFlag || (!ignoreDependencyFlag && !artifactRef.isDependency())) { Artifact artifact = resourceToArtifact(artifactRef.getLocation(), skipNonMavenProtocols); // Avoid getting NPE on artifact.getFile in some cases resolveArtifact(artifact, remoteRepos); if (artifact != null) { copy(artifact, repository); } } } }
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; }
/** * Read bundles and configuration files in the features file. * * @return * @throws MojoExecutionException */ private List<Artifact> readResources(File featuresFile) throws MojoExecutionException { List<Artifact> resources = new ArrayList<>(); try { Features features = JaxbUtil.unmarshal(featuresFile.toURI().toASCIIString(), false); for (Feature feature : features.getFeature()) { for (BundleInfo bundle : feature.getBundles()) { if (ignoreDependencyFlag || (!ignoreDependencyFlag && !bundle.isDependency())) { resources.add(resourceToArtifact(bundle.getLocation(), false)); } } for (ConfigFileInfo configFile : feature.getConfigurationFiles()) { resources.add(resourceToArtifact(configFile.getLocation(), false)); } } return resources; } catch (MojoExecutionException e) { throw e; } catch (Exception e) { throw new MojoExecutionException("Could not interpret features.xml", e); } }
/** * 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; }