User: juhalindfors
Date: 02/03/20 10:26:32
Modified: src/main/javax/management/modelmbean DescriptorSupport.java
ModelMBeanAttributeInfo.java
ModelMBeanOperationInfo.java
Log:
merge RelMX_1_0_0_8 to RelMX_1_0_0_10 to dev branch
Revision Changes Path
1.5 +47 -5 jmx/src/main/javax/management/modelmbean/DescriptorSupport.java
Index: DescriptorSupport.java
===================================================================
RCS file:
/cvsroot/jboss/jmx/src/main/javax/management/modelmbean/DescriptorSupport.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DescriptorSupport.java 8 Mar 2002 15:32:03 -0000 1.4
+++ DescriptorSupport.java 20 Mar 2002 18:26:31 -0000 1.5
@@ -24,7 +24,14 @@
* @see javax.management.Descriptor
*
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>.
- * @version $Revision$
+ * @version $Revision$
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>20020320 Juha Lindfors:</b>
+ * <ul>
+ * <li>toString() implementation</li>
+ * </ul>
*/
public class DescriptorSupport
implements Descriptor, Cloneable, Serializable
@@ -86,10 +93,28 @@
this.setFields(descriptor.getFieldNames(),
descriptor.getFieldValues(descriptor.getFieldNames()));
}
-
+ /**
+ * Creates descriptor instance with given field names and values.if both field
names and field
+ * values array contain a <tt>null</tt> reference or empty arrays, an empty
descriptor is created.
+ * None of the name entries in the field names array can be a <tt>null</tt>
reference.
+ * Field values may contain <tt>null</tt> references.
+ *
+ * @param fieldNames Contains names for the descriptor fields. This array
cannot contain
+ * <tt>null</tt> references. If both <tt>fieldNames</tt>
and <tt>fieldValues</tt>
+ * arguments contain <tt>null</tt> or empty array
references then an empty descriptor
+ * is created. The size of the <tt>fieldNames</tt> array
must match the size of
+ * the <tt>fieldValues</tt> array.
+ * @param fieldValues Contains values for the descriptor fields. Null
references are allowed.
+ *
+ * @throws RuntimeOperationsException if array sizes don't match
+ */
public DescriptorSupport(String[] fieldNames, Object[] fieldValues) throws
RuntimeOperationsException
{
- setFields(fieldNames, fieldValues);
+ if (fieldNames == null && fieldValues == null)
+ return;
+
+ // FIXME: javadoc for setFields throws exception on null values as well
+ setFields(fieldNames, fieldValues);
}
public DescriptorSupport(String[] fields)
@@ -200,8 +225,25 @@
// Object overrides ----------------------------------------------
public String toString()
{
- // FIXME: human readable string
- return super.toString();
+ String[] names = getFieldNames();
+ Object[] values = getFieldValues(names);
+
+ if (names.length == 0)
+ return "<empty descriptor>";
+
+ StringBuffer sbuf = new StringBuffer(500);
+
+ for (int i = 0; i < values.length; ++i)
+ {
+ sbuf.append(names[i]);
+ sbuf.append("=");
+ sbuf.append(values[i]);
+ sbuf.append(",");
+ }
+
+ sbuf.deleteCharAt(sbuf.length() - 1);
+
+ return sbuf.toString();
}
1.4 +36 -4
jmx/src/main/javax/management/modelmbean/ModelMBeanAttributeInfo.java
Index: ModelMBeanAttributeInfo.java
===================================================================
RCS file:
/cvsroot/jboss/jmx/src/main/javax/management/modelmbean/ModelMBeanAttributeInfo.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ModelMBeanAttributeInfo.java 8 Mar 2002 22:09:20 -0000 1.3
+++ ModelMBeanAttributeInfo.java 20 Mar 2002 18:26:31 -0000 1.4
@@ -23,6 +23,12 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>.
* @version $Revision$
*
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>20020320 Juha Lindfors:</b>
+ * <ul>
+ * <li>toString() implementation</li>
+ * </ul>
*/
public class ModelMBeanAttributeInfo
extends MBeanAttributeInfo
@@ -54,7 +60,9 @@
}
/**
- * Creates a new attribute info object.
+ * Creates a new attribute info object. If a <tt>null</tt> or
+ * invalid descriptor is passed as a parameter, a default descriptor will be
created
+ * for the attribute.
*
* @param name name of the attribute
* @param description human readable description string
@@ -154,6 +162,14 @@
return (Descriptor)descriptor.clone();
}
+ /**
+ * Replaces the descriptor associated with this attribute. If the
<tt>inDescriptor</tt>
+ * argument is <tt>null</tt> then the existing descriptor is replaced with a
default
+ * descriptor.
+ *
+ * @param inDescriptor descriptor used for replacing the existing operation
descriptor
+ * @throws IllegalArgumentException if the new descriptor is not valid
+ */
public void setDescriptor(Descriptor inDescriptor)
{
if (inDescriptor == null)
@@ -182,10 +198,26 @@
}
// Object override -----------------------------------------------
+ /**
+ * Returns a string representation of this Model MBean attribute info object.
+ * The returned string is in the form: <pre>
+ *
+ * ModelMBeanAttributeInfo[Name=<attribute name>,
+ * Type=<class name of the attribute type>,
+ * Access= RW | RO | WO,
+ * Descriptor=(fieldName1=fieldValue1, ... ,
fieldName<n>=fieldValue<n>)]
+ *
+ * </pre>
+ *
+ * @return string representation of this object
+ */
public String toString()
{
- // FIXME: human readable string
- return super.toString();
+ return "ModelMBeanAttributeInfo[" +
+ "Name=" + getName() +
+ ",Type=" + getType() +
+ ",Access=" + ((isReadable() && isWritable()) ? "RW" : (isReadable()) ?
"RO" : "WO") +
+ ",Descriptor(" + getDescriptor() + ")]";
}
// Private -------------------------------------------------------
1.6 +62 -3
jmx/src/main/javax/management/modelmbean/ModelMBeanOperationInfo.java
Index: ModelMBeanOperationInfo.java
===================================================================
RCS file:
/cvsroot/jboss/jmx/src/main/javax/management/modelmbean/ModelMBeanOperationInfo.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ModelMBeanOperationInfo.java 8 Mar 2002 22:09:20 -0000 1.5
+++ ModelMBeanOperationInfo.java 20 Mar 2002 18:26:31 -0000 1.6
@@ -23,6 +23,13 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>.
* @version $Revision$
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>20020320 Juha Lindfors:</b>
+ * <ul>
+ * <li>toString() implementation</li>
+ * </ul>
*/
public class ModelMBeanOperationInfo
extends MBeanOperationInfo
@@ -167,13 +174,65 @@
}
// Object overrides ----------------------------------------------
+ /**
+ * Returns a string representation of this Model MBean operation info object.
+ * The returned string is in the form: <pre>
+ *
+ * ModelMBeanOperationInfo[<return type> <operation
name>(<signature>),
+ * Impact=ACTION | INFO | ACTION_INFO | UNKNOWN,
+ * Descriptor=(fieldName1=fieldValue1, ... ,
fieldName<n>=fieldValue<n>)]
+ *
+ * </pre>
+ *
+ * @return string representation of this object
+ */
public String toString()
{
- // FIXME: human readable string
- return super.toString();
+ return "ModelMBeanOperationInfo[" +
+ getReturnType() + " " + getName() + getSignatureString() +
+ ",Impact=" + getImpactString() +
+ ",Descriptor(" + getDescriptor() + ")]";
}
// Private -------------------------------------------------------
+ private String getSignatureString()
+ {
+ StringBuffer sbuf = new StringBuffer(400);
+ sbuf.append("(");
+
+ MBeanParameterInfo[] sign = getSignature();
+
+ if (sign.length > 0)
+ {
+ for (int i = 0; i < sign.length; ++i)
+ {
+ sbuf.append(sign[i].getType());
+ sbuf.append(" ");
+ sbuf.append(sign[i].getName());
+
+ sbuf.append(",");
+ }
+
+ sbuf.delete(sbuf.length() - 1, sbuf.length());
+ }
+ sbuf.append(")");
+
+ return sbuf.toString();
+ }
+
+ private String getImpactString()
+ {
+ int impact = getImpact();
+ if (impact == MBeanOperationInfo.ACTION)
+ return "ACTION";
+ else if (impact == MBeanOperationInfo.INFO)
+ return "INFO";
+ else if (impact == MBeanOperationInfo.ACTION_INFO)
+ return "ACTION_INFO";
+ else
+ return "UNKNOWN";
+ }
+
private Descriptor createDefaultDescriptor()
{
DescriptorSupport descr = new DescriptorSupport();
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development