Author: rob.stryker(a)jboss.com
Date: 2008-11-20 17:20:31 -0500 (Thu, 20 Nov 2008)
New Revision: 11932
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanOperationInfoWrapper.java
Log:
JBIDE-3231 - errors when pressing * in jmx
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanOperationInfoWrapper.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanOperationInfoWrapper.java 2008-11-20
20:44:43 UTC (rev 11931)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanOperationInfoWrapper.java 2008-11-20
22:20:31 UTC (rev 11932)
@@ -9,6 +9,7 @@
package org.jboss.tools.jmx.core;
import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
import org.eclipse.core.runtime.Assert;
@@ -34,6 +35,12 @@
return result;
}
+
+ /*
+ * Everything below here is duplication from javax.management
+ * to overcome a jboss bug where some mbeans do not conform to spec.
+ */
+
public boolean equals(Object obj) {
if (this == obj)
return true;
@@ -45,8 +52,56 @@
if (info == null) {
if (other.info != null)
return false;
- } else if (!info.equals(other.info))
+ } else if (!equals2(other.info))
return false;
return true;
}
+
+ private boolean equals2(MBeanOperationInfo o) {
+ if (o == info)
+ return true;
+ if (!(o instanceof MBeanOperationInfo))
+ return false;
+ MBeanOperationInfo p = (MBeanOperationInfo) o;
+ return (p.getName().equals(info.getName()) &&
+ p.getReturnType().equals(info.getReturnType()) &&
+ p.getDescription().equals(info.getDescription()) &&
+ p.getImpact() == info.getImpact() &&
+ arrayEquals(p.getSignature(), info.getSignature()) &&
+ p.getDescriptor().equals(info.getDescriptor()));
+
+ }
+
+ private boolean arrayEquals(MBeanParameterInfo[] a, MBeanParameterInfo[] a2) {
+ if (a==a2)
+ return true;
+ if (a==null || a2==null)
+ return false;
+
+ int length = a.length;
+ if (a2.length != length)
+ return false;
+
+ for (int i=0; i<length; i++) {
+ MBeanParameterInfo o1 = a[i];
+ MBeanParameterInfo o2 = a2[i];
+ if (!(o1==null ? o2==null : paramEquals(o1,o2)))
+ return false;
+ }
+
+ return true;
+ }
+
+ private boolean paramEquals(MBeanParameterInfo o1, MBeanParameterInfo o2) {
+ if (o1 == o2)
+ return true;
+ return (o1.getName().equals(o2.getName()) &&
+ o1.getType().equals(o2.getType()) &&
+ safeEquals(o1.getDescription(), o2.getDescription()) &&
+ o1.getDescriptor().equals(o2.getDescriptor()));
+ }
+
+ private boolean safeEquals(Object o1, Object o2) {
+ return o1 == o2 || !(o1 == null || o2 == null) || o1.equals(o2);
+ }
}