FELIX-1689: improve the features deployer to leverage batch installation too
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@825092 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java b/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java
index 7de16a0..dfefe60 100644
--- a/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java
+++ b/karaf/deployer/features/src/main/java/org/apache/felix/karaf/deployer/features/FeatureDeploymentListener.java
@@ -25,7 +25,12 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumSet;
import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
@@ -168,12 +173,11 @@
featuresService.addRepository(url.toURI());
for (Repository repo : featuresService.listRepositories()) {
if (repo.getURI().equals(url.toURI())) {
- for (Feature f : repo.getFeatures()) {
- try {
- featuresService.installFeature(f.getName(), f.getVersion());
- } catch (Exception e) {
- LOGGER.error("Unable to install feature: " + f.getName(), e);
- }
+ Set<Feature> features = new HashSet<Feature>(Arrays.asList(repo.getFeatures()));
+ try {
+ featuresService.installFeatures(features, EnumSet.noneOf(FeaturesService.Option.class));
+ } catch (Exception e) {
+ LOGGER.error("Unable to install features", e);
}
}
}
diff --git a/karaf/deployer/features/src/main/resources/OSGI-INF/blueprint/features-deployer.xml b/karaf/deployer/features/src/main/resources/OSGI-INF/blueprint/features-deployer.xml
index ab1b68a..12ba2d9 100644
--- a/karaf/deployer/features/src/main/resources/OSGI-INF/blueprint/features-deployer.xml
+++ b/karaf/deployer/features/src/main/resources/OSGI-INF/blueprint/features-deployer.xml
@@ -18,7 +18,6 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://geronimo.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
default-activation="lazy">
<service ref="featureDeploymentListener" auto-export="interfaces"/>
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeaturesService.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeaturesService.java
index 461dc73..6432541 100644
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeaturesService.java
+++ b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/FeaturesService.java
@@ -18,6 +18,7 @@
import java.net.URI;
import java.util.EnumSet;
+import java.util.Set;
/**
* The service managing features repositories.
@@ -42,6 +43,10 @@
void installFeature(String name, String version, EnumSet<Option> options) throws Exception;
+ void installFeature(Feature f, EnumSet<Option> options) throws Exception;
+
+ void installFeatures(Set<Feature> features, EnumSet<Option> options) throws Exception;
+
void uninstallFeature(String name) throws Exception;
void uninstallFeature(String name, String version) throws Exception;