Package org.apache.karaf.features

Examples of org.apache.karaf.features.Feature


    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);
        if (verbose) {
            System.out.println("Uninstalling feature " + feature.getName() + " " + feature.getVersion());
        }
        // 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);
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 (FeatureImpl.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

                                    featureVersion = FeatureImpl.DEFAULT_VERSION;
                                }

                                try {
                                    // try to grab specific feature version
                                    Feature feature = getFeature(featureName, featureVersion);
                                    if (feature != null) {
                                        features.add(feature);
                                    } else {
                                        LOGGER.error("Error installing boot feature " + f + ": feature not found");
                                    }
                                } catch (Exception e) {
                                    LOGGER.error("Error installing boot feature " + f, e);
                                }
                            }
                        }
                        try {
                            installFeatures(features, EnumSet.of(Option.NoCleanIfFailure, Option.ContinueBatchOnFailure));
                        } catch (Exception e) {
                            LOGGER.error("Error installing boot features", e);
                        }
                        bootFeaturesInstalled = true;
                        saveState();
                    }
                }.start();
            } else {
                // splitting the features
                String[] list = boot.split(",");
                Set<Feature> features = new LinkedHashSet<Feature>();
                for (String f : list) {
                    f = f.trim();
                    if (f.length() > 0) {
                        String featureVersion = null;

                        // first we split the parts of the feature string to gain access to the version info
                        // if specified
                        String[] parts = f.split(";");
                        String featureName = parts[0];
                        for (String part : parts) {
                            // if the part starts with "version=" it contains the version info
                            if (part.startsWith(FeatureImpl.VERSION_PREFIX)) {
                                featureVersion = part.substring(FeatureImpl.VERSION_PREFIX.length());
                            }
                        }

                        if (featureVersion == null) {
                            // no version specified - use default version
                            featureVersion = FeatureImpl.DEFAULT_VERSION;
                        }

                        try {
                            // try to grab specific feature version
                            Feature feature = getFeature(featureName, featureVersion);
                            if (feature != null) {
                                features.add(feature);
                            } else {
                                LOGGER.error("Error installing boot feature " + f + ": feature not found");
                            }
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

            Set<Group> groups = groupManager.listLocalGroups();

            if (groups != null && !groups.isEmpty()) {
                for (Group group : groups) {

                    Feature feature = event.getFeature();
                    String name = feature.getName();
                    String version = feature.getVersion();

                    if (isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.OUTBOUND)) {
                        FeatureEvent.EventType type = event.getType();

                        // update the features in the cluster group
View Full Code Here

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

    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

            System.out.println("Installing feature " + feature.getName() + " " + feature.getVersion());
        }
        for (Feature dependency : feature.getDependencies()) {
            VersionRange range = FeatureImpl.DEFAULT_VERSION.equals(dependency.getVersion())
                        ? VersionRange.ANY_VERSION : new VersionRange(dependency.getVersion(), true, true);
            Feature fi = null;
            for (Feature f : installed.keySet()) {
                if (f.getName().equals(dependency.getName())) {
                    Version v = VersionTable.getVersion(f.getVersion());
                    if (range.contains(v)) {
                        if (fi == null || VersionTable.getVersion(fi.getVersion()).compareTo(v) < 0) {
                            fi = f;
                        }
                    }
                }
            }
            if (fi == null) {
                Map<String, Feature> avail = getFeatures().get(dependency.getName());
                if (avail != null) {
                    for (Feature f : avail.values()) {
                        Version v = VersionTable.getVersion(f.getVersion());
                        if (range.contains(v)) {
                            if (fi == null || VersionTable.getVersion(fi.getVersion()).compareTo(v) < 0) {
                                fi = f;
                            }
                        }
                    }
                }
View Full Code Here

        }
        uninstallFeature(name, versions.get(0));
    }
   
    public void uninstallFeature(String name, String version) 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");
        }
        // Grab all the bundles installed by this feature
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 (FeatureImpl.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

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.