geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r806420 - /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java
Date Fri, 21 Aug 2009 05:16:40 GMT
Author: gawor
Date: Fri Aug 21 05:16:40 2009
New Revision: 806420

URL: http://svn.apache.org/viewvc?rev=806420&view=rev
Log:
select bundle that has lowest ranking service that's in use to destroy

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

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java?rev=806420&r1=806419&r2=806420&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java
Fri Aug 21 05:16:40 2009
@@ -111,15 +111,11 @@
             int usage = 0;
             if (references != null) {
                 for (ServiceReference reference : references) {
-                    Bundle[] usingBundles = reference.getUsingBundles();
-                    if (usingBundles != null) {
-                        usage += usingBundles.length;
-                    }
+                    usage += getServiceUsage(reference);
                 }
             }
             LOGGER.debug("Usage for bundle {} is {}", bundle, usage);
             if (usage == 0) {
-                LOGGER.debug("Currently selecting bundle {} for destroy", bundle);
                 bundlesToDestroy.add(bundle);
             }
         }
@@ -129,11 +125,15 @@
                     return (int) (b2.getLastModified() - b1.getLastModified());
                 }
             });
+            LOGGER.debug("Selected bundles {} for destroy (no services in use)", bundlesToDestroy);
         } else {
             ServiceReference ref = null;
             for (Bundle bundle : containers.keySet()) {
                 ServiceReference[] references = bundle.getRegisteredServices();
                 for (ServiceReference reference : references) {
+                    if (getServiceUsage(reference) == 0) {
+                        continue;
+                    }
                     if (ref == null || reference.compareTo(ref) < 0) {
                         LOGGER.debug("Currently selecting bundle {} for destroy (with reference
{})", bundle, reference);
                         ref = reference;
@@ -141,10 +141,16 @@
                 }
             }
             bundlesToDestroy.add(ref.getBundle());
+            LOGGER.debug("Selected bundle {} for destroy (lowest ranking service)", bundlesToDestroy);
         }
         return bundlesToDestroy;
     }
 
+    private static int getServiceUsage(ServiceReference ref) {
+        Bundle[] usingBundles = ref.getUsingBundles();
+        return (usingBundles != null) ? usingBundles.length : 0;        
+    }
+    
     public void bundleChanged(BundleEvent event) {
         Bundle bundle = event.getBundle();
         if (event.getType() == BundleEvent.LAZY_ACTIVATION) {



Mime
View raw message