org.fusesource.fabric.commands.support.BundleLocationCompleter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fabric-commands Show documentation
Show all versions of fabric-commands Show documentation
Fuse Fabric :: Karaf Commands
The newest version!
package org.fusesource.fabric.commands.support;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.apache.karaf.features.BundleInfo;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeaturesService;
import org.apache.karaf.shell.console.Completer;
import org.apache.karaf.shell.console.completer.StringsCompleter;
public class BundleLocationCompleter implements Completer {
private FeaturesService featuresService;
@Override
public int complete(String buffer, int cursor, List candidates) {
StringsCompleter delegate = new StringsCompleter();
try {
delegate.getStrings().addAll(getFeatureLocations());
} catch (Exception ex) {
//ignore
}
return delegate.complete(buffer, cursor, candidates);
}
private Set getFeatureLocations() throws Exception {
Set bundleLocations = new LinkedHashSet();
for (Feature feature : featuresService.listFeatures()) {
try {
for (BundleInfo info : feature.getBundles()) {
bundleLocations.add(info.getLocation());
}
} catch (Exception e) {
//Ignore
}
}
return bundleLocations;
}
public FeaturesService getFeaturesService() {
return featuresService;
}
public void setFeaturesService(FeaturesService featuresService) {
this.featuresService = featuresService;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy