This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jmx.provider-0.6.0
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jmx-provider.git

commit 770d4a154dad49ec266a561dda1973d1f8aba1bb
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Tue Oct 15 16:44:53 2013 +0000

    SLING-3176 : ValueMap of jmx resource should contain mbean attributes
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jmxprovider@1532424
 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/jmx/provider/impl/MBeanResource.java     | 40 +++++++++++++++-------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/jmx/provider/impl/MBeanResource.java 
b/src/main/java/org/apache/sling/jmx/provider/impl/MBeanResource.java
index 21aa8e3..d479f45 100644
--- a/src/main/java/org/apache/sling/jmx/provider/impl/MBeanResource.java
+++ b/src/main/java/org/apache/sling/jmx/provider/impl/MBeanResource.java
@@ -19,8 +19,11 @@
 package org.apache.sling.jmx.provider.impl;
 
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 
+import javax.management.Attribute;
+import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanAttributeInfo;
@@ -128,22 +131,33 @@ public class MBeanResource extends AbstractResource {
         result.put(Constants.PROP_OBJECTNAME, 
this.objectName.getCanonicalName());
 
         final MBeanAttributeInfo[] attribs = this.info.getAttributes();
+        final String[] names = new String[attribs.length];
+        int index = 0;
         for(final MBeanAttributeInfo i : attribs) {
-             Object value = null;
-             try {
-                value = this.mbeanServer.getAttribute(this.objectName, 
i.getName());
-                if ( value != null ) {
-                    result.put(i.getName(), value);
+            names[index] = i.getName();
+            index++;
+        }
+         AttributeList values = null;
+         try {
+            values = this.mbeanServer.getAttributes(this.objectName, names);
+            if ( values != null ) {
+                final Iterator iter = values.iterator();
+                while ( iter.hasNext() ) {
+                    final Attribute a = (Attribute)iter.next();
+                    final Object value = a.getValue();
+                    if ( value != null ) {
+                        result.put(a.getName(), value);
+                    }
                 }
-            } catch (final AttributeNotFoundException e) {
-                // ignore
-            } catch (final InstanceNotFoundException e) {
-                // ignore
-            } catch (final MBeanException e) {
-                // ignore
-            } catch (final ReflectionException e) {
-                // ignore
             }
+        } catch (final AttributeNotFoundException e) {
+            // ignore
+        } catch (final InstanceNotFoundException e) {
+            // ignore
+        } catch (final MBeanException e) {
+            // ignore
+        } catch (final ReflectionException e) {
+            // ignore
         }
 
         return result;

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to