activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r524041 - /activemq/camel/trunk/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
Date Fri, 30 Mar 2007 10:54:51 GMT
Author: jstrachan
Date: Fri Mar 30 03:54:50 2007
New Revision: 524041

URL: http://svn.apache.org/viewvc?view=rev&rev=524041
Log:
optimised so that the Destination and Conduit are looked up and reused on startup

Modified:
    activemq/camel/trunk/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java

Modified: activemq/camel/trunk/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java?view=diff&rev=524041&r1=524040&r2=524041
==============================================================================
--- activemq/camel/trunk/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
(original)
+++ activemq/camel/trunk/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
Fri Mar 30 03:54:50 2007
@@ -40,6 +40,10 @@
 public class CxfProducer extends DefaultProducer<CxfExchange> {
     private CxfEndpoint endpoint;
     private final LocalTransportFactory transportFactory;
+    private Destination destination;
+    private Conduit conduit;
+    private ResultFuture future = new ResultFuture();
+
 
     public CxfProducer(CxfEndpoint endpoint, LocalTransportFactory transportFactory) {
         super(endpoint);
@@ -49,20 +53,12 @@
 
     public void onExchange(CxfExchange exchange) {
         try {
-            EndpointInfo endpointInfo = endpoint.getEndpointInfo();
-            Destination d = transportFactory.getDestination(endpointInfo);
-
-            // Set up a listener for the response
-            Conduit conduit = transportFactory.getConduit(endpointInfo);
-            ResultFuture future = new ResultFuture();
-            conduit.setMessageObserver(future);
-
             CxfBinding binding = endpoint.getBinding();
             MessageImpl m = binding.createCxfMessage(exchange);
             ExchangeImpl e = new ExchangeImpl();
             e.setInMessage(m);
             m.put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
-            m.setDestination(d);
+            m.setDestination(destination);
             conduit.send(m);
 
             // now lets wait for the response
@@ -77,6 +73,27 @@
         catch (IOException e) {
             throw new RuntimeCamelException(e);
         }
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        EndpointInfo endpointInfo = endpoint.getEndpointInfo();
+        destination = transportFactory.getDestination(endpointInfo);
+
+        // Set up a listener for the response
+        conduit = transportFactory.getConduit(endpointInfo);
+        conduit.setMessageObserver(future);
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+
+        if (conduit != null) {
+            conduit.close();
+        }
+
     }
 
     protected class ResultFuture implements MessageObserver {



Mime
View raw message