Search in sources :

Example 1 with Feature

use of org.apache.karaf.features.Feature in project karaf by apache.

the class KarafTestSupport method assertFeatureInstalled.

public void assertFeatureInstalled(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)) {
            return;
        }
    }
    Assert.fail("Feature " + featureName + (featureVersion != null ? "/" + featureVersion : "") + " should be installed but is not");
}
Also used : Feature(org.apache.karaf.features.Feature)

Example 2 with Feature

use of org.apache.karaf.features.Feature in project karaf by apache.

the class FeaturesPlugin method getFeatures.

private List<ExtendedFeature> getFeatures(List<Repository> repositories) {
    List<ExtendedFeature> features = new ArrayList<>();
    if (featuresService == null) {
        this.log.error("Features service is not available");
        return features;
    }
    try {
        for (Repository r : repositories) {
            for (Feature f : r.getFeatures()) {
                ExtendedFeature.State state = featuresService.isInstalled(f) ? ExtendedFeature.State.INSTALLED : ExtendedFeature.State.UNINSTALLED;
                features.add(new ExtendedFeature(state, r.getName(), f));
            }
        }
    } catch (Exception e) {
        this.log.error(e.getMessage());
    }
    Collections.sort(features, new ExtendedFeatureComparator());
    return features;
}
Also used : Repository(org.apache.karaf.features.Repository) ArrayList(java.util.ArrayList) Feature(org.apache.karaf.features.Feature) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 3 with Feature

use of org.apache.karaf.features.Feature in project karaf by apache.

the class JmxRepository method getFeatureIdentifierTable.

static TabularData getFeatureIdentifierTable(List<Feature> features) throws OpenDataException {
    TabularDataSupport table = new TabularDataSupport(JmxFeature.FEATURE_IDENTIFIER_TABLE);
    for (Feature feature : features) {
        String[] itemNames = new String[] { FeaturesServiceMBean.FEATURE_NAME, FeaturesServiceMBean.FEATURE_VERSION };
        Object[] itemValues = new Object[] { feature.getName(), feature.getVersion() };
        CompositeData ident = new CompositeDataSupport(JmxFeature.FEATURE_IDENTIFIER, itemNames, itemValues);
        table.put(ident);
    }
    return table;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Feature(org.apache.karaf.features.Feature)

Example 4 with Feature

use of org.apache.karaf.features.Feature in project karaf by apache.

the class FeaturesServiceImpl method getDeploymentState.

private Deployer.DeploymentState getDeploymentState(State state) throws Exception {
    Deployer.DeploymentState dstate = new Deployer.DeploymentState();
    dstate.state = state;
    FrameworkInfo info = installSupport.getInfo();
    dstate.serviceBundle = info.ourBundle;
    dstate.initialBundleStartLevel = info.initialBundleStartLevel;
    dstate.currentStartLevel = info.currentStartLevel;
    dstate.bundles = info.bundles;
    // Features
    dstate.features = new HashMap<>();
    for (Map<String, Feature> m : getFeatures().values()) {
        for (Feature feature : m.values()) {
            String id = feature.getId();
            dstate.features.put(id, feature);
        }
    }
    RegionDigraph regionDigraph = installSupport.getDiGraphCopy();
    dstate.bundlesPerRegion = DigraphHelper.getBundlesPerRegion(regionDigraph);
    dstate.filtersPerRegion = DigraphHelper.getPolicies(regionDigraph);
    return dstate;
}
Also used : RegionDigraph(org.eclipse.equinox.region.RegionDigraph) FrameworkInfo(org.apache.karaf.features.internal.service.BundleInstallSupport.FrameworkInfo) Feature(org.apache.karaf.features.Feature)

Example 5 with Feature

use of org.apache.karaf.features.Feature in project karaf by apache.

the class FeaturesServiceImpl method createFeatureCacheInternal.

private Map<String, Map<String, Feature>> createFeatureCacheInternal() throws Exception {
    Map<String, Map<String, Feature>> map = new HashMap<>();
    Repository[] repos = repositories.listRepositories();
    for (Repository repo : repos) {
        for (Feature f : repo.getFeatures()) {
            if (map.get(f.getName()) == null) {
                Map<String, Feature> versionMap = new HashMap<>();
                versionMap.put(f.getVersion(), f);
                map.put(f.getName(), versionMap);
            } else {
                map.get(f.getName()).put(f.getVersion(), f);
            }
        }
    }
    return map;
}
Also used : Repository(org.apache.karaf.features.Repository) HashMap(java.util.HashMap) StateStorage.toStringStringSetMap(org.apache.karaf.features.internal.service.StateStorage.toStringStringSetMap) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Feature(org.apache.karaf.features.Feature)

Aggregations

Feature (org.apache.karaf.features.Feature)127 Test (org.junit.Test)56 FeaturesService (org.apache.karaf.features.FeaturesService)43 HashSet (java.util.HashSet)41 Repository (org.apache.karaf.features.Repository)39 ApplicationService (org.codice.ddf.admin.application.service.ApplicationService)18 Bundle (org.osgi.framework.Bundle)18 HashMap (java.util.HashMap)17 ArrayList (java.util.ArrayList)16 Map (java.util.Map)16 Dependency (org.apache.karaf.features.Dependency)15 BundleInfo (org.apache.karaf.features.BundleInfo)14 Application (org.codice.ddf.admin.application.service.Application)14 URI (java.net.URI)13 IOException (java.io.IOException)12 VersionRange (org.apache.felix.utils.version.VersionRange)12 LinkedHashSet (java.util.LinkedHashSet)11 Version (org.osgi.framework.Version)11 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)10 EnumSet (java.util.EnumSet)9