geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r806359 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container: AbstractServiceReferenceRecipe.java ReferenceListRecipe.java ReferenceRecipe.java
Date Thu, 20 Aug 2009 21:14:09 GMT
Author: gawor
Date: Thu Aug 20 21:14:08 2009
New Revision: 806359

URL: http://svn.apache.org/viewvc?rev=806359&view=rev
Log:
call unbind with null service object if service reference is unsatisfied during activation

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/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=806359&r1=806358&r2=806359&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
Thu Aug 20 21:14:08 2009
@@ -82,7 +82,6 @@
     protected final String filter;
     /** The list of listeners for this reference.  This list will be lazy created */
     protected List<Listener> listeners;
-    protected boolean listenersCreated = true;
 
     private final List<ServiceReference> references = new ArrayList<ServiceReference>();
     private final AtomicBoolean started = new AtomicBoolean();
@@ -333,6 +332,34 @@
 
     protected abstract void retrack();
 
+    protected void updateListeners() {  
+        if (references.isEmpty()) {
+            unbind(null, null);
+        } else {
+            retrack();
+        }
+    }
+    
+    protected void bind(ServiceReference reference, Object service) {
+        if (listeners != null) {    
+            for (Listener listener : listeners) {
+                if (listener != null) {
+                    listener.bind(reference, service);
+                }
+            } 
+        }
+    }
+    
+    protected void unbind(ServiceReference reference, Object service) {
+        if (listeners != null) {    
+            for (Listener listener : listeners) {
+                if (listener != null) {
+                    listener.unbind(reference, service);
+                }
+            } 
+        }
+    }
+    
     public List<ServiceReference> getServiceReferences() {
         synchronized (references) {
             return new ArrayList<ServiceReference>(references);

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=806359&r1=806358&r2=806359&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
Thu Aug 20 21:14:08 2009
@@ -78,7 +78,8 @@
             addPartialObject(object);
             // Handle initial references
             createListeners();
-            retrack();
+            updateListeners();
+           
             return object;
         } catch (ComponentDefinitionException t) {
             throw t;
@@ -133,11 +134,7 @@
                     }
                 }
                 if (listeners != null) {
-                    for (Listener listener : listeners) {
-                        if (listener != null) {
-                            listener.bind(dispatcher.reference, dispatcher.proxy);
-                        }
-                    }
+                    bind(dispatcher.reference, dispatcher.proxy);                   
                 } else {
                     unboundDispatchers.add(dispatcher);
                 }
@@ -151,13 +148,7 @@
         if (storage != null) {
             ServiceDispatcher dispatcher = findDispatcher(reference);
             if (dispatcher != null) {
-                if (listeners != null) {
-                    for (Listener listener : listeners) {
-                        if (listener != null) {
-                            listener.unbind(dispatcher.reference, dispatcher.proxy);
-                        }
-                    }
-                }
+                unbind(dispatcher.reference, dispatcher.proxy);
                 storage.remove(dispatcher);
                 dispatcher.destroy();
             }

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=806359&r1=806358&r2=806359&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
Thu Aug 20 21:14:08 2009
@@ -88,7 +88,7 @@
 
             // Handle initial references
             createListeners();
-            retrack();
+            updateListeners();            
 
             // Return a ServiceProxy that can injection of references or proxies can be done
correctly
             return wrapper;
@@ -144,12 +144,7 @@
             trackedServiceReference = ref;
             trackedService = null;
             monitor.notifyAll();
-            if (listeners != null) {
-                for (Listener listener : listeners) {
-                    listener.bind(trackedServiceReference, proxy);
-                }
-                listenersCreated = false;
-            }
+            bind(trackedServiceReference, proxy);
         }
     }
 
@@ -157,23 +152,11 @@
         LOGGER.debug("Unbinding reference {}", getName());
         synchronized (monitor) {
             if (trackedServiceReference != null) {
-                if (listeners != null) {
-                    for (Listener listener : listeners) {
-                        listener.unbind(trackedServiceReference, proxy);
-                    }
-                    listenersCreated = false;
-                }
+                unbind(trackedServiceReference, proxy);
                 blueprintContainer.getBundleContext().ungetService(trackedServiceReference);
                 trackedServiceReference = null;
                 trackedService = null;
                 monitor.notifyAll();
-            } else if (listenersCreated) {
-                if (listeners != null) {
-                    for (Listener listener : listeners) {
-//                        listener.unbind(null, null);
-                    }
-                    listenersCreated = false;
-                }
             }
         }
     }



Mime
View raw message