use of org.apache.karaf.features.Feature in project karaf by apache.
the class KarafTestSupport method assertFeatureNotInstalled.
public void assertFeatureNotInstalled(String featureName, String featureVersion) throws Exception {
Feature featureToAssert = featureService.getFeatures(featureName, featureVersion)[0];
Feature[] features = featureService.listInstalledFeatures();
for (Feature feature : features) {
if (featureToAssert.equals(feature)) {
Assert.fail("Feature " + featureName + (featureVersion != null ? "/" + featureVersion : "") + " is installed whereas it should not be");
}
}
}
use of org.apache.karaf.features.Feature in project karaf by apache.
the class KarafTestSupport method assertFeaturesInstalled.
public void assertFeaturesInstalled(String... expectedFeatures) throws Exception {
Set<String> expectedFeaturesSet = new HashSet<>(Arrays.asList(expectedFeatures));
Feature[] features = featureService.listInstalledFeatures();
Set<String> installedFeatures = new HashSet<>();
for (Feature feature : features) {
installedFeatures.add(feature.getName());
}
String msg = "Expecting the following features to be installed : " + expectedFeaturesSet + " but found " + installedFeatures;
Assert.assertTrue(msg, installedFeatures.containsAll(expectedFeaturesSet));
}
use of org.apache.karaf.features.Feature in project karaf by apache.
the class KarServiceImpl method getFeatures.
private Set<Feature> getFeatures(Map<String, Feature> featureMap, List<String> features, int depth) {
Set<Feature> featureSet = new HashSet<>();
if (depth > 5) {
// Break after some recursions to avoid endless loops
return featureSet;
}
if (features == null) {
featureSet.addAll(featureMap.values());
return featureSet;
}
for (String featureName : features) {
Feature feature = featureMap.get(featureName);
if (feature == null) {
System.out.println("Feature " + featureName + " not found in repository.");
//throw new RuntimeException();
} else {
featureSet.add(feature);
List<Dependency> deps = feature.getDependencies();
List<String> depNames = new ArrayList<>();
for (Dependency dependency : deps) {
depNames.add(dependency.getName());
}
featureSet.addAll(getFeatures(featureMap, depNames, depth++));
}
}
return featureSet;
}
use of org.apache.karaf.features.Feature in project karaf by apache.
the class FeaturesServiceMBeanImpl method infoFeature.
private TabularData infoFeature(Feature[] f) throws Exception {
ArrayList<JmxFeature> features = new ArrayList<>();
for (Feature feature : f) {
JmxFeature jmxFeature;
if (featuresService.isInstalled(feature)) {
jmxFeature = new JmxFeature(feature, true);
} else {
jmxFeature = new JmxFeature(feature, false);
}
features.add(jmxFeature);
}
return JmxFeature.tableFrom(features);
}
use of org.apache.karaf.features.Feature in project ddf by codice.
the class ApplicationServiceImpl method getCurrentBundleStates.
/**
* Evaluates the bundles contained in a set of {@link Feature}s and
* determines if each bundle is currently in an active, inactive, or failed
* state.
*
* @param features
* @return {@link BundleStateSet} containing information on the state of
* each bundle
*/
private final BundleStateSet getCurrentBundleStates(Set<Feature> features) {
BundleStateSet bundleStateSet = new BundleStateSet();
for (Feature curFeature : features) {
for (BundleInfo curBundleInfo : curFeature.getBundles()) {
Bundle curBundle = getContext().getBundle(curBundleInfo.getLocation());
if (curBundle != null && curBundle.adapt(BundleRevision.class).getTypes() != BundleRevision.TYPE_FRAGMENT) {
// check if bundle is inactive
int bundleState = curBundle.getState();
switch(bundleState) {
case Bundle.RESOLVED:
case Bundle.STARTING:
case Bundle.STOPPING:
bundleStateSet.addInactiveBundle(curBundle);
break;
case Bundle.INSTALLED:
case Bundle.UNINSTALLED:
bundleStateSet.addFailedBundle(curBundle);
break;
case Bundle.ACTIVE:
// and SpringDM) failed on start
for (BundleStateService curStateService : bundleStateServices) {
LOGGER.trace("Checking {} for bundle state of {}.", curStateService.getName(), curBundle.getSymbolicName());
BundleState curState = curStateService.getState(curBundle);
switch(curState) {
case Resolved:
case Stopping:
LOGGER.trace("{} is in an inactive state. Current State: {}", curBundle.getSymbolicName(), curState.toString());
bundleStateSet.addInactiveBundle(curBundle);
break;
case Installed:
case Failure:
LOGGER.trace("{} is in a failed state. Current State: {}", curBundle.getSymbolicName(), curState.toString());
bundleStateSet.addFailedBundle(curBundle);
break;
case Waiting:
case Starting:
case GracePeriod:
LOGGER.trace("{} is in a transitional state. Current State: {}", curBundle.getSymbolicName(), curState.toString());
bundleStateSet.addTransitionalBundle(curBundle);
break;
case Active:
LOGGER.trace("{} is in an active state. Current State: {}", curBundle.getSymbolicName(), curState.toString());
bundleStateSet.addActiveBundle(curBundle);
break;
case Unknown:
default:
// Ignore - BundleStateService unaware of this bundle.
break;
}
}
// end case Bundle.Active
break;
default:
bundleStateSet.addActiveBundle(curBundle);
break;
}
}
}
}
return bundleStateSet;
}
Aggregations