Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsboshev2008-09-26 14:16:42 +0000
committersboshev2008-09-26 14:16:42 +0000
commit3c42f6cbd8e58663beab110c5e8fbccbaefdaa91 (patch)
tree9964cef9f350bb2f93ae0d57e5809e0261edb0fa /bundles
parent306048aac05147ab402048fec5aa6518c3c812b3 (diff)
downloadrt.equinox.bundles-3c42f6cbd8e58663beab110c5e8fbccbaefdaa91.tar.gz
rt.equinox.bundles-3c42f6cbd8e58663beab110c5e8fbccbaefdaa91.tar.xz
rt.equinox.bundles-3c42f6cbd8e58663beab110c5e8fbccbaefdaa91.zip
Bug 246075. [DS] SCR should process components of started bundles synchronously
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java38
1 files changed, 37 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java
index 500f0b473..8d5488cb7 100644
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java
+++ b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java
@@ -55,6 +55,7 @@ public class SCRManager implements ServiceListener, SynchronousBundleListener, C
public final int DISABLE_COMPONENTS = 2;
private ComponentStorage storage;
+ boolean doSynchronousComponentResolving = true;
/**
* Constructs the SCRManager.
@@ -62,6 +63,11 @@ public class SCRManager implements ServiceListener, SynchronousBundleListener, C
public SCRManager(BundleContext bc, Log log) {
this.bc = bc;
SCRManager.log = log;
+ String doSynchronousComponentResolvingValue = System.getProperty("equinox.ds.synchronous_build");
+ if (doSynchronousComponentResolvingValue != null) {
+ //def value is true
+ doSynchronousComponentResolving = !doSynchronousComponentResolvingValue.equalsIgnoreCase("false");
+ }
security = Log.security();
@@ -175,6 +181,7 @@ public class SCRManager implements ServiceListener, SynchronousBundleListener, C
* Action for this item
* @param o
* Object for this item
+ * @param security specifies whether to use security privileged call
*/
public void enqueueWork(WorkPerformer d, int a, Object o, boolean security) {
addEvent(new QueuedJob(d, a, o), security);
@@ -524,9 +531,33 @@ public class SCRManager implements ServiceListener, SynchronousBundleListener, C
}
}
// store the components in the cache
- bundleToServiceComponents.put(bundle, components);
+ bundleToServiceComponents.put(bundle, components.clone());
// this will also resolve the component dependencies!
enqueueWork(this, ENABLE_COMPONENTS, components, false);
+ synchronized (components) {
+ long startTime = System.currentTimeMillis();
+ try {
+ do {
+ components.wait(1000);
+ } while (!components.isEmpty() && (System.currentTimeMillis() - startTime < WorkThread.BLOCK_TIMEOUT));
+ if (System.currentTimeMillis() - startTime >= WorkThread.BLOCK_TIMEOUT) {
+ Activator.log.warning("[SCR] Enabling of components of bundle " + getBundleName(bundle) + " did not complete in " + WorkThread.BLOCK_TIMEOUT + "ms", null);
+ }
+ } catch (InterruptedException e) {
+ //do nothing
+ }
+ }
+ }
+ }
+
+ private String getBundleName(Bundle b) {
+ String res = null;
+ if (b.getSymbolicName() != null) {
+ return b.getSymbolicName();
+ } else if ((res = (String) b.getHeaders().get(Constants.BUNDLE_NAME)) != null) {
+ return res;
+ } else {
+ return b.getLocation();
}
}
@@ -657,6 +688,11 @@ public class SCRManager implements ServiceListener, SynchronousBundleListener, C
public void performWork(int workAction, Object workObject) {
if (workAction == ENABLE_COMPONENTS) {
resolver.enableComponents((Vector) workObject);
+ //notify that the component enabling has finished
+ synchronized (workObject) {
+ ((Vector) workObject).clear();
+ workObject.notify();
+ }
} else if (workAction == DISABLE_COMPONENTS) {
resolver.disableComponents((Vector) workObject);
}

Back to the top