camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1391008 - /camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
Date Thu, 27 Sep 2012 13:43:23 GMT
Author: davsclaus
Date: Thu Sep 27 13:43:22 2012
New Revision: 1391008

URL: http://svn.apache.org/viewvc?rev=1391008&view=rev
Log:
CAMEL-5656: JMXConnector started async no need for thread pool as thread should terminate
after started.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java?rev=1391008&r1=1391007&r2=1391008&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
Thu Sep 27 13:43:22 2012
@@ -25,7 +25,6 @@ import java.rmi.registry.LocateRegistry;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ExecutorService;
 import javax.management.JMException;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
@@ -58,7 +57,6 @@ public class DefaultManagementAgent exte
     private static final transient Logger LOG = LoggerFactory.getLogger(DefaultManagementAgent.class);
 
     private CamelContext camelContext;
-    private ExecutorService executorService;
     private MBeanServer server;
     // need a name -> actual name mapping as some servers changes the names (suc as WebSphere)
     private final Map<ObjectName, ObjectName> mbeansRegistered = new HashMap<ObjectName,
ObjectName>();
@@ -207,14 +205,6 @@ public class DefaultManagementAgent exte
         this.registerNewRoutes = registerNewRoutes;
     }
 
-    public ExecutorService getExecutorService() {
-        return executorService;
-    }
-
-    public void setExecutorService(ExecutorService executorService) {
-        this.executorService = executorService;
-    }
-
     public CamelContext getCamelContext() {
         return camelContext;
     }
@@ -271,6 +261,7 @@ public class DefaultManagementAgent exte
         if (cs != null) {
             try {
                 cs.stop();
+                LOG.debug("Stopped JMX Connector");
             } catch (IOException e) {
                 LOG.debug("Error occurred during stopping JMXConnectorService: "
                         + cs + ". This exception will be ignored.");
@@ -412,23 +403,23 @@ public class DefaultManagementAgent exte
 
         cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
 
-        if (executorService == null) {
-            // we only need a single thread for the JMX connector
-            executorService = camelContext.getExecutorServiceManager().newSingleThreadExecutor(this,
"JMXConnector: " + url);
-        }
-
-        // execute the JMX connector
-        executorService.execute(new Runnable() {
+        // use async thread for starting the JMX Connector
+        // (no need to use a thread pool or enlist in JMX as this thread is terminated when
the JMX connector has been started)
+        Thread thread = new Thread(new Runnable() {
             public void run() {
                 try {
+                    LOG.debug("Staring JMX Connector thread to listen at: {}", url);
                     cs.start();
+                    LOG.info("JMX Connector thread started and listening at: {}", url);
                 } catch (IOException ioe) {
-                    LOG.warn("Could not start JMXConnector thread.", ioe);
+                    LOG.warn("Could not start JMXConnector thread at: " + url + ". JMX Connector
not in use.", ioe);
                 }
             }
         });
-
-        LOG.info("JMX Connector thread started and listening at: " + url);
+        thread.setDaemon(true);
+        String threadName = camelContext.getExecutorServiceManager().resolveThreadName("JMXConnector:
" + url);
+        thread.setName(threadName);
+        thread.start();
     }
 
 }



Mime
View raw message