aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1365595 - /aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/AbstractCompendiumHandler.java
Date Wed, 25 Jul 2012 14:10:05 GMT
Author: gnodet
Date: Wed Jul 25 14:10:04 2012
New Revision: 1365595

URL: http://svn.apache.org/viewvc?rev=1365595&view=rev
Log:
[ARIES-884] ClassCastException in JMX when installing some bundles

Modified:
    aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/AbstractCompendiumHandler.java

Modified: aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/AbstractCompendiumHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/AbstractCompendiumHandler.java?rev=1365595&r1=1365594&r2=1365595&view=diff
==============================================================================
--- aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/AbstractCompendiumHandler.java
(original)
+++ aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/AbstractCompendiumHandler.java
Wed Jul 25 14:10:04 2012
@@ -17,7 +17,6 @@
 package org.apache.aries.jmx;
 
 import java.util.concurrent.ExecutorService;
-
 import javax.management.StandardMBean;
 
 import org.apache.aries.jmx.agent.JMXAgentContext;
@@ -77,8 +76,7 @@ public abstract class AbstractCompendium
         //API stipulates versions for compendium services with static ObjectName
         //This shouldn't happen but added as a consistency check
         if (trackedId != null) {
-            String serviceDescription = (String) ((reference.getProperty(Constants.SERVICE_DESCRIPTION)
!= null) ?
-                    reference.getProperty(Constants.SERVICE_DESCRIPTION) : reference.getProperty(Constants.OBJECTCLASS));
+            String serviceDescription = getServiceDescription(reference);
             logger.log(LogService.LOG_WARNING, "Detected secondary ServiceReference for ["
+ serviceDescription
                     + "] with " + Constants.SERVICE_ID + " [" + serviceId + "] Only 1 instance
will be JMX managed");
         } else {
@@ -106,8 +104,7 @@ public abstract class AbstractCompendium
         Logger logger = agentContext.getLogger();
         Long serviceID = (Long) reference.getProperty(Constants.SERVICE_ID);
         if (trackedId != null && !trackedId.equals(serviceID)) {
-            String serviceDescription = (String) ((reference.getProperty(Constants.SERVICE_DESCRIPTION)
!= null) ? 
-                    reference.getProperty(Constants.SERVICE_DESCRIPTION) : reference.getProperty(Constants.OBJECTCLASS));
+            String serviceDescription = getServiceDescription(reference);
             logger.log(LogService.LOG_WARNING, "ServiceReference for [" + serviceDescription
+ "] with "
                     + Constants.SERVICE_ID + " [" + serviceID + "] is not currently JMX managed");
         } else {
@@ -124,6 +121,26 @@ public abstract class AbstractCompendium
         }
     }
 
+    private String getServiceDescription(ServiceReference reference) {
+        String serviceDescription = (String) reference.getProperty(Constants.SERVICE_DESCRIPTION);
+        if (serviceDescription == null) {
+            Object obj = reference.getProperty(Constants.OBJECTCLASS);
+            if (obj instanceof String) {
+                StringBuilder sb = new StringBuilder();
+                for (String s : (String[]) obj) {
+                    if (sb.length() > 0) {
+                        sb.append(", ");
+                    }
+                    sb.append(s);
+                }
+                serviceDescription = sb.toString();
+            } else {
+                serviceDescription = obj.toString();
+            }
+        }
+        return serviceDescription;
+    }
+
     /**
      * Gets the <code>StandardMBean</code> managed by this handler when the backing
service is available or null
      * 



Mime
View raw message