donaldp 01/12/01 19:44:24
Modified: src/java/org/apache/jmx/introspector JavaBeanMBean.java
Log:
Make sure accessors and mutators are not added as operations of the bean.
Revision Changes Path
1.6 +24 -5
jakarta-avalon-phoenix/src/java/org/apache/jmx/introspector/JavaBeanMBean.java
Index: JavaBeanMBean.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-phoenix/src/java/org/apache/jmx/introspector/JavaBeanMBean.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JavaBeanMBean.java 2001/11/19 12:21:31 1.5
+++ JavaBeanMBean.java 2001/12/02 03:44:24 1.6
@@ -25,7 +25,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Leo Simons</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version CVS $Revision: 1.5 $ $Date: 2001/11/19 12:21:31 $
+ * @version CVS $Revision: 1.6 $ $Date: 2001/12/02 03:44:24 $
*/
public class JavaBeanMBean
extends AbstractMBean
@@ -159,7 +159,6 @@
if( null == interfaces ) return null;
final ArrayList operations = new ArrayList();
- final ArrayList names = new ArrayList();
for( int i = 0; i < interfaces.length; i++ )
{
@@ -177,14 +176,36 @@
final MethodDescriptor[] methods =
beanInfo.getMethodDescriptors();
for( int j = 0; j < methods.length; j++ )
{
+ final MethodDescriptor descriptor = methods[ j ];
+ final Method method = descriptor.getMethod();
+ if( isMutator( method ) || isAccessor( method ) )
+ {
+ continue;
+ }
+
operations.add( methods[ j ] );
- names.add( methods[ j ].getName() );
}
}
return (MethodDescriptor[])operations.toArray( new MethodDescriptor[
0 ] );
}
+ private boolean isMutator( final Method method )
+ {
+ return
+ Void.TYPE == method.getReturnType() &&
+ method.getName().startsWith( "set" ) &&
+ 1 == method.getParameterTypes().length;
+ }
+
+ private boolean isAccessor( final Method method )
+ {
+ return
+ Void.TYPE != method.getReturnType() &&
+ method.getName().startsWith( "get" ) &&
+ 0 == method.getParameterTypes().length;
+ }
+
/**
* Retrieve a list of allowed attributes.
* Allowed attributes are based on interfaces passed in.
@@ -195,7 +216,6 @@
if( null == interfaces ) return null;
final ArrayList attributes = new ArrayList();
- final ArrayList names = new ArrayList();
for( int i = 0; i < interfaces.length; i++ )
{
@@ -214,7 +234,6 @@
for( int j = 0; j < propertys.length; j++ )
{
attributes.add( propertys[ j ] );
- names.add( propertys[ j ].getName() );
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>