Modify Start Level service to synchronously persist bundle start level
changes. (FELIX-1551)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@810205 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 14ff7e5..1cd0f28 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -1221,15 +1221,16 @@
{
if (startLevel >= 1)
{
- impl.setStartLevel(startLevel);
+ // NOTE: The start level was persistently recorded inside
+ // the start level impl because the spec requires it to be
+ // done synchronously.
try
{
// Start the bundle if necessary.
if (((impl.getPersistentState() == Bundle.ACTIVE)
|| (impl.getPersistentState() == Bundle.STARTING))
- && (impl.getStartLevel(getInitialBundleStartLevel())
- <= getActiveStartLevel()))
+ && (startLevel <= getActiveStartLevel()))
{
// TODO: LAZY - Not sure if this is the best way...
int options = Bundle.START_TRANSIENT;
@@ -1241,8 +1242,7 @@
// Stop the bundle if necessary.
else if (((impl.getState() == Bundle.ACTIVE)
|| (impl.getState() == Bundle.STARTING))
- && (impl.getStartLevel(getInitialBundleStartLevel())
- > getActiveStartLevel()))
+ && (startLevel > getActiveStartLevel()))
{
stopBundle(impl, false);
}
diff --git a/framework/src/main/java/org/apache/felix/framework/StartLevelImpl.java b/framework/src/main/java/org/apache/felix/framework/StartLevelImpl.java
index 4d2d194..050f67e 100644
--- a/framework/src/main/java/org/apache/felix/framework/StartLevelImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/StartLevelImpl.java
@@ -172,6 +172,9 @@
}
synchronized (m_requestList)
{
+ // Synchronously persists the start level.
+ ((BundleImpl) bundle).setStartLevel(startlevel);
+ // Asynchronously process the start level change.
m_requestList.add(new Object[] { bundle, new Integer(startlevel) });
m_requestList.notifyAll();
}