This adds the remaining OpenMBeanXXXSupport classes. Changelog:
2006-08-02 Andrew John Hughes <[EMAIL PROTECTED]> * javax/management/MBeanConstructorInfo.java: (MBeanConstructorInfo(String,String,MBeanParameterInfo[]): Copy array rather than directly assigning. * javax/management/MBeanInfo.java: (MBeanInfo(String,String,MBeanAttributeInfo[], MBeanConstructorInfo[], MBeanOperationInfo[], MBeanNotificationInfo[])): Likewise. * javax/management/MBeanOperationInfo.java: (MBeanOperationInfo(String,String,MBeanParameterInfo[],String,int)): Likewise. * javax/management/openmbean/OpenMBeanAttributeInfoSupport.java, * javax/management/openmbean/OpenMBeanConstructorInfoSupport.java: New files. * javax/management/openmbean/OpenMBeanInfo.java: Corrected documentation. * javax/management/openmbean/OpenMBeanInfoSupport.java: New file. * javax/management/openmbean/OpenMBeanOperationInfo.java: Corrected documentation. * javax/management/openmbean/OpenMBeanOperationInfoSupport.java: New file. * javax/management/openmbean/OpenMBeanParameterInfoSupport.java: (MBeanParameterInfo(String,String,OpenType,Object,Object[])): Call other constructor rather than reimplementing. -- Andrew :-) Escape the Java Trap with GNU Classpath! http://www.gnu.org/philosophy/java-trap.html public class gcj extends Freedom implements Java { ... }
Index: javax/management/MBeanConstructorInfo.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/management/MBeanConstructorInfo.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 MBeanConstructorInfo.java --- javax/management/MBeanConstructorInfo.java 29 Jul 2006 21:44:53 -0000 1.3 +++ javax/management/MBeanConstructorInfo.java 2 Aug 2006 21:28:35 -0000 @@ -89,10 +89,11 @@ public class MBeanConstructorInfo * Constructs a @link{MBeanConstructorInfo} with the specified * name, description and parameter information. A <code>null</code> * value for the parameter information is the same as passing in - * an empty array. + * an empty array. A copy of the parameter array is taken, so + * later changes have no effect. * * @param name the name of the constructor. - * @param desc a description of the attribute. + * @param desc a description of the constructor. * @param sig the signature of the constructor, as a series * of [EMAIL PROTECTED] MBeanParameterInfo} objects, one for * each parameter. @@ -104,7 +105,10 @@ public class MBeanConstructorInfo if (sig == null) signature = new MBeanParameterInfo[0]; else - signature = sig; + { + signature = new MBeanParameterInfo[sig.length]; + System.arraycopy(sig, 0, signature, 0, sig.length); + } } /** Index: javax/management/MBeanInfo.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/management/MBeanInfo.java,v retrieving revision 1.4 diff -u -3 -p -u -r1.4 MBeanInfo.java --- javax/management/MBeanInfo.java 29 Jul 2006 21:44:53 -0000 1.4 +++ javax/management/MBeanInfo.java 2 Aug 2006 21:28:35 -0000 @@ -140,7 +140,8 @@ public class MBeanInfo * can be loaded by the MBean server or class loader; it merely * has to be a syntactically correct class name. Any of the * arrays may be <code>null</code>; this will be treated as if - * an empty array was supplied. + * an empty array was supplied. A copy of the arrays is + * taken, so later changes have no effect. * * @param name the name of the class this instance describes. * @param desc a description of the bean. @@ -162,19 +163,31 @@ public class MBeanInfo if (attribs == null) attributes = new MBeanAttributeInfo[0]; else - attributes = attribs; + { + attributes = new MBeanAttributeInfo[attribs.length]; + System.arraycopy(attribs, 0, attributes, 0, attribs.length); + } if (cons == null) constructors = new MBeanConstructorInfo[0]; else - constructors = cons; + { + constructors = new MBeanConstructorInfo[cons.length]; + System.arraycopy(cons, 0, constructors, 0, cons.length); + } if (ops == null) operations = new MBeanOperationInfo[0]; else - operations = ops; + { + operations = new MBeanOperationInfo[ops.length]; + System.arraycopy(ops, 0, operations, 0, ops.length); + } if (notifs == null) notifications = new MBeanNotificationInfo[0]; else - notifications = notifs; + { + notifications = new MBeanNotificationInfo[notifs.length]; + System.arraycopy(notifs, 0, notifications, 0, notifs.length); + } } /** Index: javax/management/MBeanOperationInfo.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/management/MBeanOperationInfo.java,v retrieving revision 1.2 diff -u -3 -p -u -r1.2 MBeanOperationInfo.java --- javax/management/MBeanOperationInfo.java 29 Jul 2006 21:44:53 -0000 1.2 +++ javax/management/MBeanOperationInfo.java 2 Aug 2006 21:28:35 -0000 @@ -140,7 +140,8 @@ public class MBeanOperationInfo * Constructs a @link{MBeanOperationInfo} with the specified name, * description, parameter information, return type and impact. A * <code>null</code> value for the parameter information is the same - * as passing in an empty array. + * as passing in an empty array. A copy of the parameter array is + * taken, so later changes have no effect. * * @param name the name of the constructor. * @param desc a description of the attribute. @@ -158,7 +159,10 @@ public class MBeanOperationInfo if (sig == null) signature = new MBeanParameterInfo[0]; else - signature = sig; + { + signature = new MBeanParameterInfo[sig.length]; + System.arraycopy(sig, 0, signature, 0, sig.length); + } this.type = type; this.impact = impact; } Index: javax/management/openmbean/OpenMBeanAttributeInfoSupport.java =================================================================== RCS file: javax/management/openmbean/OpenMBeanAttributeInfoSupport.java diff -N javax/management/openmbean/OpenMBeanAttributeInfoSupport.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ javax/management/openmbean/OpenMBeanAttributeInfoSupport.java 2 Aug 2006 21:28:35 -0000 @@ -0,0 +1,546 @@ +/* OpenMBeanAttributeInfoSupport.java -- Open typed info about an attribute. + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.management.openmbean; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import javax.management.MBeanAttributeInfo; + +/** + * Describes an attribute of an open management bean. + * + * @author Andrew John Hughes ([EMAIL PROTECTED]) + * @since 1.5 + */ +public class OpenMBeanAttributeInfoSupport + extends MBeanAttributeInfo + implements OpenMBeanAttributeInfo +{ + + /** + * Compatible with JDK 1.5 + */ + private static final long serialVersionUID = -4867215622149721849L; + + /** + * The open type of the attribute. + */ + private OpenType openType; + + /** + * The default value of the attribute (may be <code>null</code>). + */ + private Object defaultValue; + + /** + * The possible legal values of the attribute (may be <code>null</code>). + */ + private Set legalValues; + + /** + * The minimum value of the attribute (may be <code>null</code>). + */ + private Comparable minValue; + + /** + * The maximum value of the attribute (may be <code>null</code>). + */ + private Comparable maxValue; + + /** + * The hash code of this instance. + */ + private transient Integer hashCode; + + /** + * The <code>toString()</code> result of this instance. + */ + private transient String string; + + /** + * Constructs a new [EMAIL PROTECTED] OpenMBeanAttributeInfo} using the + * specified name, description, open type and access properties. + * The name, description and open type may not be <code>null</code> + * and the name and description may not be equal to the empty + * string. + * + * @param name the name of the attribute. + * @param desc a description of the attribute. + * @param type the open type of the attribute. + * @param isReadable true if the attribute's value can be read. + * @param isWritable true if the attribute's value can be changed. + * @param isIs true if the attribute uses an accessor of the form isXXX. + * @throws IllegalArgumentException if the name, description or + * open type are <code>null</code> + * or the name or description are + * the empty string. + */ + public OpenMBeanAttributeInfoSupport(String name, String desc, OpenType type, + boolean isReadable, boolean isWritable, + boolean isIs) + { + super(name, type == null ? null : type.getClassName(), desc, isReadable, + isWritable, isIs); + if (name == null) + throw new IllegalArgumentException("The name may not be null."); + if (desc == null) + throw new IllegalArgumentException("The description may not be null."); + if (type == null) + throw new IllegalArgumentException("The type may not be null."); + if (name.length() == 0) + throw new IllegalArgumentException("The name may not be the empty string."); + if (desc.length() == 0) + throw new IllegalArgumentException("The description may not be the " + + "empty string."); + } + + /** + * Constructs a new [EMAIL PROTECTED] OpenMBeanAttributeInfo} using the + * specified name, description, open type and default value. The + * name, description and open type cannot be <code>null</code> and + * the name and description may not be equal to the empty string. + * The default value may be <code>null</code>. If non-null, it must + * be a valid value of the given open type. Default values are not + * applicable to the open types, [EMAIL PROTECTED] ArrayType} and [EMAIL PROTECTED] + * TabularType}. + * + * @param name the name of the attribute. + * @param desc a description of the attribute. + * @param type the open type of the attribute. + * @param isReadable true if the attribute's value can be read. + * @param isWritable true if the attribute's value can be changed. + * @param isIs true if the attribute uses an accessor of the form isXXX. + * @param defaultValue the default value of the attribute. + * @throws IllegalArgumentException if the name, description or + * open type are <code>null</code> + * or the name or description are + * the empty string. + * @throws OpenDataException if <code>defaultValue<code> is non-null + * and is either not a value of the given + * open type or the open type is an instance + * of [EMAIL PROTECTED] ArrayType} or [EMAIL PROTECTED] TabularType}. + */ + public OpenMBeanAttributeInfoSupport(String name, String desc, OpenType type, + boolean isReadable, boolean isWritable, + boolean isIs, Object defaultValue) + throws OpenDataException + { + this(name, desc, type, isReadable, isWritable, isIs, defaultValue, null); + } + + /** + * <p> + * Constructs a new [EMAIL PROTECTED] OpenMBeanAttributeInfo} using the + * specified name, description, open type, access properties, + * default, maximum and minimum values. The name, description + * and open type cannot be <code>null</code> and the name and + * description may not be equal to the empty string. The + * default, maximum and minimum values may be <code>null</code>. + * The following conditions apply when the attributes mentioned + * are non-null: + * </p> + * <ul> + * <li>The values must be valid values for the given open type.</li> + * <li>Default values are not applicable to the open types, [EMAIL PROTECTED] + * ArrayType} and [EMAIL PROTECTED] TabularType}.</li> + * <li>The minimum value must be smaller than or equal to the maximum value + * (literally, <code>minValue.compareTo(maxValue) <= 0</code>.</li> + * <li>The minimum value must be smaller than or equal to the default value + * (literally, <code>minValue.compareTo(defaultValue) <= 0</code>.</li> + * <li>The default value must be smaller than or equal to the maximum value + * (literally, <code>defaultValue.compareTo(maxValue) <= 0</code>.</li> + * </ul> + * + * @param name the name of the attribute. + * @param desc a description of the attribute. + * @param type the open type of the attribute. + * @param isReadable true if the attribute's value can be read. + * @param isWritable true if the attribute's value can be changed. + * @param isIs true if the attribute uses an accessor of the form isXXX. + * @param defaultValue the default value of the attribute, or <code>null</code>. + * @param minimumValue the minimum value of the attribute, or <code>null</code>. + * @param maximumValue the maximum value of the attribute, or <code>null</code>. + * @throws IllegalArgumentException if the name, description or + * open type are <code>null</code> + * or the name or description are + * the empty string. + * @throws OpenDataException if any condition in the list above is broken. + */ + public OpenMBeanAttributeInfoSupport(String name, String desc, OpenType type, + boolean isReadable, boolean isWritable, + boolean isIs, Object defaultValue, + Comparable minimumValue, + Comparable maximumValue) + throws OpenDataException + { + this(name, desc, type, isReadable, isWritable, isIs); + if (defaultValue != null && !(type.isValue(defaultValue))) + throw new OpenDataException("The default value is not a member of the " + + "open type given."); + if (minimumValue != null && !(type.isValue(minimumValue))) + throw new OpenDataException("The minimum value is not a member of the " + + "open type given."); + if (maximumValue != null && !(type.isValue(maximumValue))) + throw new OpenDataException("The maximum value is not a member of the " + + "open type given."); + if (defaultValue != null && (type instanceof ArrayType || + type instanceof TabularType)) + throw new OpenDataException("Default values are not applicable for " + + "array or tabular types."); + if (minValue != null && maxValue != null + && minValue.compareTo(maxValue) > 0) + throw new OpenDataException("The minimum value is greater than the " + + "maximum."); + if (minValue != null && defaultValue != null + && minValue.compareTo(defaultValue) > 0) + throw new OpenDataException("The minimum value is greater than the " + + "default."); + if (defaultValue != null && maxValue != null + && maxValue.compareTo(defaultValue) < 0) + throw new OpenDataException("The default value is greater than the " + + "maximum."); + + openType = type; + this.defaultValue = defaultValue; + minValue = minimumValue; + maxValue = maximumValue; + } + + /** + * <p> + * Constructs a new [EMAIL PROTECTED] OpenMBeanAttributeInfo} using the + * specified name, description, open type, access properties, default + * value and set of legal values. The name, description and open type + * cannot be <code>null</code> and the name and description may not be + * equal to the empty string. The default, maximum and minimum values + * may be <code>null</code>. The following conditions apply when the + * attributes mentioned are non-null: + * </p> + * <ul> + * <li>The default value and each of the legal values must be a valid + * value for the given open type.</li> + * <li>Default and legal values are not applicable to the open types, [EMAIL PROTECTED] + * ArrayType} and [EMAIL PROTECTED] TabularType}.</li> + * <li>The default value is not in the set of legal values.</li> + * </ul> + * <p> + * The legal values are copied from the array into a unmodifiable set, + * so future modifications to the array have no effect. + * </p> + * + * @param name the name of the attribute. + * @param desc a description of the attribute. + * @param type the open type of the attribute. + * @param isReadable true if the attribute's value can be read. + * @param isWritable true if the attribute's value can be changed. + * @param isIs true if the attribute uses an accessor of the form isXXX. + * @param defaultValue the default value of the attribute, or <code>null</code>. + * @param legalValues the legal values of the attribute. May be + * <code>null</code> or an empty array. + * @throws IllegalArgumentException if the name, description or + * open type are <code>null</code> + * or the name or description are + * the empty string. + * @throws OpenDataException if any condition in the list above is broken. + */ + public OpenMBeanAttributeInfoSupport(String name, String desc, OpenType type, + boolean isReadable, boolean isWritable, + boolean isIs, Object defaultValue, + Object[] legalValues) + throws OpenDataException + { + this(name, desc, type, isReadable, isWritable, isIs); + if (defaultValue != null && !(type.isValue(defaultValue))) + throw new OpenDataException("The default value is not a member of the " + + "open type given."); + if (defaultValue != null && (type instanceof ArrayType || + type instanceof TabularType)) + throw new OpenDataException("Default values are not applicable for " + + "array or tabular types."); + if (legalValues != null && (type instanceof ArrayType || + type instanceof TabularType)) + throw new OpenDataException("Legal values are not applicable for " + + "array or tabular types."); + if (legalValues != null && legalValues.length > 0) + { + Set lv = new HashSet(legalValues.length); + for (int a = 0; a < legalValues.length; ++a) + { + if (legalValues[a] != null && + !(type.isValue(legalValues[a]))) + throw new OpenDataException("The legal value, " + + legalValues[a] + + "is not a member of the " + + "open type given."); + lv.add(legalValues[a]); + } + if (defaultValue != null && !(lv.contains(defaultValue))) + throw new OpenDataException("The default value is not in the set " + + "of legal values."); + this.legalValues = Collections.unmodifiableSet(lv); + } + openType = type; + this.defaultValue = defaultValue; + } + + /** + * Compares this attribute with the supplied object. This returns + * true iff the object is an instance of [EMAIL PROTECTED] OpenMBeanAttributeInfo} + * with an equal name and open type and the same default, minimum, + * maximum and legal values and the same access properties. + * + * @param obj the object to compare. + * @return true if the object is a [EMAIL PROTECTED] OpenMBeanAttributeInfo} + * instance, + * <code>name.equals(object.getName())</code>, + * <code>openType.equals(object.getOpenType())</code>, + * <code>isRead == object.isReadable()</code>, + * <code>isWrite == object.isWritable()</code>, + * <code>isIs == object.isIs()</code>, + * <code>defaultValue.equals(object.getDefaultValue())</code>, + * <code>minValue.equals(object.getMinValue())</code>, + * <code>maxValue.equals(object.getMaxValue())</code>, + * and <code>legalValues.equals(object.getLegalValues())</code>. + */ + public boolean equals(Object obj) + { + if (!(obj instanceof OpenMBeanAttributeInfo)) + return false; + OpenMBeanAttributeInfo o = (OpenMBeanAttributeInfo) obj; + return getName().equals(o.getName()) && + openType.equals(o.getOpenType()) && + isReadable() == o.isReadable() && + isWritable() == o.isWritable() && + isIs() == o.isIs() && + (defaultValue == null ? o.getDefaultValue() == null : + defaultValue.equals(o.getDefaultValue())) && + (minValue == null ? o.getMinValue() == null : + minValue.equals(o.getMinValue())) && + (maxValue == null ? o.getMaxValue() == null : + maxValue.equals(o.getMaxValue())) && + (legalValues == null ? o.getLegalValues() == null : + legalValues.equals(o.getLegalValues())); + } + + /** + * Returns the default value of this attribute, or <code>null</code> + * if there is no default value. + * + * @return the default value of the attribute, or <code>null</code> + * if there is no default. + */ + public Object getDefaultValue() + { + return defaultValue; + } + + /** + * Returns a [EMAIL PROTECTED] java.util.Set} enumerating the legal values + * of this attribute, or <code>null</code> if no such limited + * set exists for this attribute. + * + * @return a set of legal values, or <code>null</code> if no such + * set exists. + */ + public Set getLegalValues() + { + return legalValues; + } + + /** + * Returns the maximum value of this attribute, or <code>null</code> + * if there is no maximum. + * + * @return the maximum value, or <code>null</code> if none exists. + */ + public Comparable getMaxValue() + { + return maxValue; + } + + /** + * Returns the minimum value of this attribute, or <code>null</code> + * if there is no minimum. + * + * @return the minimum value, or <code>null</code> if none exists. + */ + public Comparable getMinValue() + { + return minValue; + } + + /** + * Returns the open type instance which represents the type of this + * attribute. + * + * @return the open type of this attribute. + */ + public OpenType getOpenType() + { + return openType; + } + + /** + * Returns true if this attribute has a default value + * (i.e. the value is non-null). + * + * @return true if this attribute has a default. + */ + public boolean hasDefaultValue() + { + return defaultValue != null; + } + + /** + * <p> + * Returns the hashcode of the attribute information as the sum of + * the hashcodes of the name, open type, default value, maximum + * value, minimum value and the set of legal values. + * </p> + * <p> + * As instances of this class are immutable, the hash code + * is computed just once for each instance and reused + * throughout its life. + * </p> + * + * @return the hashcode of the attribute information. + */ + public int hashCode() + { + if (hashCode == null) + hashCode = Integer.valueOf(getName().hashCode() + + openType.hashCode() + + Boolean.valueOf(isReadable()).hashCode() + + (2 * + Boolean.valueOf(isWritable()).hashCode()) + + (4 * Boolean.valueOf(isIs()).hashCode()) + + (defaultValue == null ? 0 : + defaultValue.hashCode()) + + (minValue == null ? 0 : + minValue.hashCode()) + + (maxValue == null ? 0 : + maxValue.hashCode()) + + (legalValues == null ? 0 : + legalValues.hashCode())); + return hashCode.intValue(); + } + + /** + * Returns true if there is a set of legal values for this + * attribute (i.e. the value is non-null). + * + * @return true if a set of legal values exists for this + * attribute. + */ + public boolean hasLegalValues() + { + return legalValues != null; + } + + /** + * Returns true if there is a maximum value for this attribute + * (i.e. the value is non-null). + * + * @return true if a maximum value exists for this attribute. + */ + public boolean hasMaxValue() + { + return maxValue != null; + } + + /** + * Returns true if there is a minimum value for this attribute. + * (i.e. the value is non-null). + * + * @return true if a minimum value exists for this attribute. + */ + public boolean hasMinValue() + { + return minValue != null; + } + + /** + * Returns true if the specified object is a valid value for + * this attribute. + * + * @param obj the object to test. + * @return true if <code>obj</code> is a valid value for this + * attribute. + */ + public boolean isValue(Object obj) + { + return openType.isValue(obj); + } + + /** + * <p> + * Returns a textual representation of this instance. This + * is constructed using the class name + * (<code>javax.management.openmbean.OpenMBeanAttributeInfo</code>) + * along with the name, open type, access properties, default, + * minimum, maximum and legal values of the attribute. + * </p> + * <p> + * As instances of this class are immutable, the return value + * is computed just once for each instance and reused + * throughout its life. + * </p> + * + * @return a @link{java.lang.String} instance representing + * the instance in textual form. + */ + public String toString() + { + if (string == null) + string = getClass().getName() + + "[name=" + getName() + + ",openType=" + openType + + ",isReadable=" + isReadable() + + ",isWritable=" + isWritable() + + ",isIs=" + isIs() + + ",defaultValue=" + defaultValue + + ",minValue=" + minValue + + ",maxValue=" + maxValue + + ",legalValues=" + legalValues + + "]"; + return string; + } + +} Index: javax/management/openmbean/OpenMBeanConstructorInfoSupport.java =================================================================== RCS file: javax/management/openmbean/OpenMBeanConstructorInfoSupport.java diff -N javax/management/openmbean/OpenMBeanConstructorInfoSupport.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ javax/management/openmbean/OpenMBeanConstructorInfoSupport.java 2 Aug 2006 21:28:35 -0000 @@ -0,0 +1,174 @@ +/* OpenMBeanConstructorInfoSupport.java -- Open typed info about an constructor. + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.management.openmbean; + +import java.util.Arrays; + +import javax.management.MBeanConstructorInfo; +import javax.management.MBeanParameterInfo; + +/** + * Describes a constructor for an open management bean. + * + * @author Andrew John Hughes ([EMAIL PROTECTED]) + * @since 1.5 + */ +public class OpenMBeanConstructorInfoSupport + extends MBeanConstructorInfo + implements OpenMBeanConstructorInfo +{ + + /** + * Compatible with JDK 1.5 + */ + private static final long serialVersionUID = -4400441579007477003L; + + /** + * The hash code of this instance. + */ + private transient Integer hashCode; + + /** + * The <code>toString()</code> result of this instance. + */ + private transient String string; + + /** + * Constructs a @link{OpenMBeanConstructorInfo} with the specified + * name, description and parameter information. A <code>null</code> + * value for the parameter information is the same as passing in + * an empty array. Neither the name nor the description may be + * null or equal to the empty string. A copy of the parameter array + * is taken, so later changes have no effect. + * + * @param name the name of the constructor. + * @param desc a description of the constructor. + * @param sig the signature of the constructor, as a series + * of [EMAIL PROTECTED] MBeanParameterInfo} objects, one for + * each parameter. + * @throws IllegalArgumentException if the name or description is + * either <code>null</code> + * or the empty string. + * @throws ArrayStoreException if the members of the signature array + * are not assignable to + * [EMAIL PROTECTED] javax.management.MBeanParameterInfo} + */ + public OpenMBeanConstructorInfoSupport(String name, String desc, + OpenMBeanParameterInfo[] sig) + { + super(name, desc, (MBeanParameterInfo[]) sig); + if (name == null) + throw new IllegalArgumentException("The name may not be null."); + if (desc == null) + throw new IllegalArgumentException("The description may not be null."); + if (name.length() == 0) + throw new IllegalArgumentException("The name may not be the empty string."); + if (desc.length() == 0) + throw new IllegalArgumentException("The description may not be the " + + "empty string."); + } + + /** + * Compares this attribute with the supplied object. This returns + * true iff the object is an instance of [EMAIL PROTECTED] OpenMBeanConstructorInfo} + * with an equal name and signature. + * + * @param obj the object to compare. + * @return true if the object is a [EMAIL PROTECTED] OpenMBeanParameterInfo} + * instance, + * <code>name.equals(object.getName())</code>, + * and <code>signature.equals(object.getSignature())</code>. + */ + public boolean equals(Object obj) + { + if (!(obj instanceof OpenMBeanConstructorInfo)) + return false; + OpenMBeanConstructorInfo o = (OpenMBeanConstructorInfo) obj; + return getName().equals(o.getName()) && + getSignature().equals(o.getSignature()); + } + + /** + * <p> + * Returns the hashcode of the constructor information as the sum of + * the hashcodes of the name and signature (calculated by + * <code>java.util.Arrays.asList(signature).hashCode()</code>). + * </p> + * <p> + * As instances of this class are immutable, the return value + * is computed just once for each instance and reused + * throughout its life. + * </p> + * + * @return the hashcode of the constructor information. + */ + public int hashCode() + { + if (hashCode == null) + hashCode = Integer.valueOf(getName().hashCode() + + Arrays.asList(getSignature()).hashCode()); + return hashCode.intValue(); + } + + /** + * <p> + * Returns a textual representation of this instance. This + * is constructed using the class name + * (<code>javax.management.openmbean.OpenMBeanConstructorInfo</code>) + * along with the name and signature. + * </p> + * <p> + * As instances of this class are immutable, the return value + * is computed just once for each instance and reused + * throughout its life. + * </p> + * + * @return a @link{java.lang.String} instance representing + * the instance in textual form. + */ + public String toString() + { + if (string == null) + string = getClass().getName() + + "[name=" + getName() + + ",signature=" + getSignature() + + "]"; + return string; + } + +} Index: javax/management/openmbean/OpenMBeanInfo.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/management/openmbean/OpenMBeanInfo.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 OpenMBeanInfo.java --- javax/management/openmbean/OpenMBeanInfo.java 1 Aug 2006 19:28:26 -0000 1.1 +++ javax/management/openmbean/OpenMBeanInfo.java 2 Aug 2006 21:28:35 -0000 @@ -61,11 +61,11 @@ public interface OpenMBeanInfo /** * Compares this attribute with the supplied object. This returns - * true iff the object is an instance of [EMAIL PROTECTED] OpenMBeanOperationInfo} + * true iff the object is an instance of [EMAIL PROTECTED] OpenMBeanInfo} * with the same class name and equal instances of the info classes. * * @param obj the object to compare. - * @return true if the object is a [EMAIL PROTECTED] OpenMBeanParameterInfo} + * @return true if the object is a [EMAIL PROTECTED] OpenMBeanInfo} * instance, * <code>className.equals(object.getClassName())</code> * and each info class has an equal in the other object. Index: javax/management/openmbean/OpenMBeanInfoSupport.java =================================================================== RCS file: javax/management/openmbean/OpenMBeanInfoSupport.java diff -N javax/management/openmbean/OpenMBeanInfoSupport.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ javax/management/openmbean/OpenMBeanInfoSupport.java 2 Aug 2006 21:28:35 -0000 @@ -0,0 +1,191 @@ +/* OpenMBeanInfoSupport.java -- Open typed info about a bean. + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.management.openmbean; + +import java.util.Arrays; +import java.util.HashSet; + +import javax.management.MBeanInfo; +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanConstructorInfo; +import javax.management.MBeanNotificationInfo; +import javax.management.MBeanOperationInfo; + +/** + * Describes an open management bean. + * + * @author Andrew John Hughes ([EMAIL PROTECTED]) + * @since 1.5 + */ +public class OpenMBeanInfoSupport + extends MBeanInfo + implements OpenMBeanInfo +{ + + /** + * Compatible with JDK 1.5 + */ + private static final long serialVersionUID = 4349395935420511492L; + + /** + * The hash code of this instance. + */ + private transient Integer hashCode; + + /** + * The <code>toString()</code> result of this instance. + */ + private transient String string; + + /** + * Constructs a new [EMAIL PROTECTED] OpenMBeanInfo} using the supplied + * class name and description with the given attributes, + * operations, constructors and notifications. The class + * name does not have to actually specify a valid class that + * can be loaded by the MBean server or class loader; it merely + * has to be a syntactically correct class name. Any of the + * arrays may be <code>null</code>; this will be treated as if + * an empty array was supplied. A copy of the arrays is + * taken, so later changes have no effect. + * + * @param name the name of the class this instance describes. + * @param desc a description of the bean. + * @param attribs the attribute descriptions for the bean, + * or <code>null</code>. + * @param cons the constructor descriptions for the bean, + * or <code>null</code>. + * @param ops the operation descriptions for the bean, + * or <code>null</code>. + * @param notifs the notification descriptions for the bean, + * or <code>null</code>. + * @throws ArrayStoreException if a members of an array + * is not assignable to the equivalent + * <code>MBeanXXXInfo</code> class. + */ + public OpenMBeanInfoSupport(String name, String desc, + OpenMBeanAttributeInfo[] attribs, + OpenMBeanConstructorInfo[] cons, + OpenMBeanOperationInfo[] ops, + MBeanNotificationInfo[] notifs) + { + super(name, desc, (MBeanAttributeInfo[]) attribs, + (MBeanConstructorInfo[]) cons, + (MBeanOperationInfo[]) ops, + notifs); + } + + /** + * Compares this attribute with the supplied object. This returns + * true iff the object is an instance of [EMAIL PROTECTED] OpenMBeanInfo} + * with the same class name and equal instances of the info classes. + * + * @param obj the object to compare. + * @return true if the object is a [EMAIL PROTECTED] OpenMBeanInfo} + * instance, + * <code>className.equals(object.getClassName())</code> + * and each info class has an equal in the other object. + */ + public boolean equals(Object obj) + { + if (!(obj instanceof OpenMBeanInfo)) + return false; + OpenMBeanInfo o = (OpenMBeanInfo) obj; + return getClassName().equals(o.getClassName()) && + getAttributes().equals(o.getAttributes()) && + getConstructors().equals(o.getConstructors()) && + getNotifications().equals(o.getNotifications()) && + getOperations().equals(o.getOperations()); + } + + /** + * <p> + * Returns the hashcode of the bean information as the sum of the + * hashcodes of the class name and each array (calculated using + * java.util.HashSet(<code>java.util.Arrays.asList(signature)).hashCode()</code>). + * </p> + * <p> + * As instances of this class are immutable, the return value + * is computed just once for each instance and reused + * throughout its life. + * </p> + * + * @return the hashcode of the bean information. + */ + public int hashCode() + { + if (hashCode == null) + hashCode = + Integer.valueOf(getClassName().hashCode() + + new HashSet(Arrays.asList(getAttributes())).hashCode() + + new HashSet(Arrays.asList(getConstructors())).hashCode() + + new HashSet(Arrays.asList(getNotifications())).hashCode() + + new HashSet(Arrays.asList(getOperations())).hashCode()); + return hashCode.intValue(); + } + + /** + * <p> + * Returns a textual representation of this instance. This + * is constructed using the class name + * (<code>javax.management.openmbean.OpenMBeanInfo</code>) + * along with the class name and textual representations + * of each array. + * </p> + * <p> + * As instances of this class are immutable, the return value + * is computed just once for each instance and reused + * throughout its life. + * </p> + * + * @return a @link{java.lang.String} instance representing + * the instance in textual form. + */ + public String toString() + { + if (string == null) + string = getClass().getName() + + "[className=" + getClassName() + + ",attributes=" + getAttributes() + + ",constructors=" + getConstructors() + + ",notifications=" + getNotifications() + + ",operations=" + getOperations() + + "]"; + return string; + } + +} Index: javax/management/openmbean/OpenMBeanOperationInfo.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 OpenMBeanOperationInfo.java --- javax/management/openmbean/OpenMBeanOperationInfo.java 1 Aug 2006 19:28:26 -0000 1.1 +++ javax/management/openmbean/OpenMBeanOperationInfo.java 2 Aug 2006 21:28:35 -0000 @@ -62,7 +62,7 @@ public interface OpenMBeanOperationInfo * instance, * <code>name.equals(object.getName())</code>, * <code>signature.equals(object.getSignature())</code>, - * <code>returnType.equals(object.getOpenReturnType())</code>, + * <code>returnOpenType.equals(object.getReturnOpenType())</code>, * and <code>impact == object.getImpact()</code>. */ boolean equals(Object obj); Index: javax/management/openmbean/OpenMBeanOperationInfoSupport.java =================================================================== RCS file: javax/management/openmbean/OpenMBeanOperationInfoSupport.java diff -N javax/management/openmbean/OpenMBeanOperationInfoSupport.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ javax/management/openmbean/OpenMBeanOperationInfoSupport.java 2 Aug 2006 21:28:35 -0000 @@ -0,0 +1,240 @@ +/* OpenMBeanOperationInfoSupport.java -- Open typed info about an operation. + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.management.openmbean; + +import java.util.Arrays; + +import javax.management.MBeanOperationInfo; +import javax.management.MBeanParameterInfo; + +/** + * Describes a operation for an open management bean. + * + * @author Andrew John Hughes ([EMAIL PROTECTED]) + * @since 1.5 + */ +public class OpenMBeanOperationInfoSupport + extends MBeanOperationInfo + implements OpenMBeanOperationInfo +{ + + /** + * Compatible with JDK 1.5 + */ + private static final long serialVersionUID = 4996859732565369366L; + + /** + * The open type representing the return value. + */ + private OpenType returnOpenType; + + /** + * The hash code of this instance. + */ + private transient Integer hashCode; + + /** + * The <code>toString()</code> result of this instance. + */ + private transient String string; + + /** + * Constructs a @link{OpenMBeanOperationInfo} with the specified name, + * description, parameter information, open return type and impact. A + * <code>null</code> value for the parameter information is the same + * as passing in an empty array. A copy of the parameter array is + * taken, so later changes have no effect. The name and the + * description may not be equal to the empty string, and neither + * the name, description nor the open return type may be + * <code>null</code>. The value of <code>impact</code> must be + * one of the four valid values + * ([EMAIL PROTECTED] javax.management.MBeanOperationInfo#INFO}, + * [EMAIL PROTECTED] javax.management.MBeanOperationInfo#ACTION}, + * [EMAIL PROTECTED] javax.management.MBeanOperationInfo#ACTION_INFO} and + * [EMAIL PROTECTED] javax.management.MBeanOperationInfo#UNKNOWN}). + * + * + * @param name the name of the constructor. + * @param desc a description of the attribute. + * @param sig the signature of the method, as a series + * of [EMAIL PROTECTED] MBeanParameterInfo} objects, one for + * each parameter. + * @param type the open return type of the method. + * @param impact the impact of performing the operation. + * @throws IllegalArgumentException if the name, description or + * open return type is <code>null</code>, + * the name or description are equal to + * the empty string, or the impact factor + * is not one of the values enumerated + * above. + * @throws ArrayStoreException if the members of the signature array + * are not assignable to + * [EMAIL PROTECTED] javax.management.MBeanParameterInfo} + */ + public OpenMBeanOperationInfoSupport(String name, String desc, + OpenMBeanParameterInfo[] sig, + OpenType type, int impact) + { + super(name, desc, (MBeanParameterInfo[]) sig, + type == null ? null : type.getClassName(), impact); + if (name == null) + throw new IllegalArgumentException("The name may not be null."); + if (desc == null) + throw new IllegalArgumentException("The description may not be null."); + if (type == null) + throw new IllegalArgumentException("The type may not be null."); + if (name.length() == 0) + throw new IllegalArgumentException("The name may not be the empty string."); + if (desc.length() == 0) + throw new IllegalArgumentException("The description may not be the " + + "empty string."); + if (impact != ACTION && impact != INFO && + impact != ACTION_INFO && impact != UNKNOWN) + throw new IllegalArgumentException("The impact factor is an invalid value."); + returnOpenType = type; + } + + /** + * Compares this attribute with the supplied object. This returns + * true iff the object is an instance of [EMAIL PROTECTED] OpenMBeanOperationInfo} + * with an equal name, signature, open return type and impact. + * + * @param obj the object to compare. + * @return true if the object is a [EMAIL PROTECTED] OpenMBeanParameterInfo} + * instance, + * <code>name.equals(object.getName())</code>, + * <code>signature.equals(object.getSignature())</code>, + * <code>returnOpenType.equals(object.getReturnOpenType())</code>, + * and <code>impact == object.getImpact()</code>. + */ + public boolean equals(Object obj) + { + if (!(obj instanceof OpenMBeanOperationInfo)) + return false; + OpenMBeanOperationInfo o = (OpenMBeanOperationInfo) obj; + return getName().equals(o.getName()) && + getSignature().equals(o.getSignature()) && + returnOpenType.equals(o.getReturnOpenType()) && + getImpact() == o.getImpact(); + } + + /** + * Returns the open type instance which represents the type of the + * return value. + * + * @return the open type of the return value. + */ + public OpenType getReturnOpenType() + { + return returnOpenType; + } + + /** + * <p> + * Returns the hashcode of the operation information as the sum of + * the hashcodes of the name, open return type, impact and signature + * (calculated by + * <code>java.util.Arrays.asList(signature).hashCode()</code>). + * </p> + * <p> + * As instances of this class are immutable, the return value + * is computed just once for each instance and reused + * throughout its life. + * </p> + * + * @return the hashcode of the operation information. + */ + public int hashCode() + { + if (hashCode == null) + hashCode = Integer.valueOf(getName().hashCode() + + returnOpenType.hashCode() + + Integer.valueOf(getImpact()).hashCode() + + Arrays.asList(getSignature()).hashCode()); + return hashCode.intValue(); + } + + /** + * <p> + * Returns a textual representation of this instance. This + * is constructed using the class name + * (<code>javax.management.openmbean.OpenMBeanOperationInfo</code>) + * along with the name, signature, open return type and impact. + * </p> + * <p> + * As instances of this class are immutable, the return value + * is computed just once for each instance and reused + * throughout its life. + * </p> + * + * @return a @link{java.lang.String} instance representing + * the instance in textual form. + */ + public String toString() + { + if (string == null) + { + String impactString; + switch (getImpact()) + { + case INFO: + impactString = "INFO"; + break; + case ACTION: + impactString = "ACTION"; + break; + case ACTION_INFO: + impactString = "ACTION_INFO"; + break; + case UNKNOWN: + impactString = "UNKNOWN"; + break; + default: + impactString = "ERRONEOUS VALUE"; + } + string = getClass().getName() + + "[name=" + getName() + + ",signature=" + getSignature() + + ",returnOpenType=" + returnOpenType + + ",impact=" + impactString + + "]"; + } + return string; + } + +} Index: javax/management/openmbean/OpenMBeanParameterInfoSupport.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java,v retrieving revision 1.2 diff -u -3 -p -u -r1.2 OpenMBeanParameterInfoSupport.java --- javax/management/openmbean/OpenMBeanParameterInfoSupport.java 1 Aug 2006 23:15:02 -0000 1.2 +++ javax/management/openmbean/OpenMBeanParameterInfoSupport.java 2 Aug 2006 21:28:40 -0000 @@ -265,18 +265,7 @@ public class OpenMBeanParameterInfoSuppo Object defaultValue, Object[] legalValues) throws OpenDataException { - super(name, type == null ? null : type.getClassName(), desc); - if (name == null) - throw new IllegalArgumentException("The name may not be null."); - if (desc == null) - throw new IllegalArgumentException("The description may not be null."); - if (type == null) - throw new IllegalArgumentException("The type may not be null."); - if (name.length() == 0) - throw new IllegalArgumentException("The name may not be the empty string."); - if (desc.length() == 0) - throw new IllegalArgumentException("The description may not be the " + - "empty string."); + this(name, desc, type); if (defaultValue != null && !(type.isValue(defaultValue))) throw new OpenDataException("The default value is not a member of the " + "open type given.");
signature.asc
Description: Digital signature