deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject deltaspike git commit: sorting our dynamic mbean featureinfo to ease deterministic code without having to map operations etc
Date Tue, 09 May 2017 10:12:04 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 6b49da426 -> 08c8cb3b5


sorting our dynamic mbean featureinfo to ease deterministic code without having to map operations
etc


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/08c8cb3b
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/08c8cb3b
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/08c8cb3b

Branch: refs/heads/master
Commit: 08c8cb3b5643b889698c6c2458be1966d1a1d8ab
Parents: 6b49da4
Author: rmannibucau <rmannibucau@apache.org>
Authored: Tue May 9 12:11:58 2017 +0200
Committer: rmannibucau <rmannibucau@apache.org>
Committed: Tue May 9 12:11:58 2017 +0200

----------------------------------------------------------------------
 .../core/impl/jmx/DynamicMBeanWrapper.java          | 16 ++++++++++++++++
 .../test/core/impl/jmx/SimpleRegistrationTest.java  |  4 ++--
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/08c8cb3b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/DynamicMBeanWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/DynamicMBeanWrapper.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/DynamicMBeanWrapper.java
index c37585c..99e60a5 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/DynamicMBeanWrapper.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/DynamicMBeanWrapper.java
@@ -40,6 +40,7 @@ import javax.management.ImmutableDescriptor;
 import javax.management.InvalidAttributeValueException;
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanException;
+import javax.management.MBeanFeatureInfo;
 import javax.management.MBeanInfo;
 import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanOperationInfo;
@@ -63,6 +64,8 @@ import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -248,6 +251,10 @@ public class DynamicMBeanWrapper extends NotificationBroadcasterSupport
implemen
             clazz = clazz.getSuperclass();
         }
 
+        Collections.sort(attributeInfos, MBeanFeatureInfoSorter.INSTANCE);
+        Collections.sort(operationInfos, MBeanFeatureInfoSorter.INSTANCE);
+        Collections.sort(notificationInfos, MBeanFeatureInfoSorter.INSTANCE);
+
         info = new MBeanInfo(annotatedMBean.getName(),
                 description,
                 attributeInfos.toArray(new MBeanAttributeInfo[attributeInfos.size()]),
@@ -532,4 +539,13 @@ public class DynamicMBeanWrapper extends NotificationBroadcasterSupport
implemen
     {
         sendNotification(notification);
     }
+
+    private static class MBeanFeatureInfoSorter<T extends MBeanFeatureInfo> implements
Comparator<T> {
+        private static final Comparator<? super MBeanFeatureInfo> INSTANCE = new MBeanFeatureInfoSorter<MBeanFeatureInfo>();
+
+        @Override
+        public int compare(final T o1, final T o2) {
+            return o1.getName().compareTo(o2.getName());
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/08c8cb3b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java
b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java
index a8ac369..b4f0199 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java
@@ -80,8 +80,8 @@ public abstract class SimpleRegistrationTest {
         MBeanOperationInfo[] operations = mBeanInfo.getOperations();
         Assert.assertNotNull(operations);
         Assert.assertTrue(operations.length > 0);
-        Assert.assertTrue("Empty Signature on operation: " + operations[0], operations[0].getSignature().length
> 0);
-        MBeanParameterInfo parameterInfo = operations[0].getSignature()[0];
+        Assert.assertTrue("Empty Signature on operation: " + operations[1], operations[1].getSignature().length
> 0);
+        MBeanParameterInfo parameterInfo = operations[1].getSignature()[0];
         assertEquals("multiplier", parameterInfo.getName());
         assertEquals("the multiplier", parameterInfo.getDescription());
 


Mime
View raw message