geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r781861 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container: BlueprintContainerImpl.java ServiceRecipe.java
Date Thu, 04 Jun 2009 22:31:13 GMT
Author: gnodet
Date: Thu Jun  4 22:31:13 2009
New Revision: 781861

URL: http://svn.apache.org/viewvc?rev=781861&view=rev
Log:
Fix some synchronization problems with the ServiceRecipe register / unregister methods

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java?rev=781861&r1=781860&r2=781861&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
Thu Jun  4 22:31:13 2009
@@ -446,20 +446,22 @@
             for (String name : dependencies.keySet()) {
                 ComponentMetadata metadata = componentDefinitionRegistry.getComponentDefinition(name);
                 if (metadata instanceof ServiceMetadata) {
-                    boolean satisfied = true;
-                    for (SatisfiableRecipe recipe : dependencies.get(name)) {
-                        if (!recipe.isSatisfied()) {
-                            satisfied = false;
-                            break;
-                        }
-                    }
                     ServiceRecipe reg = (ServiceRecipe) instantiator.getRepository().getRecipe(name);
-                    if (satisfied && !reg.isRegistered()) {
-                        LOGGER.debug("Registering service {} due to satisfied references",
name);
-                        reg.register();
-                    } else if (!satisfied && reg.isRegistered()) {
-                        LOGGER.debug("Unregistering service {} due to unsatisfied references",
name);
-                        reg.unregister();
+                    synchronized (reg) {
+                        boolean satisfied = true;
+                        for (SatisfiableRecipe recipe : dependencies.get(name)) {
+                            if (!recipe.isSatisfied()) {
+                                satisfied = false;
+                                break;
+                            }
+                        }
+                        if (satisfied && !reg.isRegistered()) {
+                            LOGGER.debug("Registering service {} due to satisfied references",
name);
+                            reg.register();
+                        } else if (!satisfied && reg.isRegistered()) {
+                            LOGGER.debug("Unregistering service {} due to unsatisfied references",
name);
+                            reg.unregister();
+                        }
                     }
                 }
             }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java?rev=781861&r1=781860&r2=781861&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
Thu Jun  4 22:31:13 2009
@@ -148,8 +148,8 @@
         registration = blueprintContainer.getBundleContext().registerService(classArray,
new TriggerServiceFactory(), props);
         registrationProperties = props;
 
-        LOGGER.debug("Trigger service {} registered with interfaces {} and properties {}",
-                     new Object[] { this, classes, props });
+        LOGGER.debug("Service {} registered with interfaces {} and properties {}",
+                     new Object[] { name, classes, props });
     }
 
     public synchronized boolean isRegistered() {
@@ -176,16 +176,19 @@
 
     public synchronized void unregister() {
         if (registration != null) {
+            // This method needs to allow reentrance, so if we need to make sure the registration
is
+            // set to null before actually unregistering the service
+            ServiceRegistration reg = registration;
+            registration = null;
             // TODO: shouldn't listeners be called before unregistering the service?
-            registration.unregister();
+            reg.unregister();
             if (listeners != null) {
                 LOGGER.debug("Calling listeners for service unregistration");
                 for (ServiceListener listener : listeners) {
                     listener.unregister(getService(), registrationProperties);
                 }
             }
-            LOGGER.debug("Service {} unregistered", service);
-            registration = null;
+            LOGGER.debug("Service {} unregistered", name);
         }
     }
     



Mime
View raw message