You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/07/01 16:01:43 UTC
svn commit: r790174 -
/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
Author: rickhall
Date: Wed Jul 1 14:01:43 2009
New Revision: 790174
URL: http://svn.apache.org/viewvc?rev=790174&view=rev
Log:
Improved system bundle update. (FELIX-33)
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=790174&r1=790173&r2=790174&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java Wed Jul 1 14:01:43 2009
@@ -835,27 +835,54 @@
{
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();
+ // First acquire the system bundle lock to verify the state.
+ acquireBundleLock(Felix.this, Bundle.STARTING | Bundle.ACTIVE);
+ // Record the state and stop the system bundle.
+ int oldState = Felix.this.getState();
+ try
+ {
+ stop();
+ }
+ catch (BundleException ex)
+ {
+ m_logger.log(Logger.LOG_WARNING, "Exception stopping framework.", ex);
+ }
+ finally
+ {
+ releaseBundleLock(Felix.this);
+ }
+
+ // Make sure the framework is stopped.
+ try
+ {
+ waitForStop(0);
+ }
+ catch (InterruptedException ex)
+ {
+ m_logger.log(Logger.LOG_WARNING, "Did not wait for framework to stop.", ex);
+ }
+
+ // Depending on the old state, restart the framework.
+ try
+ {
+ switch (oldState)
+ {
+ case Bundle.STARTING:
+ init();
+ break;
+ case Bundle.ACTIVE:
+ start();
+ break;
+ }
+ }
+ catch (BundleException ex)
+ {
+ m_logger.log(Logger.LOG_WARNING, "Exception restarting framework.", ex);
+ }
}
- catch (BundleException ex)
+ catch (Exception ex)
{
- m_logger.log(Logger.LOG_WARNING, "Exception restarting framework.", ex);
+ m_logger.log(Logger.LOG_WARNING, "Cannot update an inactive framework.");
}
}
}).start();