You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bi...@apache.org on 2006/03/05 01:41:25 UTC
svn commit: r383232 -
/jakarta/commons/proper/modeler/trunk/src/java/org/apache/commons/modeler/BaseModelMBean.java
Author: billbarker
Date: Sat Mar 4 16:41:25 2006
New Revision: 383232
URL: http://svn.apache.org/viewcvs?rev=383232&view=rev
Log:
Allow invoking methods with the same name but different signatures.
Fix for Bug #34959
Modified:
jakarta/commons/proper/modeler/trunk/src/java/org/apache/commons/modeler/BaseModelMBean.java
Modified: jakarta/commons/proper/modeler/trunk/src/java/org/apache/commons/modeler/BaseModelMBean.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/modeler/trunk/src/java/org/apache/commons/modeler/BaseModelMBean.java?rev=383232&r1=383231&r2=383232&view=diff
==============================================================================
--- jakarta/commons/proper/modeler/trunk/src/java/org/apache/commons/modeler/BaseModelMBean.java (original)
+++ jakarta/commons/proper/modeler/trunk/src/java/org/apache/commons/modeler/BaseModelMBean.java Sat Mar 4 16:41:25 2006
@@ -394,7 +394,8 @@
"Method name is null");
if( log.isDebugEnabled()) log.debug("Invoke " + name);
- Method method=(Method)invokeAttMap.get(name);
+ MethodKey mkey = new MethodKey(name, signature);
+ Method method=(Method)invokeAttMap.get(mkey);
if( method==null ) {
if (params == null)
params = new Object[0];
@@ -444,7 +445,7 @@
"Cannot find method " + name +
" with this signature");
}
- invokeAttMap.put( name, method );
+ invokeAttMap.put( mkey, method );
}
// Invoke the selected method on the appropriate object
@@ -1376,5 +1377,41 @@
if( resource instanceof MBeanRegistration ) {
((MBeanRegistration)resource).postDeregister();
}
+ }
+
+ static class MethodKey {
+ private String name;
+ private String[] signature;
+
+ MethodKey(String name, String[] signature) {
+ this.name = name;
+ if(signature == null) {
+ signature = new String[0];
+ }
+ this.signature = signature;
+ }
+
+ public boolean equals(Object other) {
+ if(!(other instanceof MethodKey)) {
+ return false;
+ }
+ MethodKey omk = (MethodKey)other;
+ if(!name.equals(omk.name)) {
+ return false;
+ }
+ if(signature.length != omk.signature.length) {
+ return false;
+ }
+ for(int i=0; i < signature.length; i++) {
+ if(!signature[i].equals(omk.signature[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public int hashCode() {
+ return name.hashCode();
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org