FELIX-1576: The features service should do a PackageAdmin.refresh() after uninstalling a feature
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@813062 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
index 421de12..ab25f7b 100644
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
+++ b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
@@ -54,6 +54,7 @@
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
import org.osgi.service.prefs.PreferencesService;
+import org.osgi.service.packageadmin.PackageAdmin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,6 +73,7 @@
private BundleContext bundleContext;
private ConfigurationAdmin configAdmin;
+ private PackageAdmin packageAdmin;
private PreferencesService preferences;
private Set<URI> uris;
private Map<URI, RepositoryImpl> repositories = new HashMap<URI, RepositoryImpl>();
@@ -97,6 +99,14 @@
this.configAdmin = configAdmin;
}
+ public PackageAdmin getPackageAdmin() {
+ return packageAdmin;
+ }
+
+ public void setPackageAdmin(PackageAdmin packageAdmin) {
+ this.packageAdmin = packageAdmin;
+ }
+
public PreferencesService getPreferences() {
return preferences;
}
@@ -219,11 +229,11 @@
b.start();
}
}
-
callListeners(new FeatureEvent(f, FeatureEvent.EventType.FeatureInstalled, false));
installed.put(f, bundles);
saveState();
}
+
protected Bundle installBundleIfNeeded(String bundleLocation) throws IOException, BundleException {
LOGGER.debug("Checking " + bundleLocation);
InputStream is;
@@ -306,6 +316,9 @@
b.uninstall();
}
}
+ if (getPackageAdmin() != null) {
+ getPackageAdmin().refreshPackages(null);
+ }
callListeners(new FeatureEvent(feature, FeatureEvent.EventType.FeatureInstalled, false));
saveState();
}
diff --git a/karaf/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml b/karaf/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
index 0d7e2c4..4e601df 100644
--- a/karaf/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
+++ b/karaf/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
@@ -34,6 +34,7 @@
<property name="urls" value="$[featuresRepositories]" />
<property name="boot" value="$[featuresBoot]" />
<property name="configAdmin" ref="configAdmin" />
+ <property name="packageAdmin" ref="packageAdmin" />
<property name="preferences" ref="preferences" />
<property name="bundleContext" ref="blueprintBundleContext" />
</bean>
@@ -48,6 +49,8 @@
<reference id="preferences" interface="org.osgi.service.prefs.PreferencesService" availability="optional"/>
+ <reference id="packageAdmin" interface="org.osgi.service.packageadmin.PackageAdmin" />
+
<service ref="featuresService" interface="org.apache.felix.karaf.features.FeaturesService" />
</blueprint>