camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject camel git commit: CAMEL-10914: CxfConsumer doesn't clean up the CXF endpoint MBean upon stop
Date Wed, 01 Mar 2017 12:18:53 GMT
Repository: camel
Updated Branches:
  refs/heads/master 19d23bac3 -> 70872f32b


CAMEL-10914: CxfConsumer doesn't clean up the CXF endpoint MBean upon stop


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/70872f32
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/70872f32
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/70872f32

Branch: refs/heads/master
Commit: 70872f32b2089ea0f452dd18226b22381baeeec9
Parents: 19d23ba
Author: Tadayoshi Sato <sato.tadayoshi@gmail.com>
Authored: Wed Mar 1 20:20:21 2017 +0900
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Wed Mar 1 13:18:40 2017 +0100

----------------------------------------------------------------------
 .../apache/camel/component/cxf/CxfConsumer.java | 27 ++++++++++++++------
 1 file changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/70872f32/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
index e16127b..808d58b 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
@@ -63,17 +63,21 @@ public class CxfConsumer extends DefaultConsumer {
     public CxfConsumer(final CxfEndpoint endpoint, Processor processor) throws Exception
{
         super(endpoint, processor);
         cxfEndpoint = endpoint;
-        // create server
-        ServerFactoryBean svrBean = endpoint.createServerFactoryBean();
-        svrBean.setInvoker(new CxfConsumerInvoker(endpoint));
-        server = svrBean.create();
-        // Apply the server configurer if it is possible 
+        server = createServer();
+    }
+
+    protected Server createServer() throws Exception {
+        ServerFactoryBean svrBean = cxfEndpoint.createServerFactoryBean();
+        svrBean.setInvoker(new CxfConsumerInvoker(cxfEndpoint));
+        Server server = svrBean.create();
+        // Apply the server configurer if it is possible
         if (cxfEndpoint.getCxfEndpointConfigurer() != null) {
             cxfEndpoint.getCxfEndpointConfigurer().configureServer(server);
         }
-        if (ObjectHelper.isNotEmpty(endpoint.getPublishedEndpointUrl())) {
-            server.getEndpoint().getEndpointInfo().setProperty("publishedEndpointUrl", endpoint.getPublishedEndpointUrl());
+        if (ObjectHelper.isNotEmpty(cxfEndpoint.getPublishedEndpointUrl())) {
+            server.getEndpoint().getEndpointInfo().setProperty("publishedEndpointUrl", cxfEndpoint.getPublishedEndpointUrl());
         }
+        return server;
     }
 
     public Server getServer() {
@@ -83,12 +87,19 @@ public class CxfConsumer extends DefaultConsumer {
     @Override
     protected void doStart() throws Exception {
         super.doStart();
+        if (server == null) {
+            server = createServer();
+        }
         server.start();
     }
 
     @Override
     protected void doStop() throws Exception {
-        server.stop();
+        if (server != null) {
+            server.stop();
+            server.destroy();
+            server = null;
+        }
         super.doStop();
     }
 


Mime
View raw message