servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lh...@apache.org
Subject svn commit: r1030009 - /servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java
Date Tue, 02 Nov 2010 11:52:55 GMT
Author: lhein
Date: Tue Nov  2 11:52:55 2010
New Revision: 1030009

URL: http://svn.apache.org/viewvc?rev=1030009&view=rev
Log:
improved structure for executor mbeans to distinguish between consumer and provider executors
(see SM-2007)

Modified:
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java

Modified: servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java?rev=1030009&r1=1030008&r2=1030009&view=diff
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java
(original)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java
Tue Nov  2 11:52:55 2010
@@ -52,6 +52,7 @@ public class ExecutorFactoryImpl impleme
     private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(ExecutorFactoryImpl.class);
 
     private static final String OBJECT_NAME_PREFIX = "org.apache.servicemix:ContainerName=ServiceMix,Name=Executors,Type=";
+    private static final String OBJECT_NAME_POSTFIX = ",SubType=";
 
     private ExecutorConfig defaultConfig = new ExecutorConfig();
 
@@ -214,10 +215,18 @@ public class ExecutorFactoryImpl impleme
 
         if (this.managementStrategy != null) {
             // SMX 4 - ManagementStrategy
-            this.managementStrategy.manageNamedObject(mbean, new javax.management.ObjectName(String.format("%s%s",
OBJECT_NAME_PREFIX, sanitize(id))));
+            if (hasSubType(id)) {
+                this.managementStrategy.manageNamedObject(mbean, new javax.management.ObjectName(String.format("%s%s%s%s",
OBJECT_NAME_PREFIX, sanitize(getType(id)), OBJECT_NAME_POSTFIX, sanitize(getSubType(id)))));
+            } else {
+                this.managementStrategy.manageNamedObject(mbean, new javax.management.ObjectName(String.format("%s%s",
OBJECT_NAME_PREFIX, sanitize(id))));
+            }
         } else if (this.mbeanServer != null) {
             // SMX 3 - MBeanServer
-            this.mbeanServer.registerMBean(mbean, new javax.management.ObjectName(String.format("%s%s",
OBJECT_NAME_PREFIX, sanitize(id))));
+            if (hasSubType(id)) {
+                this.mbeanServer.registerMBean(mbean, new javax.management.ObjectName(String.format("%s%s%s%s",
OBJECT_NAME_PREFIX, sanitize(getType(id)), OBJECT_NAME_POSTFIX, sanitize(getSubType(id)))));
+            } else {
+                this.mbeanServer.registerMBean(mbean, new javax.management.ObjectName(String.format("%s%s",
OBJECT_NAME_PREFIX, sanitize(id))));
+            }
         } else {
             // no possibility to insert the mbean
         }
@@ -235,4 +244,16 @@ public class ExecutorFactoryImpl impleme
         }
         return result;
     }
+
+    private boolean hasSubType(String id) {
+        return id.toLowerCase().trim().endsWith(".consumer") || id.toLowerCase().trim().endsWith(".provider");
+    }
+
+    private String getType(String id) {
+        return id.substring(0, id.lastIndexOf("."));
+    }
+
+    private String getSubType(String id) {
+        return id.substring(id.lastIndexOf(".") +1);
+    }
 }



Mime
View raw message