Return-Path: Delivered-To: apmail-avalon-cvs-archive@www.apache.org Received: (qmail 70619 invoked from network); 15 May 2004 05:50:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 15 May 2004 05:50:39 -0000 Received: (qmail 44003 invoked by uid 500); 15 May 2004 05:51:05 -0000 Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 43919 invoked by uid 500); 15 May 2004 05:51:04 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 43905 invoked by uid 500); 15 May 2004 05:51:04 -0000 Received: (qmail 43899 invoked by uid 98); 15 May 2004 05:51:04 -0000 Received: from niclas@apache.org by hermes.apache.org by uid 82 with qmail-scanner-1.20 (clamuko: 0.70. Clear:RC:0(209.237.227.194):. Processed in 0.044166 secs); 15 May 2004 05:51:04 -0000 X-Qmail-Scanner-Mail-From: niclas@apache.org via hermes.apache.org X-Qmail-Scanner: 1.20 (Clear:RC:0(209.237.227.194):. Processed in 0.044166 secs) Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by hermes.apache.org with SMTP; 15 May 2004 05:51:04 -0000 Received: (qmail 70541 invoked by uid 1774); 15 May 2004 05:50:36 -0000 Date: 15 May 2004 05:50:36 -0000 Message-ID: <20040515055036.70540.qmail@minotaur.apache.org> From: niclas@apache.org To: avalon-components-cvs@apache.org Subject: cvs commit: avalon-components/facilities/jmx/util/src/java/org/apache/avalon/jmx/util MBeanInfoBuilder.java X-Spam-Rating: hermes.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N niclas 2004/05/14 22:50:36 Modified: facilities/jmx/util/src/java/org/apache/avalon/jmx/util MBeanInfoBuilder.java Log: Applying patch from Cameron Fieber. This patch fixes a bug where the ModelMBeanInfo would fail to build for indexed type properties (by basically ignoring them for now, eventually it will treat them as operations), as well as supporting more information on introspected operations if it is available. Revision Changes Path 1.2 +61 -6 avalon-components/facilities/jmx/util/src/java/org/apache/avalon/jmx/util/MBeanInfoBuilder.java Index: MBeanInfoBuilder.java =================================================================== RCS file: /home/cvs/avalon-components/facilities/jmx/util/src/java/org/apache/avalon/jmx/util/MBeanInfoBuilder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MBeanInfoBuilder.java 4 Apr 2004 16:18:57 -0000 1.1 +++ MBeanInfoBuilder.java 15 May 2004 05:50:36 -0000 1.2 @@ -19,11 +19,13 @@ import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.MethodDescriptor; +import java.beans.ParameterDescriptor; import java.beans.PropertyDescriptor; import java.io.InputStream; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.List; import javax.management.Descriptor; import javax.management.MBeanParameterInfo; @@ -167,7 +169,7 @@ // do the methods final MethodDescriptor[] methods = beanInfo.getMethodDescriptors(); - final ArrayList operations = new ArrayList(); + final List operations = new ArrayList(); for ( int j = 0; j < methods.length; j++ ) { @@ -186,13 +188,19 @@ // do the attributes final PropertyDescriptor[] propertys = beanInfo.getPropertyDescriptors(); - final ModelMBeanAttributeInfo[] attributes = new ModelMBeanAttributeInfo[propertys. - length]; + final List attributesList = new ArrayList(); for ( int j = 0; j < propertys.length; j++ ) - { - attributes[j] = buildAttributeInfo( propertys[j], null ); + { + final ModelMBeanAttributeInfo attribute = buildAttributeInfo( propertys[j], null ); + //could be null for indexed properties + if (null != attribute) + { + attributesList.add( attribute ); + } } + final ModelMBeanAttributeInfo[] attributes = + (ModelMBeanAttributeInfo[]) attributesList.toArray( new ModelMBeanAttributeInfo[0] ); final ModelMBeanConstructorInfo[] constructors = new ModelMBeanConstructorInfo[0]; @@ -325,6 +333,15 @@ final String name = property.getName(); final Method readMethod = property.getReadMethod(); final Method writeMethod = property.getWriteMethod(); + final Class propertyType = property.getPropertyType(); + + //indexed property + //TODO: create a ModelMBeanOperationInfo + if (null == propertyType) + { + return null; + } + final String type = property.getPropertyType().getName(); String description = property.getDisplayName(); @@ -428,7 +445,30 @@ if ( config == null ) { - info = new ModelMBeanOperationInfo( method.getDisplayName(), method.getMethod() ); + final Class[] methodSignature = method.getMethod().getParameterTypes(); + final ParameterDescriptor[] paramDescriptors = method.getParameterDescriptors(); + if (methodSignature.length == 0 + || null == paramDescriptors + || methodSignature.length != paramDescriptors.length) + { + info = new ModelMBeanOperationInfo( method.getDisplayName(), method.getMethod() ); + } + else + { + final String name = method.getName(); + final String type = method.getMethod().getReturnType().getName(); + final String description = method.getDisplayName(); + final int impact = ModelMBeanOperationInfo.UNKNOWN; + final MBeanParameterInfo[] params = new MBeanParameterInfo[methodSignature.length]; + for (int i = 0; i < methodSignature.length; i++) + { + params[i] = buildParameterInfo( methodSignature[i], paramDescriptors[i] ); + } + + info = new ModelMBeanOperationInfo( name, description, params, type, impact ); + } + + } else @@ -490,6 +530,21 @@ final String name = paramConfig.getAttribute( "name" ); final String description = paramConfig.getAttribute( "description" ); final String type = paramConfig.getAttribute( "type" ); + + return new MBeanParameterInfo( name, type, description ); + } + + /** + * Builds the param descriptor from bean info. + * + * @throws ConfigurationException if configuration not structured corretly + * @return the descriptor + */ + private MBeanParameterInfo buildParameterInfo(Class parameterType, ParameterDescriptor descriptor) + { + final String name = descriptor.getDisplayName(); + final String description = descriptor.getShortDescription(); + final String type = parameterType.getName(); return new MBeanParameterInfo( name, type, description ); } --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org For additional commands, e-mail: cvs-help@avalon.apache.org