Implement system bundle update. (FELIX-33)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@789942 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index c18f3bf..867600c 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -819,8 +819,46 @@
AdminPermission.EXECUTE));
}
- // TODO: FRAMEWORK - This is supposed to stop and then restart the framework.
- throw new BundleException("System bundle update not implemented yet.");
+ // Spec says to close input stream first.
+ try
+ {
+ if (is != null) is.close();
+ }
+ catch (IOException ex)
+ {
+ m_logger.log(Logger.LOG_WARNING, "Exception closing input stream.", ex);
+ }
+
+ // Then to stop and restart the framework on a separate thread.
+ new Thread(new Runnable() {
+ public void run()
+ {
+ try
+ {
+ stop();
+ }
+ catch (BundleException ex)
+ {
+ m_logger.log(Logger.LOG_WARNING, "Exception stopping framework.", ex);
+ }
+ try
+ {
+ waitForStop(0);
+ }
+ catch (InterruptedException ex)
+ {
+ m_logger.log(Logger.LOG_WARNING, "Did not wait for framework to stop.", ex);
+ }
+ try
+ {
+ start();
+ }
+ catch (BundleException ex)
+ {
+ m_logger.log(Logger.LOG_WARNING, "Exception restarting framework.", ex);
+ }
+ }
+ }).start();
}
public String toString()