Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBJ Hargrave2006-04-08 04:17:10 +0000
committerBJ Hargrave2006-04-08 04:17:10 +0000
commit3855c494ce8f2ca3abdfb880ca0d839352f54f2d (patch)
tree768adcadf6f93db54a6678a4d700aeaeace76435
parent67ed0973190a721f17bfba4984f465b7f44afe54 (diff)
downloadrt.equinox.bundles-3855c494ce8f2ca3abdfb880ca0d839352f54f2d.tar.gz
rt.equinox.bundles-3855c494ce8f2ca3abdfb880ca0d839352f54f2d.tar.xz
rt.equinox.bundles-3855c494ce8f2ca3abdfb880ca0d839352f54f2d.zip
Fix for Bug 129055. Make sure factory instance is created before registering the service to avoid potential race from someone obtaining the instance via the service before it was created for the factory
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InstanceProcess.java26
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentFactoryImpl.java13
2 files changed, 19 insertions, 20 deletions
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InstanceProcess.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InstanceProcess.java
index 836e8a967..21459cfdd 100644
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InstanceProcess.java
+++ b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InstanceProcess.java
@@ -106,14 +106,6 @@ public class InstanceProcess implements ConfigurationListener {
if (DEBUG)
System.out.println("InstanceProcess: buildInstances: component name = " + cd.getName());
- // if component is immediate - create instance immediately
- if (cd.isImmediate()) {
- try {
- buildDispose.buildComponentConfigInstance(null, cdp);
- } catch (ComponentException e) {
- Log.log(1, "[SCR] Error attempting to build Component.", e);
- }
- }
// ComponentFactory
if (cdp.isComponentFactory()) {
@@ -143,9 +135,21 @@ public class InstanceProcess implements ConfigurationListener {
// for the Service Component on behalf of the Service
// Component.
cdp.setServiceRegistration(cd.getBundleContext().registerService(ComponentFactory.class.getName(), new ComponentFactoryImpl(cdp, main), cdp.getProperties()));
-
- // if ServiceFactory or Service
- } else if (cd.getService() != null) {
+ continue; // break so we do not create an instance
+ }
+
+ // if component is immediate or a factory instance - create instance
+ // if it is a factory instance, we need to create it before we register its service
+ if (cd.isImmediate() || (cd.getFactory() != null)) {
+ try {
+ buildDispose.buildComponentConfigInstance(null, cdp);
+ } catch (ComponentException e) {
+ Log.log(1, "[SCR] Error attempting to build Component.", e);
+ }
+ }
+
+ // if Service
+ if (cd.getService() != null) {
RegisterComponentService.registerService(this, cdp);
}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentFactoryImpl.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentFactoryImpl.java
index 198ee7ec3..62f54e080 100644
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentFactoryImpl.java
+++ b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentFactoryImpl.java
@@ -21,7 +21,7 @@ import org.osgi.service.component.*;
* register a ComponentFactory service to allow new component configurations
* to be created and activated.
*
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.1 $
*/
public class ComponentFactoryImpl implements ComponentFactory {
@@ -79,13 +79,8 @@ public class ComponentFactoryImpl implements ComponentFactory {
// if it has one)
main.resolver.instanceProcess.registerComponentConfigs(Collections.singletonList(newCDP));
- // get instance of new cdp to return
-
- if (newCDP.getComponentDescription().isImmediate()) {
- // if cdp is immediate then instanceProcess created one
- return (ComponentInstance) newCDP.getInstances().get(0);
- }
-
- return main.resolver.instanceProcess.buildDispose.buildComponentConfigInstance(null, newCDP);
+ // Instance process will have created an instance
+
+ return (ComponentInstance) newCDP.getInstances().get(0);
}
}

Back to the top