You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2010/06/24 15:18:56 UTC

svn commit: r957542 - in /servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc: CxfBcComponent.java CxfBcConsumer.java

Author: ffang
Date: Thu Jun 24 13:18:56 2010
New Revision: 957542

URL: http://svn.apache.org/viewvc?rev=957542&view=rev
Log:
[SMXCOMP-762]CxfBCComponet should be able to cache cxf buses across different cxf endpoint

Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java?rev=957542&r1=957541&r2=957542&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java Thu Jun 24 13:18:56 2010
@@ -17,6 +17,8 @@
 package org.apache.servicemix.cxfbc;
 
 import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
@@ -33,6 +35,8 @@ public class CxfBcComponent extends Defa
     private CxfBcEndpointType[] endpoints;
 
     private Bus bus;
+    
+    private Map<String, Bus> allBuses = new ConcurrentHashMap<String, Bus>();
 
     private String busCfg;
     
@@ -116,6 +120,10 @@ public class CxfBcComponent extends Defa
         }
         return bus;
     }
+    
+    public Map<String, Bus> getAllBuses() {
+        return this.allBuses;
+    }
 
     /**
         * Specifies the location of the CXF configuraiton file used to configure

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java?rev=957542&r1=957541&r2=957542&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java Thu Jun 24 13:18:56 2010
@@ -393,11 +393,18 @@ public class CxfBcConsumer extends Consu
     public void deactivate() throws Exception {
         server.stop();
         if (!isComponentBus()) {
+            Map<String, Bus> allBuses = ((CxfBcComponent) getServiceUnit().getComponent()).getAllBuses();
             //if use the endpoint own bus, then shutdown it
             if (providedBus != null) {
+                if (allBuses.keySet().contains(providedBus.getId())) {
+                    allBuses.remove(providedBus.getId());
+                }
                 providedBus.shutdown(true);
                 providedBus = null;
             } else {
+                if (allBuses.keySet().contains(bus.getId())) {
+                    allBuses.remove(bus.getId());
+                }
                 bus.shutdown(true);
                 bus = null;
             }
@@ -653,8 +660,9 @@ public class CxfBcConsumer extends Consu
     }
 
     protected Bus getBus() {
+        Bus ret = null;
         if (providedBus != null) {
-            return providedBus;
+            ret = providedBus;
         } else if (getBusCfg() != null) {
             if (bus == null) {
                 SpringBusFactory bf = new SpringBusFactory();
@@ -665,11 +673,16 @@ public class CxfBcConsumer extends Consu
                     BusFactory.setDefaultBus(bus);
                 }
             }
-            return bus;
+            ret = bus;
         } else {
         	bus = ((CxfBcComponent) getServiceUnit().getComponent()).getBus();
-            return bus;
+            ret = bus;
         }
+        Map<String, Bus> allBuses = ((CxfBcComponent) getServiceUnit().getComponent()).getAllBuses();
+        if (!allBuses.keySet().contains(ret.getId())) {
+            allBuses.put(ret.getId(), ret);
+        }
+        return ret;
     }
 
     private boolean isComponentBus() {