use of org.apache.karaf.features.Dependency in project karaf by apache.
the class FeatureResource method build.
/**
* 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()) {
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;
}
use of org.apache.karaf.features.Dependency in project karaf by apache.
the class InfoFeatureCommand method displayFeatureTree.
/**
* Called originally with featureName and featureVersion that have already been resolved successfully.
*
* @param admin
* @param featureName
* @param featureVersion
* @param prefix
* @return
* @throws Exception
*/
private int displayFeatureTree(FeaturesService admin, String featureName, String featureVersion, String prefix) throws Exception {
int unresolved = 0;
Feature[] resolvedFeatures = admin.getFeatures(featureName, featureVersion);
for (Feature resolved : resolvedFeatures) {
if (resolved != null) {
System.out.println(prefix + " " + resolved.getName() + " " + resolved.getVersion());
} else {
System.out.println(prefix + " " + featureName + " " + featureVersion + " *");
unresolved++;
}
if (resolved != null) {
if (bundle) {
List<String> bundleLocation = new LinkedList<>();
List<BundleInfo> bundles = resolved.getBundles();
for (BundleInfo bundleInfo : bundles) {
bundleLocation.add(bundleInfo.getLocation());
}
if (conditional) {
for (Conditional cond : resolved.getConditional()) {
List<String> condition = cond.getCondition();
List<BundleInfo> conditionalBundles = cond.getBundles();
for (BundleInfo bundleInfo : conditionalBundles) {
bundleLocation.add(bundleInfo.getLocation() + "(condition:" + condition + ")");
}
}
}
for (int i = 0, j = bundleLocation.size(); i < j; i++) {
System.out.println(prefix + " " + (i + 1 == j ? "\\" : "+") + " " + bundleLocation.get(i));
}
}
prefix += " ";
List<Dependency> dependencies = resolved.getDependencies();
for (Dependency toDisplay : dependencies) {
unresolved += displayFeatureTree(admin, toDisplay.getName(), toDisplay.getVersion(), prefix);
}
if (conditional) {
for (Conditional cond : resolved.getConditional()) {
List<Dependency> conditionDependencies = cond.getDependencies();
for (int i = 0, j = conditionDependencies.size(); i < j; i++) {
Dependency toDisplay = dependencies.get(i);
unresolved += displayFeatureTree(admin, toDisplay.getName(), toDisplay.getVersion(), prefix);
}
}
}
}
}
return unresolved;
}
use of org.apache.karaf.features.Dependency in project controller by opendaylight.
the class ChildAwareFeatureWrapper method getChildFeatures.
/*
* Get FeatureConfigSnapshotHolders appropriate to feed to the config subsystem
* from the underlying Feature Config files and those of its children recursively
*/
public Set<? extends ChildAwareFeatureWrapper> getChildFeatures() throws Exception {
List<Dependency> dependencies = feature.getDependencies();
Set<ChildAwareFeatureWrapper> childFeatures = new LinkedHashSet<>();
if (dependencies != null) {
for (Dependency dependency : dependencies) {
Feature fi = extractFeatureFromDependency(dependency);
if (fi != null) {
if (featuresService.getFeature(fi.getName(), fi.getVersion()) == null) {
LOG.warn("Feature: {}, {} is missing from features service. Skipping", fi.getName(), fi.getVersion());
} else {
ChildAwareFeatureWrapper wrappedFeature = new ChildAwareFeatureWrapper(fi, featuresService);
childFeatures.add(wrappedFeature);
}
}
}
}
return childFeatures;
}
use of org.apache.karaf.features.Dependency in project ddf by codice.
the class ApplicationServiceBeanTest method testGetInstallationProfiles.
/**
* Tests the {@link ApplicationServiceBean#getInstallationProfiles()} method
*
* @throws Exception
*/
@Test
public void testGetInstallationProfiles() throws Exception {
Feature testFeature1 = mock(Feature.class);
Feature testFeature2 = mock(Feature.class);
Dependency testDependency1 = mock(Dependency.class);
Dependency testDependency2 = mock(Dependency.class);
when(testFeature1.getName()).thenReturn(TEST_FEATURE_NAME);
when(testFeature2.getName()).thenReturn(TEST_FEATURE_NAME);
when(testDependency1.getName()).thenReturn(TEST_FEATURE_NAME);
when(testDependency2.getName()).thenReturn(TEST_FEATURE_NAME);
when(testFeature1.getDescription()).thenReturn(TEST_FEATURE_DESCRIPTION);
when(testFeature2.getDescription()).thenReturn(TEST_FEATURE_DESCRIPTION);
List<Dependency> dependencies1 = new ArrayList<>();
dependencies1.add(testDependency1);
List<Dependency> dependencies2 = new ArrayList<>();
dependencies2.add(testDependency2);
when(testFeature1.getDependencies()).thenReturn(dependencies1);
when(testFeature2.getDependencies()).thenReturn(dependencies2);
List<Feature> featureList = new ArrayList<>();
featureList.add(testFeature1);
featureList.add(testFeature2);
when(testAppService.getInstallationProfiles()).thenReturn(featureList);
ApplicationServiceBean serviceBean = newApplicationServiceBean();
List<Map<String, Object>> result = serviceBean.getInstallationProfiles();
assertThat("Should contain the nodes set up previously.", (String) result.get(0).get("name"), is(TEST_FEATURE_NAME));
assertThat("Should have two entries.", result.size(), is(2));
}
use of org.apache.karaf.features.Dependency in project ddf by codice.
the class ProfileListCommandTest method createMockDependency.
private Dependency createMockDependency(String name) {
Dependency dependency = mock(Dependency.class);
when(dependency.getName()).thenReturn(name);
when(dependency.getVersion()).thenReturn("0.0.0");
return dependency;
}
Aggregations