User: juhalindfors
Date: 02/03/01 03:57:34
Modified: src/main/javax/management MBeanAttributeInfo.java
MBeanOperationInfo.java
Log:
javadocs + cleanup
Revision Changes Path
1.4 +96 -11 jmx/src/main/javax/management/MBeanAttributeInfo.java
Index: MBeanAttributeInfo.java
===================================================================
RCS file: /cvsroot/jboss/jmx/src/main/javax/management/MBeanAttributeInfo.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MBeanAttributeInfo.java 10 Dec 2001 17:21:13 -0000 1.3
+++ MBeanAttributeInfo.java 1 Mar 2002 11:57:34 -0000 1.4
@@ -7,6 +7,7 @@
package javax.management;
import java.lang.reflect.Method;
+import java.io.Serializable;
/**
* Represents a management attribute in an MBeans' management interface.
@@ -14,45 +15,98 @@
* @see javax.management.MBeanInfo
*
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>.
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*
*/
public class MBeanAttributeInfo extends MBeanFeatureInfo
- implements java.io.Serializable, Cloneable
+ implements Serializable, Cloneable
{
// Attributes ----------------------------------------------------
- protected String type = null;
- protected boolean isReadable = false;
- protected boolean isWritable = false;
- protected boolean isIs = false;
+
+ /**
+ * Attribute type string. This is a fully qualified class name of the type.
+ */
+ private String type = null;
+
+ /**
+ * Is attribute readable.
+ */
+ private boolean isReadable = false;
+
+ /**
+ * Is attribute writable.
+ */
+ private boolean isWritable = false;
+
+ /**
+ * Is attribute using the boolean <tt>isAttributeName</tt> naming convention.
+ */
+ private boolean isIs = false;
+
// Constructors --------------------------------------------------
+
+ /**
+ * Creates an MBean attribute info object.
+ *
+ * @param name name of the attribute
+ * @param type the fully qualified class name of the attribute's type
+ * @param description human readable description string of the attribute
+ * @param isReadable if attribute is readable
+ * @param isWritable if attribute is writable
+ * @param isIs if attribute is using the boolean <tt>isAttributeName</tt>
naming convention for its getter method
+ */
public MBeanAttributeInfo(String name, String type, String description,
boolean isReadable, boolean isWritable, boolean isIs)
{
super(name, description);
+
this.type = type;
this.isReadable = isReadable;
this.isWritable = isWritable;
this.isIs = isIs;
}
+ /**
+ * Creates an MBean attribute info object using the given accessor methods.
+ *
+ * @param name Name of the attribute.
+ * @param description Human readable description string of the attribute's
type.
+ * @param getter The attribute's read accessor. May be <tt>null</tt> if
the attribute is write-only.
+ * @param setter The attribute's write accessor. May be <tt>null</tt> if
the attribute is read-only.
+ *
+ * @throws IntrospectionException if the accessor methods are not valid for the
attribute
+ */
public MBeanAttributeInfo(String name, String description, Method getter, Method
setter)
- throws IntrospectionException
+ throws IntrospectionException
{
super(name, description);
if (getter != null)
{
+ // getter must always be no args method, return type cannot be void
+ if (getter.getParameterTypes().length != 0)
+ throw new IntrospectionException("Expecting getter method to be of the
form 'AttributeType getAttributeName()': found getter with " +
getter.getParameterTypes().length + " parameters.");
+ if (getter.getReturnType() == Void.TYPE)
+ throw new IntrospectionException("Expecting getter method to be of the
form 'AttributeType getAttributeName()': found getter with void return type.");
+
this.isReadable = true;
+
if (getter.getName().startsWith("is"))
this.isIs = true;
+
this.type = getter.getReturnType().getName();
}
if (setter != null)
{
+ // setter must have one argument, no less, no more. Return type must be
void.
+ if (setter.getParameterTypes().length != 1)
+ throw new IntrospectionException("Expecting the setter method to be of
the form 'void setAttributeName(AttributeType value)': found setter with " +
setter.getParameterTypes().length + " parameters.");
+ if (setter.getReturnType() != Void.TYPE)
+ throw new IntrospectionException("Expecting the setter method to be of
the form 'void setAttributeName(AttributeType value)': found setter with " +
setter.getReturnType() + " return type.");
+
this.isWritable = true;
if (type == null)
@@ -72,35 +126,66 @@
}
}
+
// Public --------------------------------------------------------
+
+ /**
+ * Returns the type string of this attribute.
+ *
+ * @return fully qualified class name of the attribute's type
+ */
public String getType()
{
return type;
}
+ /**
+ * If the attribute is readable.
+ *
+ * @return true if attribute is readable; false otherwise
+ */
public boolean isReadable()
{
return isReadable;
}
+ /**
+ * If the attribute is writable.
+ *
+ * @return true if attribute is writable; false otherwise
+ */
public boolean isWritable()
{
return isWritable;
}
+ /**
+ * If the attribute is using the boolean <tt>isAttributeName</tt> naming
convention
+ * for its read accessor.
+ *
+ * @param true if using <tt>isAttributeName</tt> getter; false otherwise
+ */
public boolean isIs()
{
return isIs;
}
+
// Cloneable implementation --------------------------------------
- public Object clone() throws CloneNotSupportedException
+
+ /**
+ * Creates a copy of this object.
+ *
+ * @return clone of this object
+ * @throws CloneNotSupportedException if there was a failure creating the copy
+ */
+ public synchronized Object clone() throws CloneNotSupportedException
{
MBeanAttributeInfo clone = (MBeanAttributeInfo)super.clone();
- clone.type = getType();
- clone.isReadable = isReadable();
- clone.isWritable = isWritable();
- clone.isIs = isIs();
+ clone.type = this.type;
+ clone.isReadable = this.isReadable;
+ clone.isWritable = this.isWritable;
+ clone.isIs = this.isIs;
return clone;
}
1.7 +3 -2 jmx/src/main/javax/management/MBeanOperationInfo.java
Index: MBeanOperationInfo.java
===================================================================
RCS file: /cvsroot/jboss/jmx/src/main/javax/management/MBeanOperationInfo.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MBeanOperationInfo.java 24 Feb 2002 13:56:56 -0000 1.6
+++ MBeanOperationInfo.java 1 Mar 2002 11:57:34 -0000 1.7
@@ -18,7 +18,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>.
* @author <a href="mailto:[EMAIL PROTECTED]">Trevor Squires</a>.
*
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public class MBeanOperationInfo extends MBeanFeatureInfo
implements Serializable, Cloneable
@@ -74,7 +74,7 @@
* object and description.
*
* @param description human readable description of this operation
- * @param method used to build the metadata for the management operation
+ * @param method used for build the metadata for the management operation
*/
public MBeanOperationInfo(String description, Method method)
{
@@ -105,6 +105,7 @@
String returnType, int impact)
{
super(name, description);
+
this.signature = (null == signature) ? new MBeanParameterInfo[0] :
(MBeanParameterInfo[]) signature.clone();
this.returnType = returnType;
this.impact = impact;
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development