Package org.apache.karaf.features

Examples of org.apache.karaf.features.Feature


      ArrayList<Set<Feature>> result = new ArrayList<Set<Feature>>();
      for (Set<String> features : stagedFeatures) {
          HashSet<Feature> featureSet = new HashSet<Feature>();
            for (String featureName : features) {
                try {
                    Feature feature = getFeature(featureName);
                    if (feature == null) {
                        LOGGER.error("Error Boot feature " + featureName + " not found");
                    } else {
                        featureSet.add(feature);
                    }
View Full Code Here


    }
   
    @Test
    public void testDefaultBootFeatures() throws Exception  {
        FeaturesServiceImpl impl = EasyMock.createMock(FeaturesServiceImpl.class);
        Feature configFeature = feature("config", "1.0.0");
        Feature standardFeature = feature("standard", "1.0.0");
        Feature regionFeature = feature("region", "1.0.0");
        expect(impl.listInstalledFeatures()).andStubReturn(new Feature[]{});
        expect(impl.getFeature("config", "0.0.0")).andReturn(configFeature);
        expect(impl.getFeature("standard", "0.0.0")).andReturn(standardFeature);
        expect(impl.getFeature("region", "0.0.0")).andReturn(regionFeature);
View Full Code Here

    @Test
    public void testStartDoesNotFailWithNonExistentVersion() throws Exception  {
        FeaturesServiceImpl impl = EasyMock.createMock(FeaturesServiceImpl.class);
        expect(impl.listInstalledFeatures()).andReturn(new Feature[]{});
        EasyMock.expectLastCall();
        Feature sshFeature = feature("ssh", "1.0.0");
        expect(impl.getFeature("ssh", "1.0.0")).andReturn(sshFeature);
        expect(impl.getFeature("transaction", "1.2")).andReturn(null);
       
        // Only the ssh feature should get installed
        impl.installFeatures(setOf(sshFeature), EnumSet.of(Option.NoCleanIfFailure, Option.ContinueBatchOnFailure));
View Full Code Here

    }
   
    @Test
    public void testStagedBoot() throws Exception  {
        FeaturesServiceImpl impl = EasyMock.createStrictMock(FeaturesServiceImpl.class);
        Feature sshFeature = feature("ssh", "1.0.0");
        Feature transactionFeature = feature("transaction", "2.0.0");
        expect(impl.listInstalledFeatures()).andStubReturn(new Feature[]{});
        expect(impl.getFeature("transaction", "0.0.0")).andStubReturn(transactionFeature);
        expect(impl.getFeature("ssh", "0.0.0")).andStubReturn(sshFeature);

        impl.installFeatures(setOf(transactionFeature), EnumSet.of(Option.NoCleanIfFailure, Option.ContinueBatchOnFailure));
View Full Code Here

     * @param version the version of the feature.
     * @param options the installation options.
     * @throws Exception in case of install failure.
     */
    public void installFeature(String name, String version, EnumSet<Option> options) throws Exception {
        Feature f = getFeature(name, version);
        if (f == null) {
            throw new Exception("No feature named '" + name
                + "' with version '" + version + "' available");
        }
        installFeature(f, options);
View Full Code Here

        }
    }

    private void installFeatureDependency(Dependency dependency, InstallationState state, boolean verbose)
            throws Exception {
        Feature fi = getFeatureForDependency(dependency);
        if (fi == null) {
            throw new Exception("No feature named '" + dependency.getName()
                    + "' with version '" + dependency.getVersion() + "' available");
        }
        if (state.features.containsKey(fi)) {
            LOGGER.debug("Feature {} with version {} is already being installed", fi.getName(), fi.getVersion());
        } else {
            doInstallFeature(state, fi, verbose);
        }
    }
View Full Code Here

    public void uninstallFeature(String name, String version) throws Exception {
        uninstallFeature(name, version, EnumSet.noneOf(Option.class));
    }

    public void uninstallFeature(String name, String version, EnumSet<Option> options) throws Exception {
      Feature feature = getFeature(name, version);
        if (feature == null || !installed.containsKey(feature)) {
            throw new Exception("Feature named '" + name + "' with version '" + version + "' is not installed");
        }
        boolean verbose = options != null && options.contains(Option.Verbose);
        boolean refresh = options == null || !options.contains(Option.NoAutoRefreshBundles);
        String msg = "Uninstalling feature " + feature.getName() + " " + feature.getVersion();
        LOGGER.info(msg);
        if (verbose) {
            System.out.println(msg);
        }
        // Grab all the bundles installed by this feature
        // and remove all those who will still be in use.
        // This gives this list of bundles to uninstall.
        Set<Long> bundles = installed.remove(feature);

        //Also remove bundles installed as conditionals
        for (Conditional conditional : feature.getConditional()) {
            Feature conditionalFeature = conditional.asFeature(feature.getName(),feature.getVersion());
            if (installed.containsKey(conditionalFeature)) {
                msg = "Uninstalling feature " + conditionalFeature.getName() + " " + conditionalFeature.getVersion();
                LOGGER.info(msg);
                if (verbose) {
                    System.out.println(msg);
                }
              bundles.addAll(installed.remove(conditionalFeature));
            } else {
              LOGGER.info("Conditional feature {}, hasn't been installed!");
            }
        }
        for (Feature f : new HashSet<Feature>(installed.keySet())) {
            f = getFeature(f.getName(), f.getVersion());
            if (f != null) {
                for (Conditional conditional : f.getConditional()) {
                    boolean satisfied = true;
                    for (Dependency dep : conditional.getCondition()) {
                        Feature df = getFeatureForDependency(dep);
                        satisfied &= installed.containsKey(df);
                    }
                    if (!satisfied) {
                        Feature conditionalFeature = conditional.asFeature(f.getName(), f.getVersion());
                        if (installed.containsKey(conditionalFeature)) {
                            msg = "Uninstalling feature " + conditionalFeature.getName() + " " + conditionalFeature.getVersion();
                            LOGGER.info(msg);
                            if (verbose) {
                                System.out.println(msg);
                            }
                            bundles.addAll(installed.remove(conditionalFeature));
View Full Code Here

        }
        Map<String, Feature> versions = getFeatures().get(name);
        if (versions == null || versions.isEmpty()) {
            return null;
        } else {
            Feature feature = versions.get(version);
            if (feature == null) {
                if (org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION.equals(version)) {
                    Version latest = new Version(cleanupVersion(version));
                    for (String available : versions.keySet()) {
                        Version availableVersion = new Version(cleanupVersion(available));
View Full Code Here

        return l;
    }

    protected void saveMap(Properties props, String prefix, Map<Feature, Set<Long>> map) {
        for (Map.Entry<Feature, Set<Long>> entry : map.entrySet()) {
            Feature key = entry.getKey();
            String val = createValue(entry.getValue());
            props.put(prefix + key.toString(), val);
        }
    }
View Full Code Here

    private String getFeaturesContainingBundleList(Bundle bundle) throws Exception {
        Set<Feature> features = getFeaturesContainingBundle(bundle);
        StringBuilder buffer = new StringBuilder();
        Iterator<Feature> iter = features.iterator();
        while (iter.hasNext()) {
            Feature feature= iter.next();
            buffer.append(feature.getId());
            if (iter.hasNext()) {
                buffer.append(", ");
            }
        }
        return buffer.toString();
View Full Code Here

TOP

Related Classes of org.apache.karaf.features.Feature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.