geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r790872 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container: AbstractServiceReferenceRecipe.java BlueprintContainerImpl.java ReferenceListRecipe.java ReferenceRecipe.java
Date Fri, 03 Jul 2009 11:50:07 GMT
Author: gnodet
Date: Fri Jul  3 11:50:07 2009
New Revision: 790872

URL: http://svn.apache.org/viewvc?rev=790872&view=rev
Log:
Fix references shutdown

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
    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/ReferenceListRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java?rev=790872&r1=790871&r2=790872&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
Fri Jul  3 11:50:07 2009
@@ -143,6 +143,7 @@
         if (started.compareAndSet(true, false)) {
             synchronized (references) {
                 blueprintContainer.getBundleContext().removeServiceListener(this);
+                doStop();
                 for (Iterator<ServiceReference> it = references.iterator(); it.hasNext();)
{
                     ServiceReference ref = it.next();
                     it.remove();
@@ -153,6 +154,9 @@
         }
     }
 
+    protected void doStop() {
+    }
+
     protected boolean isStarted() {
         return started.get();
     }

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=790872&r1=790871&r2=790872&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
Fri Jul  3 11:50:07 2009
@@ -430,14 +430,26 @@
     private void untrackServiceReferences() {
         Map<String, List<SatisfiableRecipe>> dependencies = getSatisfiableDependenciesMap();
         if (dependencies != null) {
-            Set<String> satisfiables = new HashSet<String>();
+            Set<String> stopped = new HashSet<String>();
             for (List<SatisfiableRecipe> recipes : dependencies.values()) {
                 for (SatisfiableRecipe satisfiable : recipes) {
-                    if (satisfiables.add(satisfiable.getName())) {
-                        satisfiable.stop();
+                    untrackServiceReference(satisfiable, stopped, dependencies);
+                }
+            }
+        }
+    }
+
+    private void untrackServiceReference(SatisfiableRecipe recipe, Set<String> stopped,
Map<String, List<SatisfiableRecipe>> dependencies) {
+        if (stopped.add(recipe.getName())) {
+            for (Map.Entry<String, List<SatisfiableRecipe>> entry : dependencies.entrySet())
{
+                if (entry.getValue().contains(recipe)) {
+                    Recipe r = getRepository().getRecipe(entry.getKey());
+                    if (r instanceof SatisfiableRecipe) {
+                        untrackServiceReference((SatisfiableRecipe) r, stopped, dependencies);
                     }
                 }
             }
+            recipe.stop();
         }
     }
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java?rev=790872&r1=790871&r2=790872&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java
Fri Jul  3 11:50:07 2009
@@ -90,16 +90,6 @@
         }
     }
 
-    public void stop() {
-        super.stop();
-        if (storage != null) {
-            List<ServiceDispatcher> dispatchers = new ArrayList<ServiceDispatcher>(storage);
-            for (ServiceDispatcher dispatcher : dispatchers) {
-                untrack(dispatcher.reference);
-            }
-        }
-    }
-
     protected void retrack() {
         List<ServiceReference> refs = getServiceReferences();
         if (refs != null) {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java?rev=790872&r1=790871&r2=790872&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java
Fri Jul  3 11:50:07 2009
@@ -94,9 +94,7 @@
         }
     }
 
-    @Override
-    public void stop() {
-        super.stop();
+    protected void doStop() {
         synchronized (monitor) {
             unbind();
             monitor.notifyAll();
@@ -133,6 +131,7 @@
     }
 
     private void bind(ServiceReference ref) {
+        LOGGER.debug("Binding reference {} to {}", getName(), ref);
         synchronized (monitor) {
             if (trackedServiceReference != null) {
                 blueprintContainer.getBundleContext().ungetService(trackedServiceReference);
@@ -150,6 +149,7 @@
     }
 
     private void unbind() {
+        LOGGER.debug("Unbinding reference {}", getName());
         synchronized (monitor) {
             if (trackedServiceReference != null) {
                 if (listeners != null) {



Mime
View raw message