summaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/management
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/management')
-rw-r--r--libjava/classpath/javax/management/BadAttributeValueExpException.java91
-rw-r--r--libjava/classpath/javax/management/BadBinaryOpValueExpException.java102
-rw-r--r--libjava/classpath/javax/management/BadStringOperationException.java92
-rw-r--r--libjava/classpath/javax/management/InstanceAlreadyExistsException.java76
-rw-r--r--libjava/classpath/javax/management/InstanceNotFoundException.java76
-rw-r--r--libjava/classpath/javax/management/InvalidApplicationException.java92
-rw-r--r--libjava/classpath/javax/management/MBeanAttributeInfo.java13
-rw-r--r--libjava/classpath/javax/management/MBeanConstructorInfo.java25
-rw-r--r--libjava/classpath/javax/management/MBeanFeatureInfo.java2
-rw-r--r--libjava/classpath/javax/management/MBeanInfo.java23
-rw-r--r--libjava/classpath/javax/management/MBeanOperationInfo.java29
-rw-r--r--libjava/classpath/javax/management/MBeanPermission.java562
-rw-r--r--libjava/classpath/javax/management/MBeanRegistration.java95
-rw-r--r--libjava/classpath/javax/management/MBeanRegistrationException.java84
-rw-r--r--libjava/classpath/javax/management/MBeanServer.java1199
-rw-r--r--libjava/classpath/javax/management/MBeanServerBuilder.java102
-rw-r--r--libjava/classpath/javax/management/MBeanServerConnection.java768
-rw-r--r--libjava/classpath/javax/management/MBeanServerDelegate.java308
-rw-r--r--libjava/classpath/javax/management/MBeanServerDelegateMBean.java101
-rw-r--r--libjava/classpath/javax/management/MBeanServerFactory.java413
-rw-r--r--libjava/classpath/javax/management/MBeanServerNotification.java103
-rw-r--r--libjava/classpath/javax/management/MBeanServerPermission.java470
-rw-r--r--libjava/classpath/javax/management/MBeanTrustPermission.java105
-rw-r--r--libjava/classpath/javax/management/MalformedObjectNameException.java76
-rw-r--r--libjava/classpath/javax/management/ObjectInstance.java147
-rw-r--r--libjava/classpath/javax/management/ObjectName.java775
-rw-r--r--libjava/classpath/javax/management/QueryExp.java87
-rw-r--r--libjava/classpath/javax/management/RuntimeErrorException.java115
-rw-r--r--libjava/classpath/javax/management/RuntimeMBeanException.java114
-rw-r--r--libjava/classpath/javax/management/ServiceNotFoundException.java75
-rw-r--r--libjava/classpath/javax/management/StandardMBean.java32
-rw-r--r--libjava/classpath/javax/management/ValueExp.java86
-rw-r--r--libjava/classpath/javax/management/loading/ClassLoaderRepository.java139
-rw-r--r--libjava/classpath/javax/management/openmbean/InvalidOpenTypeException.java76
-rw-r--r--libjava/classpath/javax/management/openmbean/KeyAlreadyExistsException.java77
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfo.java120
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java546
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfo.java112
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java174
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanInfo.java154
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java191
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java154
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java240
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java190
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java511
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenType.java6
-rw-r--r--libjava/classpath/javax/management/openmbean/SimpleType.java2
-rw-r--r--libjava/classpath/javax/management/openmbean/TabularData.java45
-rw-r--r--libjava/classpath/javax/management/openmbean/TabularDataSupport.java652
49 files changed, 9761 insertions, 66 deletions
diff --git a/libjava/classpath/javax/management/BadAttributeValueExpException.java b/libjava/classpath/javax/management/BadAttributeValueExpException.java
new file mode 100644
index 00000000000..fbdf1decad2
--- /dev/null
+++ b/libjava/classpath/javax/management/BadAttributeValueExpException.java
@@ -0,0 +1,91 @@
+/* BadAttributeValueExpException.java -- Thrown by invalid query attributes.
+ 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;
+
+/**
+ * Thrown when the value of an a attribute passed to a query proves to
+ * be invalid. This exception is only used internally by the Java
+ * management API and is not exposed to user code.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class BadAttributeValueExpException
+ extends Exception
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -3105272988410493376L;
+
+ /**
+ * The attribute value that caused the exception.
+ */
+ private Object val;
+
+ /**
+ * Constructs a new <code>BadAttributeValueExpException</code>
+ * using the specified object to represent the invalid value.
+ *
+ * @param val the inappropriate value.
+ */
+ public BadAttributeValueExpException(Object val)
+ {
+ super();
+ this.val = val;
+ }
+
+ /**
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.BadAttributeValueExpException</code>)
+ * and the invalid value.
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ return getClass().getName()
+ + "[val=" + val
+ + "]";
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/BadBinaryOpValueExpException.java b/libjava/classpath/javax/management/BadBinaryOpValueExpException.java
new file mode 100644
index 00000000000..5e1f5dbbed4
--- /dev/null
+++ b/libjava/classpath/javax/management/BadBinaryOpValueExpException.java
@@ -0,0 +1,102 @@
+/* BadBinaryOpValueExpException.java -- Thrown by invalid query expressions.
+ 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;
+
+/**
+ * Thrown when the expression passed to a method for constructing a
+ * query proves to be invalid. This exception is only used internally
+ * by the Java management API and is not exposed to user code.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class BadBinaryOpValueExpException
+ extends Exception
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 5068475589449021227L;
+
+ /**
+ * The value expression that caused the exception.
+ */
+ private ValueExp exp;
+
+ /**
+ * Constructs a new <code>BadBinaryOpValueExpException</code>
+ * using the specified expression to represent the invalid one.
+ *
+ * @param exp the inappropriate value expression.
+ */
+ public BadBinaryOpValueExpException(ValueExp exp)
+ {
+ super();
+ this.exp = exp;
+ }
+
+ /**
+ * Returns the inappropriate value expression associated
+ * with this exception.
+ *
+ * @return the value expression.
+ */
+ public ValueExp getExp()
+ {
+ return exp;
+ }
+
+ /**
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.BadBinaryOpValueExpException</code>)
+ * and the invalid value expression.
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ return getClass().getName()
+ + "[exp=" + exp
+ + "]";
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/BadStringOperationException.java b/libjava/classpath/javax/management/BadStringOperationException.java
new file mode 100644
index 00000000000..8e5949ef791
--- /dev/null
+++ b/libjava/classpath/javax/management/BadStringOperationException.java
@@ -0,0 +1,92 @@
+/* BadStringOperationException.java -- Thrown by invalid query attributes.
+ 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;
+
+/**
+ * Thrown when a string-based operation passed to a query proves to
+ * be invalid. This exception is only used internally by the Java
+ * management API and is not exposed to user code.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class BadStringOperationException
+ extends Exception
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 7802201238441662100L;
+
+ /**
+ * The operation that caused the exception.
+ */
+ private String op;
+
+ /**
+ * Constructs a new <code>BadStringOperationException</code>
+ * using the specified object to represent the invalid string
+ * operation.
+ *
+ * @param op the inappropriate string operation.
+ */
+ public BadStringOperationException(String op)
+ {
+ super();
+ this.op = op;
+ }
+
+ /**
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.BadStringOperationException</code>)
+ * and the invalid string operation.
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ return getClass().getName()
+ + "[op=" + op
+ + "]";
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/InstanceAlreadyExistsException.java b/libjava/classpath/javax/management/InstanceAlreadyExistsException.java
new file mode 100644
index 00000000000..c783208cb49
--- /dev/null
+++ b/libjava/classpath/javax/management/InstanceAlreadyExistsException.java
@@ -0,0 +1,76 @@
+/* InstanceAlreadyExistsException.java -- Thrown by invalid values.
+ 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;
+
+/**
+ * Thrown when an attempt to register a bean is made, and
+ * the bean is already registered.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class InstanceAlreadyExistsException
+ extends OperationsException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 8893743928912733931L;
+
+ /**
+ * Constructs a new <code>InstanceAlreadyExistsException</code>.
+ */
+ public InstanceAlreadyExistsException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>InstanceAlreadyExistsException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public InstanceAlreadyExistsException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/InstanceNotFoundException.java b/libjava/classpath/javax/management/InstanceNotFoundException.java
new file mode 100644
index 00000000000..4d209fc471f
--- /dev/null
+++ b/libjava/classpath/javax/management/InstanceNotFoundException.java
@@ -0,0 +1,76 @@
+/* InstanceNotFoundException.java -- Thrown by invalid values.
+ 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;
+
+/**
+ * Thrown when an attempt to locate a bean is made, and
+ * the bean does not exist in the repository.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class InstanceNotFoundException
+ extends OperationsException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -882579438394773049L;
+
+ /**
+ * Constructs a new <code>InstanceNotFoundException</code>.
+ */
+ public InstanceNotFoundException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>InstanceNotFoundException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public InstanceNotFoundException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/InvalidApplicationException.java b/libjava/classpath/javax/management/InvalidApplicationException.java
new file mode 100644
index 00000000000..0bcf2d6cb0c
--- /dev/null
+++ b/libjava/classpath/javax/management/InvalidApplicationException.java
@@ -0,0 +1,92 @@
+/* InvalidApplicationException.java -- Thrown by invalid query attributes.
+ 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;
+
+/**
+ * Thrown when a query or attribute is applied to a management bean
+ * which is of the wrong class. This exception is only used
+ * internally by the Java management API and is not exposed to user
+ * code.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class InvalidApplicationException
+ extends Exception
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -3048022274675537269L;
+
+ /**
+ * The attribute value that caused the exception.
+ */
+ private Object val;
+
+ /**
+ * Constructs a new <code>InvalidApplicationException</code>
+ * using the specified object to represent the invalid value.
+ *
+ * @param val the inappropriate expression.
+ */
+ public InvalidApplicationException(Object val)
+ {
+ super();
+ this.val = val;
+ }
+
+ /**
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.InvalidApplicationException</code>)
+ * and the invalid expression.
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ return getClass().getName()
+ + "[val=" + val
+ + "]";
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/MBeanAttributeInfo.java b/libjava/classpath/javax/management/MBeanAttributeInfo.java
index bded7e41a07..2d7c100b560 100644
--- a/libjava/classpath/javax/management/MBeanAttributeInfo.java
+++ b/libjava/classpath/javax/management/MBeanAttributeInfo.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.management;
import java.lang.reflect.Method;
+import java.lang.reflect.Type;
/**
* Describes the attributes of a management bean.
@@ -109,13 +110,21 @@ public class MBeanAttributeInfo
"not be null.");
if (getter == null)
{
- attributeType = setter.getParameterTypes()[0].getName();
+ Type t = setter.getGenericParameterTypes()[0];
+ if (t instanceof Class)
+ attributeType = ((Class) t).getName();
+ else
+ attributeType = t.toString();
isRead = false;
is = false;
}
else
{
- attributeType = getter.getReturnType().getName();
+ Type t = getter.getGenericReturnType();
+ if (t instanceof Class)
+ attributeType = ((Class) t).getName();
+ else
+ attributeType = t.toString();
isRead = true;
is = getter.getName().startsWith("is");
}
diff --git a/libjava/classpath/javax/management/MBeanConstructorInfo.java b/libjava/classpath/javax/management/MBeanConstructorInfo.java
index 832a3296d6b..15c8227c246 100644
--- a/libjava/classpath/javax/management/MBeanConstructorInfo.java
+++ b/libjava/classpath/javax/management/MBeanConstructorInfo.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.management;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Type;
import java.util.Arrays;
@@ -77,22 +78,29 @@ public class MBeanConstructorInfo
public MBeanConstructorInfo(String desc, Constructor cons)
{
super(cons.getName(), desc);
- Class[] paramTypes = cons.getParameterTypes();
+ Type[] paramTypes = cons.getGenericParameterTypes();
signature = new MBeanParameterInfo[paramTypes.length];
for (int a = 0; a < paramTypes.length; ++a)
- signature[a] = new MBeanParameterInfo(null,
- paramTypes[a].getName(),
- null);
+ {
+ Type t = paramTypes[a];
+ if (t instanceof Class)
+ signature[a] = new MBeanParameterInfo(null,
+ ((Class) t).getName(),
+ null);
+ else
+ signature[a] = new MBeanParameterInfo(null, t.toString(), null);
+ }
}
/**
* 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 {@link MBeanParameterInfo} objects, one for
* each parameter.
@@ -104,7 +112,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);
+ }
}
/**
diff --git a/libjava/classpath/javax/management/MBeanFeatureInfo.java b/libjava/classpath/javax/management/MBeanFeatureInfo.java
index 4f0243e1894..74a03038740 100644
--- a/libjava/classpath/javax/management/MBeanFeatureInfo.java
+++ b/libjava/classpath/javax/management/MBeanFeatureInfo.java
@@ -79,7 +79,7 @@ public class MBeanFeatureInfo
/**
* The <code>toString()</code> result of this instance.
*/
- protected transient String string;
+ transient String string;
/**
* Constructs a new {@link MBeanFeatureInfo} with the specified
diff --git a/libjava/classpath/javax/management/MBeanInfo.java b/libjava/classpath/javax/management/MBeanInfo.java
index e6f03f0656e..d30de0499aa 100644
--- a/libjava/classpath/javax/management/MBeanInfo.java
+++ b/libjava/classpath/javax/management/MBeanInfo.java
@@ -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);
+ }
}
/**
diff --git a/libjava/classpath/javax/management/MBeanOperationInfo.java b/libjava/classpath/javax/management/MBeanOperationInfo.java
index a2db8d1b064..6495072e627 100644
--- a/libjava/classpath/javax/management/MBeanOperationInfo.java
+++ b/libjava/classpath/javax/management/MBeanOperationInfo.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.management;
import java.lang.reflect.Method;
+import java.lang.reflect.Type;
import java.util.Arrays;
@@ -113,13 +114,23 @@ public class MBeanOperationInfo
public MBeanOperationInfo(String desc, Method method)
{
super(method.getName(), desc);
- Class[] paramTypes = method.getParameterTypes();
+ Type[] paramTypes = method.getGenericParameterTypes();
signature = new MBeanParameterInfo[paramTypes.length];
for (int a = 0; a < paramTypes.length; ++a)
- signature[a] = new MBeanParameterInfo(null,
- paramTypes[a].getName(),
- null);
- type = method.getReturnType().getName();
+ {
+ Type t = paramTypes[a];
+ if (t instanceof Class)
+ signature[a] = new MBeanParameterInfo(null,
+ ((Class) t).getName(),
+ null);
+ else
+ signature[a] = new MBeanParameterInfo(null, t.toString(), null);
+ }
+ Type retType = method.getGenericReturnType();
+ if (retType instanceof Class)
+ type = ((Class) retType).getName();
+ else
+ type = retType.toString();
if (method.getReturnType() == Void.TYPE)
{
if (paramTypes.length == 0)
@@ -140,7 +151,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 +170,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;
}
diff --git a/libjava/classpath/javax/management/MBeanPermission.java b/libjava/classpath/javax/management/MBeanPermission.java
new file mode 100644
index 00000000000..2c8dfbd622d
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanPermission.java
@@ -0,0 +1,562 @@
+/* MBeanPermission.java -- Permissions controlling server access.
+ 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;
+
+import java.security.Permission;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * <p>
+ * Represents the permissions required to perform
+ * operations using the {@link MBeanServer}. As with
+ * all {@link java.security.Permission} objects, an
+ * instance of this class either represents a permission
+ * already held or one that is required to access a
+ * particular service. In the case of {@link MBeanPermission}s,
+ * implication checks are made using an instance of this class
+ * when a user requests an operation from the server, and a
+ * {@link SecurityManager} is in place.
+ * </p>
+ * <p>
+ * An {@link MBeanPermission} consists of four elements,
+ * which all have to match for the permission to be implied.
+ * These are as follows:
+ * </p>
+ * <ol>
+ * <li><strong>The action</strong>. For a required permission,
+ * this is a single value. For a permission held by the user,
+ * this is a list of comma-separated actions (with spaces allowed),
+ * or <code>*</code> (representing all actions). {@link #getActions()}
+ * returns this value.</li>
+ * <li><strong>The class name</strong>. For a required permission,
+ * this is the class name of the bean being accessed, if any. If
+ * a bean isn't involved in this action, the value is <code>null</code>.
+ * For a permission held by the user, it has one of three values:
+ * <ol>
+ * <li>The empty string, implying any class.</li>
+ * <li><code>*</code>, also implying any class.</li>
+ * <li>A class name pattern, which may specify a single class
+ * (e.g. <code>java.lang.Object</code>) or a series of classes
+ * using the wildcard character <code>*</code> (e.g.
+ * <code>javax.swing.*</code>.)</li>
+ * </ol></li>
+ * <li><strong>The member</strong>. For a required permission,
+ * this is the member of the bean being accessed (an attribute
+ * or operation), if any. If a member of the bean isn't involved
+ * in this action, the value is <code>null</code>.
+ * For a permission held by the user, it has one of three values:
+ * <ol>
+ * <li>The empty string, implying any member.</li>
+ * <li><code>*</code>, also implying any member.</li>
+ * <li>The name of a member.</li>
+ * </ol></li>
+ * <li>The object name</strong>. For a required permission,
+ * this is the {@link ObjectName} of the bean being accessed, if
+ * any. If a bean isn't involved in this action, the value is
+ * <code>null</code>. The name may not be a pattern.
+ * For a permission held by the user, it may be the empty
+ * string (allowing everything) or an {@link ObjectName}
+ * pattern.
+ * </li></ol>
+ * {@link #getName()} returns the latter three of these as a
+ * single string:
+ * </p>
+ * <p><code>className#member[objectName]</code></p>
+ * <p>
+ * where <code>""</code> is disallowed, as, although any of
+ * the elements may be omitted, not all of them should be
+ * left out simultaneously. <code>"-"</code> is used to
+ * represent <code>null</code>. When this occurs in a
+ * required permission, anything may match it. When this
+ * forms part of a permission held by the user, it only
+ * matches another <code>null</code> value.
+ * </p>
+ * <p>The list of valid actions is as follows:</p>
+ * <ul>
+ * <li>addNotificationListener</li>
+ * <li>getAttribute</li>
+ * <li>getClassLoader</li>
+ * <li>getClassLoaderFor</li>
+ * <li>getClassLoaderRepository</li>
+ * <li>getDomains</li>
+ * <li>getMBeanInfo</li>
+ * <li>getObjectInstance</li>
+ * <li>instantiate</li>
+ * <li>invoke</li>
+ * <li>isInstanceOf</li>
+ * <li>queryMBeans</li>
+ * <li>queryNames</li>
+ * <li>registerMBean</li>
+ * <li>removeNotificationListener</li>
+ * <li>setAttribute</li>
+ * <li>unregisterMBean</li>
+ * </ul>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanPermission
+ extends Permission
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -2416928705275160661L;
+
+ /**
+ * The list of actions associated with this permission.
+ */
+ private String actions;
+
+ /**
+ * The list of actions as an ordered set.
+ */
+ private transient Set actionSet;
+
+ /**
+ * The set of valid actions.
+ */
+ private static final Set validSet;
+
+ /**
+ * Initialise the set of valid actions.
+ */
+ static
+ {
+ validSet = new HashSet();
+ validSet.add("addNotificationListener");
+ validSet.add("getAttribute");
+ validSet.add("getClassLoader");
+ validSet.add("getClassLoaderFor");
+ validSet.add("getClassLoaderRepository");
+ validSet.add("getDomains");
+ validSet.add("getMBeanInfo");
+ validSet.add("getObjectInstance");
+ validSet.add("instantiate");
+ validSet.add("invoke");
+ validSet.add("isInstanceOf");
+ validSet.add("queryMBeans");
+ validSet.add("queryNames");
+ validSet.add("registerMBean");
+ validSet.add("removeNotificationListener");
+ validSet.add("setAttribute");
+ validSet.add("unregisterMBean");
+ }
+
+ /**
+ * Constructs a new {@link MBeanPermission} with the specified name
+ * and actions. The name is of the form <code>className#member[objectName]</code>,
+ * where each element is optional, but a completely empty or <code>null</code>
+ * name is disallowed. Actions are specified as a comma-separated list
+ * and may also not be empty or <code>null</code>.
+ *
+ * @param name the name of the permission.
+ * @param actions the actions associated with this permission.
+ * @throws IllegalArgumentException if the name or actions are invalid.
+ */
+ public MBeanPermission(String name, String actions)
+ {
+ super(name);
+ if (name == null || name.length() == 0)
+ throw new IllegalArgumentException("The supplied name was null or empty.");
+ if (actions == null || actions.length() == 0)
+ throw new IllegalArgumentException("The supplied action list was null or empty.");
+ this.actions = actions;
+ updateActionSet();
+ }
+
+ /**
+ * Constructs a new {@link MBeanPermission} with the specified class name,
+ * member, object name and actions. The name of the permission is created
+ * using the form <code>className#member[objectName]</code>,
+ * where each element is optional, but an empty or <code>null</code>
+ * name is disallowed. Actions are specified as a comma-separated list
+ * and may also not be empty or <code>null</code>.
+ *
+ * @param className the name of the class to which this permission applies,
+ * or either <code>null</code> or <code>"-"</code> for a
+ * value which may be implied by any class name, but not
+ * imply any class name itself.
+ * @param member the member of the class to which this permission applies,
+ * or either <code>null</code> or <code>"-"</code> for a
+ * value which may be implied by any member, but not
+ * imply any member itself.
+ * @param objectName the {@link ObjectName} to which this permission applies,
+ * or <code>null</code> for a value which may be implied by
+ * any object name, but not imply any object name itself.
+ * @param actions the actions associated with this permission.
+ */
+ public MBeanPermission(String className, String member,
+ ObjectName name, String actions)
+ {
+ this((className == null ? "-" : className) + "#"
+ + (member == null ? "-" : member) + "["
+ + (name == null ? "-" : name.toString()) + "]", actions);
+ }
+
+ /**
+ * Returns true if the given object is also an {@link MBeanPermission}
+ * with the same name and actions.
+ *
+ * @param obj the object to test.
+ * @return true if the object is an {@link MBeanPermission} with
+ * the same name and actions.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof MBeanPermission)
+ {
+ MBeanPermission p = (MBeanPermission) obj;
+ return (p.getName().equals(getName()) &&
+ p.getActions().equals(actions));
+ }
+ return false;
+ }
+
+ /**
+ * Returns the list of actions in alphabetical order.
+ *
+ * @return the list of actions.
+ */
+ public String getActions()
+ {
+ Iterator it = actionSet.iterator();
+ StringBuilder builder = new StringBuilder();
+ while (it.hasNext())
+ {
+ builder.append(it.next());
+ if (it.hasNext())
+ builder.append(",");
+ }
+ return builder.toString();
+ }
+
+ /**
+ * Returns the hashcode of the permission as the sum
+ * of the hashcodes of the name and actions.
+ *
+ * @return the hashcode of the permission.
+ */
+ public int hashCode()
+ {
+ return getName().hashCode() + actions.hashCode();
+ }
+
+ /**
+ * <p>
+ * Returns true if this permission implies the supplied permission.
+ * This happens if the following holds:
+ * </p>
+ * <ul>
+ * <li>The supplied permission is an {@link MBeanPermission}</li>
+ * <li>The supplied permission has either a <code>null</code> classname
+ * or its classname matches the classname of this permission. A
+ * classname of <code>"*"</code> for this permission always matches
+ * the classname of the supplied permission. Generally, <code>'*'</code>
+ * acts as a wildcard, so <code>".*"</code> matches <code>'.'</code>
+ * followed by anything.</li>
+ * <li>The supplied permission has either a <code>null</code> member
+ * or its member matches the member of this permission. A member of
+ * <code>"*"</code> for this permission always matches the member
+ * of the supplied permission.</li>
+ * <li>The supplied permission has either a <code>null</code> object name
+ * or its object name matches the object name of this permission. If the
+ * object name of this permission is a pattern, {@link ObjectName#apply(ObjectName)}
+ * may be used as well.</li>
+ * <li>The supplied permission's actions are a subset of the actions
+ * of this permission. If the <code>queryMBeans</code> action is presented,
+ * the <code>queryNames</code> action is implied.</li>
+ * </ul>
+ *
+ * @param p the permission to check that this permission implies.
+ * @return true if this permission implies <code>p</code>.
+ */
+ public boolean implies(Permission p)
+ {
+ if (p instanceof MBeanPermission)
+ {
+ MBeanPermission mp = (MBeanPermission) p;
+ NameHolder pName = new NameHolder(mp.getName());
+ NameHolder name = new NameHolder(getName());
+ if (!(name.equals(pName)))
+ return false;
+ Iterator i = mp.getActionSet().iterator();
+ while (i.hasNext())
+ {
+ String nextAction = (String) i.next();
+ boolean found = actions.contains(nextAction);
+ if (!found)
+ if (nextAction.equals("queryNames"))
+ found = actions.contains("queryMBeans");
+ if (!found)
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Small helper class to handle deconstruction of the name.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ */
+ private class NameHolder
+ {
+
+ /**
+ * The class name.
+ */
+ private String className;
+
+ /**
+ * The member.
+ */
+ private String member;
+
+ /**
+ * The object name.
+ */
+ private ObjectName objectName;
+
+ /**
+ * Constructs a broken-down name from a given name.
+ *
+ * @param name the name to break down.
+ */
+ public NameHolder(String name)
+ {
+ String objectName = null;
+ int memberIndex = name.indexOf("#");
+ int onIndex = name.indexOf("[");
+ if (onIndex == -1)
+ {
+ if (memberIndex == -1)
+ className = name;
+ else
+ {
+ className = name.substring(0, memberIndex);
+ member = name.substring(memberIndex + 1);
+ }
+ }
+ else
+ {
+ if (memberIndex == -1)
+ {
+ className = name.substring(0, onIndex);
+ objectName = name.substring(onIndex + 1,
+ name.length() - 1);
+ }
+ else
+ {
+ className = name.substring(0, memberIndex);
+ member = name.substring(memberIndex + 1, onIndex);
+ objectName = name.substring(onIndex + 1,
+ name.length() - 1);
+ }
+ }
+ if (className.equals("-"))
+ className = null;
+ if (member.equals("-"))
+ member = null;
+ if (objectName == null || objectName.equals("-"))
+ this.objectName = null;
+ else
+ try
+ {
+ this.objectName = new ObjectName(objectName);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw (Error)
+ (new InternalError("Invalid object name.").initCause(e));
+ }
+ }
+
+ /**
+ * <p>
+ * Returns true if the supplied object is also a
+ * {@link NameHolder} and the following holds:
+ * </p>
+ * <ul>
+ * <li>The supplied classname is <code>null</code> or the two match. A
+ * classname of <code>"*"</code> for this holder always matches
+ * the classname of the supplied holder. Generally, <code>'*'</code>
+ * acts as a wildcard, so <code>".*"</code> matches <code>'.'</code>
+ * followed by anything.</li>
+ * <li>The supplied name holder has either a <code>null</code> member
+ * or its member matches the member of this name holder. A member of
+ * <code>"*"</code> for this name holder always matches the member
+ * of the supplied name holder.</li>
+ * <li>The supplied name holder has either a <code>null</code> object name
+ * or its object name matches the object name of this name holder. If the
+ * object name of this name holder is a pattern,
+ * {@link ObjectName#apply(ObjectName)} may be used as well.</li>
+ * </ul>
+ *
+ * @param obj the object to compare with this.
+ * @return true if the above holds.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof NameHolder)
+ {
+ NameHolder nh = (NameHolder) obj;
+ boolean cn = false;
+ String ocn = nh.getClassName();
+ if (ocn == null || className.equals("*"))
+ cn = true;
+ else
+ {
+ int wcIndex = className.indexOf("*");
+ if (wcIndex != -1)
+ cn = ocn.startsWith(className.substring(0, wcIndex));
+ else
+ cn = ocn.equals(className);
+ }
+ boolean m = false;
+ String om = nh.getMember();
+ if (om == null || member.equals("*"))
+ m = true;
+ else
+ m = om.equals(member);
+ boolean on = false;
+ ObjectName oon = nh.getObjectName();
+ if (oon == null)
+ on = true;
+ else if (objectName.isPattern())
+ on = objectName.apply(oon);
+ else
+ on = oon.equals(objectName);
+ return (cn && m && on);
+ }
+ return false;
+ }
+
+ /**
+ * Returns the class name.
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Returns the member.
+ */
+ public String getMember()
+ {
+ return member;
+ }
+
+ /**
+ * Returns the object name.
+ */
+ public ObjectName getObjectName()
+ {
+ return objectName;
+ }
+ }
+
+ /**
+ * Returns the set of actions.
+ *
+ * @return the actions as an ordered set.
+ */
+ Set getActionSet()
+ {
+ return actionSet;
+ }
+
+ /**
+ * Updates the action set from the current value of
+ * the actions string.
+ */
+ private void updateActionSet()
+ {
+ String[] actionsArray = actions.split(",");
+ actionSet = new TreeSet();
+ for (int a = 0; a < actionsArray.length; ++a)
+ actionSet.add(actionsArray[a].trim());
+ }
+
+ /**
+ * Reads the object from a stream and ensures the incoming
+ * data is valid.
+ *
+ * @param in the input stream.
+ * @throws IOException if an I/O error occurs.
+ * @throws ClassNotFoundException if a class used by the object
+ * can not be found.
+ */
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+ updateActionSet();
+ checkActions();
+ }
+
+ /**
+ * Checks that the actions used in this permission
+ * are from the valid set.
+ *
+ * @throws IllegalArgumentException if the name or actions are invalid.
+ */
+ private void checkActions()
+ {
+ Iterator it = actionSet.iterator();
+ while (it.hasNext())
+ {
+ String action = (String) it.next();
+ if (!(validSet.contains(action)))
+ throw new IllegalArgumentException("Invalid action "
+ + action + " found.");
+ }
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/MBeanRegistration.java b/libjava/classpath/javax/management/MBeanRegistration.java
new file mode 100644
index 00000000000..5a181ca4921
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanRegistration.java
@@ -0,0 +1,95 @@
+/* MBeanRegistration.java -- Interface for beans to hook into registration.
+ 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;
+
+/**
+ * Beans may implement this interface in order to perform
+ * operations immediately prior to or after their registration
+ * or deregistration.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface MBeanRegistration
+{
+
+ /**
+ * This method is called following deregistration of the bean
+ * by the server.
+ */
+ void postDeregister();
+
+ /**
+ * This method is called following both successful and unsuccessful
+ * attempts to register the bean. The supplied boolean value indicates
+ * the result of the attempt relative to this call.
+ *
+ * @param successful true if the registration was successful.
+ */
+ void postRegister(Boolean successful);
+
+ /**
+ * This method is called prior to de-registration, and may throw
+ * an exception.
+ *
+ * @throws Exception if something goes wrong during the bean's pre-deregistration
+ * operation. The server will re-throw this exception
+ * as an {@link MBeanRegistrationException}.
+ */
+ void preDeregister()
+ throws Exception;
+
+ /**
+ * This method is called prior to registration, with a reference to the
+ * server and {@link ObjectName} supplied to the server for registration.
+ * This method may be used to replace this name by one chosen by the bean.
+ * Such behaviour is expected if the supplied name is <code>null</code>,
+ * but may occur in all cases. The method may throw an exception, which
+ * will cause registration to be aborted.
+ *
+ * @param server the server with which the bean is being registered.
+ * @param name the name the server was supplied with for registration,
+ * which may be <code>null</code>.
+ * @throws Exception if something goes wrong during the bean's pre-registration
+ * operation. The server will re-throw this exception
+ * as an {@link MBeanRegistrationException}.
+ */
+ ObjectName preRegister(MBeanServer server, ObjectName name)
+ throws Exception;
+
+}
diff --git a/libjava/classpath/javax/management/MBeanRegistrationException.java b/libjava/classpath/javax/management/MBeanRegistrationException.java
new file mode 100644
index 00000000000..9f62b9aa04f
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanRegistrationException.java
@@ -0,0 +1,84 @@
+/* MBeanRegistrationException.java -- A bean registration exception.
+ 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;
+
+/**
+ * Represents an arbitrary exception thrown during registration of a
+ * management bean. When registering a bean causes an exception to be
+ * thrown, the resulting exception is wrapped inside an {@link
+ * MBeanRegistrationException}. Calling {@link getTargetException()}
+ * will return the wrapped exception.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanRegistrationException
+ extends MBeanException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 4482382455277067805L;
+
+ /**
+ * Constructs a new <code>MBeanRegistrationException</code> wrapping
+ * the specified exception.
+ *
+ * @param e the exception to be wrapped.
+ */
+ public MBeanRegistrationException(Exception e)
+ {
+ super(e);
+ }
+
+ /**
+ * Constructs a new <code>MBeanRegistrationException</code> wrapping
+ * the specified exception and using the supplied message.
+ *
+ * @param e the exception to be wrapped.
+ * @param message the error message to give to the user.
+ */
+ public MBeanRegistrationException(Exception e, String message)
+ {
+ super(e, message);
+ }
+
+
+}
+
diff --git a/libjava/classpath/javax/management/MBeanServer.java b/libjava/classpath/javax/management/MBeanServer.java
new file mode 100644
index 00000000000..73a28e3b85a
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanServer.java
@@ -0,0 +1,1199 @@
+/* MBeanServer.java -- Represents a management server.
+ 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;
+
+import java.io.ObjectInputStream;
+
+import java.util.Set;
+
+import javax.management.loading.ClassLoaderRepository;
+
+/**
+ * <p>
+ * This interface represents a server for management beans,
+ * providing facilities for the creation, registration and
+ * removal of such beans. This interface is central to the
+ * Java management architecture. Users do not usually implement
+ * this class. Instead, implementations of this class
+ * may be obtained using an {@link MBeanServerFactory}.
+ * </p>
+ * <p>
+ * Registering a bean with the server makes its attributes and
+ * operations accessible via the server. Only JMX compliant
+ * beans may be registered with the server. When a bean
+ * is registered or unregistered, an {@link MBeanServerNotification}
+ * is emitted by the server's {@link MBeanServerDelegate}.
+ * Listeners may be registered with this bean in order to
+ * obtain such notifications. It has the {@link ObjectName}
+ * <code>JMImplementation:type=MBeanServerDelegate</code>.
+ * </p>
+ * <p>
+ * Security checks are applied on the methods of the server,
+ * as detailed below, if it is obtained using the
+ * {@link MBeanServerFactory#createMBeanServer()} or
+ * {@link MBeanServerFactory#newMBeanServer()} methods and
+ * {@link System.getSecurityManager()} returns a non-<code>null</code>
+ * value. If a check fails, a {@link SecurityException}
+ * is thrown. Note than the class name used in the exception
+ * is that of the bean, and thus, as a result, an
+ * {@link InstanceNotFoundException}
+ * precludes these security checks, due to the class name
+ * that would be used in the exception being unavailable.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface MBeanServer
+ extends MBeanServerConnection
+{
+
+ /**
+ * Registers the supplied listener with the specified management
+ * bean. Notifications emitted by the management bean are forwarded
+ * to the listener via the server, which will convert any MBean
+ * references in the source to portable {@link ObjectName}
+ * instances. The notification is otherwise unchanged.
+ *
+ * @param name the name of the management bean with which the listener
+ * should be registered.
+ * @param listener the listener which will handle notifications from
+ * the bean.
+ * @param filter the filter to apply to incoming notifications, or
+ * <code>null</code> if no filtering should be applied.
+ * @param passback an object to be passed to the listener when a
+ * notification is emitted.
+ * @throws InstanceNotFoundException if the name of the management bean
+ * could not be resolved.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "addNotificationListener")</code>}.
+ * @see #removeNotificationListener(ObjectName, NotificationListener)
+ * @see #removeNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationBroadcaster#addNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void addNotificationListener(ObjectName name, NotificationListener listener,
+ NotificationFilter filter, Object passback)
+ throws InstanceNotFoundException;
+
+ /**
+ * <p>
+ * Registers the supplied listener with the specified management
+ * bean. Notifications emitted by the management bean are forwarded
+ * to the listener via the server, which will convert any MBean
+ * references in the source to portable {@link ObjectName}
+ * instances. The notification is otherwise unchanged.
+ * </p>
+ * <p>
+ * The listener that receives notifications will be the one that is
+ * registered with the given name at the time this method is called.
+ * Even if it later unregisters and ceases to use that name, it will
+ * still receive notifications.
+ * </p>
+ *
+ * @param name the name of the management bean with which the listener
+ * should be registered.
+ * @param listener the name of the listener which will handle
+ * notifications from the bean.
+ * @param filter the filter to apply to incoming notifications, or
+ * <code>null</code> if no filtering should be applied.
+ * @param passback an object to be passed to the listener when a
+ * notification is emitted.
+ * @throws InstanceNotFoundException if the name of the management bean
+ * could not be resolved.
+ * @throws RuntimeOperationsException if the bean associated with the given
+ * object name is not a
+ * {@link NotificationListener}. This
+ * exception wraps an
+ * {@link IllegalArgumentException}.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "addNotificationListener")</code>}.
+ * @see #removeNotificationListener(ObjectName, NotificationListener)
+ * @see #removeNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationBroadcaster#addNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void addNotificationListener(ObjectName name, ObjectName listener,
+ NotificationFilter filter, Object passback)
+ throws InstanceNotFoundException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the default constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * {@link javax.management.loading.ClassLoaderRepository default
+ * loader repository} of the server.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #createMBean(String, ObjectName, Object[], String[])
+ * <code>createMBean(className, name, (Object[]) null,
+ * (String[]) null)</code>} with <code>null</code> parameters
+ * and signature.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply the
+ * use of the <code>instantiate</code>
+ * and <code>registerMBean</code> methods.
+ * @see #createMBean(String, ObjectName, Object[], String[])
+ */
+ ObjectInstance createMBean(String className, ObjectName name)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the given constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * {@link javax.management.loading.ClassLoaderRepository default
+ * loader repository} of the server.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param params the parameters for the bean's constructor.
+ * @param sig the signature of the constructor to use.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply the
+ * use of the <code>instantiate</code>
+ * and <code>registerMBean</code> methods.
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ Object[] params, String[] sig)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the default constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * given class loader. If this argument is <code>null</code>,
+ * then the same class loader as was used to load the server
+ * is used.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #createMBean(String, ObjectName, ObjectName, Object[], String)
+ * <code>createMBean(className, name, loaderName, (Object[]) null,
+ * (String) null)</code>} with <code>null</code> parameters
+ * and signature.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param loaderName the name of the class loader.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws InstanceNotFoundException if the specified class loader is not
+ * registered with the server.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply the
+ * use of the <code>instantiate</code>
+ * and <code>registerMBean</code> methods.
+ * @see #createMBean(String, ObjectName, ObjectName, Object[], String[])
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ ObjectName loaderName)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, InstanceNotFoundException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the given constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * given class loader. If this argument is <code>null</code>,
+ * then the same class loader as was used to load the server
+ * is used.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param loaderName the name of the class loader.
+ * @param params the parameters for the bean's constructor.
+ * @param sig the signature of the constructor to use.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws InstanceNotFoundException if the specified class loader is not
+ * registered with the server.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply the
+ * use of the <code>instantiate</code>
+ * and <code>registerMBean</code> methods.
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ ObjectName loaderName, Object[] params,
+ String[] sig)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, InstanceNotFoundException;
+
+ /**
+ * Deserializes a byte array using the class loader of the specified
+ * management bean as its context.
+ *
+ * @param name the name of the bean whose class loader should be used.
+ * @param data the byte array to be deserialized.
+ * @return the deserialized object stream.
+ * @deprecated {@link #getClassLoaderFor(ObjectName)} should be used
+ * to obtain the class loader of the bean, which can then
+ * be used to perform deserialization in the user's code.
+ * @throws InstanceNotFoundException if the specified bean is not
+ * registered with the server.
+ * @throws OperationsException if any I/O error is thrown by the
+ * deserialization process.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "getClassLoaderFor")</code>
+ */
+ ObjectInputStream deserialize(ObjectName name, byte[] data)
+ throws InstanceNotFoundException, OperationsException;
+
+ /**
+ * Deserializes a byte array using the same class loader for its context
+ * as was used to load the given class. This class loader is obtained by
+ * loading the specified class using the {@link
+ * javax.management.loading.ClassLoaderRepository Class Loader Repository}
+ * and then using the class loader of the resulting {@link Class} instance.
+ *
+ * @param name the name of the class which should be loaded to obtain the
+ * class loader.
+ * @param data the byte array to be deserialized.
+ * @return the deserialized object stream.
+ * @deprecated {@link #getClassLoaderRepository} should be used
+ * to obtain the class loading repository, which can then
+ * be used to obtain the {@link Class} instance and deserialize
+ * the array using its class loader.
+ * @throws OperationsException if any I/O error is thrown by the
+ * deserialization process.
+ * @throws ReflectionException if an error occurs in obtaining the
+ * {@link Class} instance.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null, null,
+ * "getClassLoaderRepository")</code>
+ */
+ ObjectInputStream deserialize(String name, byte[] data)
+ throws OperationsException, ReflectionException;
+
+ /**
+ * Deserializes a byte array using the same class loader for its context
+ * as was used to load the given class. The name of the class loader to
+ * be used is supplied, and may be <code>null</code> if the server's
+ * class loader should be used instead.
+ *
+ * @param name the name of the class which should be loaded to obtain the
+ * class loader.
+ * @param loader the name of the class loader to use, or <code>null</code>
+ * if the class loader of the server should be used.
+ * @param data the byte array to be deserialized.
+ * @return the deserialized object stream.
+ * @deprecated {@link #getClassLoader(ObjectName} can be used to obtain
+ * the named class loader and deserialize the array.
+ * @throws InstanceNotFoundException if the specified class loader is not
+ * registered with the server.
+ * @throws OperationsException if any I/O error is thrown by the
+ * deserialization process.
+ * @throws ReflectionException if an error occurs in obtaining the
+ * {@link Class} instance.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, loader,
+ * "getClassLoader")</code>
+ */
+ ObjectInputStream deserialize(String name, ObjectName loader, byte[] data)
+ throws InstanceNotFoundException, ReflectionException,
+ OperationsException;
+
+ /**
+ * Returns the value of the supplied attribute from the specified
+ * management bean.
+ *
+ * @param bean the bean to retrieve the value from.
+ * @param name the name of the attribute to retrieve.
+ * @return the value of the attribute.
+ * @throws AttributeNotFoundException if the attribute could not be
+ * accessed from the bean.
+ * @throws MBeanException if the management bean's accessor throws
+ * an exception.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception was thrown in trying
+ * to invoke the bean's accessor.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, name, bean,
+ * "getAttribute")</code>}.
+ * @see DynamicMBean#getAttribute(String)
+ */
+ Object getAttribute(ObjectName bean, String name)
+ throws MBeanException, AttributeNotFoundException,
+ InstanceNotFoundException, ReflectionException;
+
+ /**
+ * Returns the values of the named attributes from the specified
+ * management bean.
+ *
+ * @param bean the bean to retrieve the value from.
+ * @param names the names of the attributes to retrieve.
+ * @return the values of the attributes.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception was thrown in trying
+ * to invoke the bean's accessor.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, bean,
+ * "getAttribute")</code>}. Additionally,
+ * for an attribute name, <code>n</code>, the
+ * caller's permission must imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, n, bean,
+ * "getAttribute")</code>} or that attribute will
+ * not be included.
+ *
+ * @see DynamicMBean#getAttributes(String[])
+ */
+ AttributeList getAttributes(ObjectName bean, String[] names)
+ throws InstanceNotFoundException, ReflectionException;
+
+ /**
+ * Returns the specified class loader. If the specified value is
+ * <code>null</code>, then the class loader of the server will be
+ * returned. If <code>l</code> is the requested class loader,
+ * and <code>r</code> is the actual class loader returned, then
+ * either <code>l</code> and <code>r</code> will be identical,
+ * or they will at least return the same class from
+ * {@link ClassLoader#loadClass(String)} for any given string.
+ * They may not be identical due to one or the other
+ * being wrapped in another class loader (e.g. for security).
+ *
+ * @param name the name of the class loader to return.
+ * @return the class loader.
+ * @throws InstanceNotFoundException if the class loader can not
+ * be found.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "getClassLoader")</code>
+ */
+ ClassLoader getClassLoader(ObjectName name)
+ throws InstanceNotFoundException;
+
+ /**
+ * Returns the class loader of the specified management bean. If
+ * <code>l</code> is the requested class loader, and <code>r</code>
+ * is the actual class loader returned, then either <code>l</code>
+ * and <code>r</code> will be identical, or they will at least
+ * return the same class from {@link ClassLoader#loadClass(String)}
+ * for any given string. They may not be identical due to one or
+ * the other being wrapped in another class loader (e.g. for
+ * security).
+ *
+ * @param name the name of the bean whose class loader should be
+ * returned.
+ * @return the class loader.
+ * @throws InstanceNotFoundException if the bean is not registered
+ * with the server.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "getClassLoaderFor")</code>
+ */
+ ClassLoader getClassLoaderFor(ObjectName name)
+ throws InstanceNotFoundException;
+
+ /**
+ * Returns the class loader repository used by this server.
+ *
+ * @return the class loader repository.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null, null,
+ * "getClassLoaderRepository")</code>
+ */
+ ClassLoaderRepository getClassLoaderRepository();
+
+ /**
+ * Returns the default domain this server applies to beans that have
+ * no specified domain.
+ *
+ * @return the default domain.
+ */
+ String getDefaultDomain();
+
+ /**
+ * Returns an array containing all the domains used by beans registered
+ * with this server. The ordering of the array is undefined.
+ *
+ * @return the list of domains.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null, name,
+ * "getDomains")</code>}. Additionally,
+ * for an domain, <code>d</code>, the
+ * caller's permission must imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null,
+ * new ObjectName("d:x=x"), "getDomains")</code>}
+ * or that domain will not be included. Note
+ * that "x=x" is an arbitrary key-value pair
+ * provided to satisfy the constructor.
+ * @see ObjectName#getDomain()
+ */
+ String[] getDomains();
+
+ /**
+ * Returns the number of management beans registered with this server.
+ * This may be less than the real number if the caller's access is
+ * restricted.
+ *
+ * @return the number of registered beans.
+ */
+ Integer getMBeanCount();
+
+ /**
+ * Returns information on the given management bean.
+ *
+ * @param name the name of the management bean.
+ * @return an instance of {@link MBeanInfo} for the bean.
+ * @throws IntrospectionException if an exception occurs in examining
+ * the bean.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception occurs when trying
+ * to invoke {@link DynamicMBean#getMBeanInfo()}
+ * on the bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "getMBeanInfo")</code>}.
+ * @see DynamicMBean#getMBeanInfo()
+ */
+ MBeanInfo getMBeanInfo(ObjectName name)
+ throws InstanceNotFoundException, IntrospectionException,
+ ReflectionException;
+
+ /**
+ * Returns the {@link ObjectInstance} created for the specified
+ * management bean on registration.
+ *
+ * @param name the name of the bean.
+ * @return the corresponding {@link ObjectInstance} instance.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "getObjectInstance")</code>
+ * @see #createMBean(String, ObjectName)
+ */
+ ObjectInstance getObjectInstance(ObjectName name)
+ throws InstanceNotFoundException;
+
+ /**
+ * <p>
+ * Creates an instance of the specified class using the list of
+ * class loaders from the {@link
+ * javax.management.loading.ClassLoaderRepository Class Loader
+ * Repository}. The class should have a public constructor
+ * with no arguments. A reference to the new instance is returned,
+ * but the instance is not yet registered with the server.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #instantiate(String, Object[], String[])
+ * <code>instantiate(name, (Object[]) null, (String[]) null)</code>}
+ * with <code>null</code> parameters and signature.
+ * </p>
+ *
+ * @param name the name of the class of bean to be instantiated.
+ * @return an instance of the given class.
+ * @throws ReflectionException if an exception is thrown during
+ * loading the class or calling the
+ * constructor.
+ * @throws MBeanException if the constructor throws an exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, null,
+ * "instantiate")</code>}.
+ * @see #instantiate(String, Object[], String[])
+ */
+ Object instantiate(String name)
+ throws ReflectionException, MBeanException;
+
+ /**
+ * Creates an instance of the specified class using the list of
+ * class loaders from the {@link
+ * javax.management.loading.ClassLoaderRepository Class Loader
+ * Repository}. The class should have a public constructor
+ * matching the supplied signature. A reference to the new
+ * instance is returned, but the instance is not yet
+ * registered with the server.
+ *
+ * @param name the name of the class of bean to be instantiated.
+ * @param params the parameters for the constructor.
+ * @param sig the signature of the constructor.
+ * @return an instance of the given class.
+ * @throws ReflectionException if an exception is thrown during
+ * loading the class or calling the
+ * constructor.
+ * @throws MBeanException if the constructor throws an exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, null,
+ * "instantiate")</code>}.
+ */
+ Object instantiate(String name, Object[] params, String[] sig)
+ throws ReflectionException, MBeanException;
+
+ /**
+ * <p>
+ * Creates an instance of the specified class using the supplied
+ * class loader. If the class loader given is <code>null</code>,
+ * then the class loader of the server will be used. The class
+ * should have a public constructor with no arguments. A reference
+ * to the new instance is returned, but the instance is not yet
+ * registered with the server.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #instantiate(String, ObjectName, Object[], String[])
+ * <code>instantiate(name, loaderName, (Object[]) null,
+ * (String[]) null)</code>} with <code>null</code> parameters
+ * and signature.
+ * </p>
+ *
+ * @param name the name of the class of bean to be instantiated.
+ * @param loaderName the name of the class loader to use.
+ * @return an instance of the given class.
+ * @throws InstanceNotFoundException if the class loader is not
+ * registered with the server.
+ * @throws ReflectionException if an exception is thrown during
+ * loading the class or calling the
+ * constructor.
+ * @throws MBeanException if the constructor throws an exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, null,
+ * "instantiate")</code>}.
+ * @see #instantiate(String, Object[], String[])
+ */
+ Object instantiate(String name, ObjectName loaderName)
+ throws InstanceNotFoundException, ReflectionException,
+ MBeanException;
+
+ /**
+ * Creates an instance of the specified class using the supplied
+ * class loader. If the class loader given is <code>null</code>,
+ * then the class loader of the server will be used. The class
+ * should have a public constructor matching the supplied
+ * signature. A reference to the new instance is returned,
+ * but the instance is not yet registered with the server.
+ *
+ * @param name the name of the class of bean to be instantiated.
+ * @param loaderName the name of the class loader to use.
+ * @param params the parameters for the constructor.
+ * @param sig the signature of the constructor.
+ * @return an instance of the given class.
+ * @throws InstanceNotFoundException if the class loader is not
+ * registered with the server.
+ * @throws ReflectionException if an exception is thrown during
+ * loading the class or calling the
+ * constructor.
+ * @throws MBeanException if the constructor throws an exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, null,
+ * "instantiate")</code>}.
+ */
+ Object instantiate(String name, ObjectName loaderName,
+ Object[] params, String[] sig)
+ throws InstanceNotFoundException, ReflectionException,
+ MBeanException;
+
+ /**
+ * Invokes the supplied operation on the specified management
+ * bean. The class objects specified in the signature are loaded
+ * using the same class loader as was used for the management bean.
+ *
+ * @param bean the management bean whose operation should be invoked.
+ * @param name the name of the operation to invoke.
+ * @param params the parameters of the operation.
+ * @param sig the signature of the operation.
+ * @return the return value of the method.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws MBeanException if the method invoked throws an exception.
+ * @throws ReflectionException if an exception is thrown in invoking the
+ * method.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, name, bean,
+ * "invoke")</code>}.
+ * @see DynamicMBean#invoke(String, Object[], String[])
+ */
+ Object invoke(ObjectName bean, String name, Object[] params, String[] sig)
+ throws InstanceNotFoundException, MBeanException,
+ ReflectionException;
+
+ /**
+ * <p>
+ * Returns true if the specified management bean is an instance
+ * of the supplied class.
+ * </p>
+ * <p>
+ * A bean, B, is an instance of a class, C, if either of the following
+ * conditions holds:
+ * </p>
+ * <ul>
+ * <li>The class name in B's {@link MBeanInfo} is equal to the supplied
+ * name.</li>
+ * <li>Both the class of B and C were loaded by the same class loader,
+ * and B is assignable to C.</li>
+ * </ul>
+ *
+ * @param name the name of the management bean.
+ * @param className the name of the class to test if <code>name</code> is
+ * an instance of.
+ * @return true if either B is directly an instance of the named class,
+ * or B is assignable to the class, given that both it and B's
+ * current class were loaded using the same class loader.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "isInstanceOf")</code>
+ */
+ boolean isInstanceOf(ObjectName name, String className)
+ throws InstanceNotFoundException;
+
+ /**
+ * Returns true if the specified management bean is registered with
+ * the server.
+ *
+ * @param name the name of the management bean.
+ * @return true if the bean is registered.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean name.
+ */
+ boolean isRegistered(ObjectName name);
+
+ /**
+ * <p>
+ * Returns a set of {@link ObjectInstance}s matching the specified
+ * criteria. The full set of beans registered with the server
+ * are passed through two filters:
+ * </p>
+ * <ol>
+ * <li>Pattern matching is performed using the supplied
+ * {@link ObjectName}.</li>
+ * <li>The supplied query expression is applied.</li>
+ * </ol>
+ * <p>
+ * If both the object name and the query expression are <code>null</code>,
+ * or the object name has no domain and no key properties,
+ * no filtering will be performed and all beans are returned.
+ * </p>
+ *
+ * @param name an {@link ObjectName} to use as a filter.
+ * @param query a query expression to apply to each of the beans that match
+ * the given object name.
+ * @return a set of {@link ObjectInstance}s matching the filtered beans.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null, name,
+ * "queryMBeans")</code>}. Additionally,
+ * for an bean, <code>b</code>, the
+ * caller's permission must imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, b, name,
+ * "queryMBeans")</code>} or that bean will
+ * not be included. Such an exception may also
+ * arise from the execution of the query, in which
+ * case that particular bean will again be excluded.
+ */
+ Set queryMBeans(ObjectName name, QueryExp query);
+
+ /**
+ * <p>
+ * Returns a set of {@link ObjectName}s matching the specified
+ * criteria. The full set of beans registered with the server
+ * are passed through two filters:
+ * </p>
+ * <ol>
+ * <li>Pattern matching is performed using the supplied
+ * {@link ObjectName}.</li>
+ * <li>The supplied query expression is applied.</li>
+ * </ol>
+ * <p>
+ * If both the object name and the query expression are <code>null</code>,
+ * or the object name has no domain and no key properties,
+ * no filtering will be performed and all beans are returned.
+ * </p>
+ *
+ * @param name an {@link ObjectName} to use as a filter.
+ * @param query a query expression to apply to each of the beans that match
+ * the given object name.
+ * @return a set of {@link ObjectName}s matching the filtered beans.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null, name,
+ * "queryNames")</code>}. Additionally,
+ * for an name, <code>n</code>, the
+ * caller's permission must imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, n, name,
+ * "queryNames")</code>} or that name will
+ * not be included. Such an exception may also
+ * arise from the execution of the query, in which
+ * case that particular bean will again be excluded.
+ * Note that these permissions are implied if the
+ * <code>queryMBeans</code> permissions are available.
+ */
+ Set queryNames(ObjectName name, QueryExp query);
+
+ /**
+ * Registers the supplied instance with the server, using the specified
+ * {@link ObjectName}. If the name given is <code>null</code>, then
+ * the bean supplied is expected to implement the {@link MBeanRegistration}
+ * interface and provide the name via the
+ * {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface.
+ *
+ * @param obj the object to register with the server.
+ * @param name the name under which to register the object,
+ * or <code>null</code> if the {@link MBeanRegistration}
+ * interface should be used.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> object.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "registerMBean")</code>}. <code>className</code>
+ * here corresponds to the result of
+ * {@link MBeanInfo#getClassName()} for objects of
+ * this class. If this check succeeds, a check
+ * is also made on its
+ * {@link java.security.ProtectionDomain} to ensure
+ * it implies {@link MBeanTrustPermission(String)
+ * <code>MBeanTrustPermission("register")</code>}.
+ * The use of the {@link MBeanRegistration} interface
+ * results in another {@link MBeanPermission} check
+ * being made on the returned {@link ObjectName}.
+ */
+ ObjectInstance registerMBean(Object obj, ObjectName name)
+ throws InstanceAlreadyExistsException, MBeanRegistrationException,
+ NotCompliantMBeanException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. This includes all
+ * combinations of filters and passback objects registered for
+ * this listener. For more specific removal of listeners, see
+ * {@link #removeNotificationListener(ObjectName,
+ * NotificationListener,NotificationFilter,Object)}
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the listener to remove.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "removeNotificationListener")</code>}.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ * @see NotificationBroadcaster#removeNotificationListener(NotificationListener)
+ */
+ void removeNotificationListener(ObjectName name,
+ NotificationListener listener)
+ throws InstanceNotFoundException, ListenerNotFoundException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. Only the first instance with
+ * the supplied filter and passback object is removed.
+ * <code>null</code> is used as a valid value for these parameters,
+ * rather than as a way to remove all registration instances for
+ * the specified listener; for this behaviour instead, see
+ * {@link #removeNotificationListener(ObjectName, NotificationListener)}.
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the listener to remove.
+ * @param filter the filter of the listener to remove.
+ * @param passback the passback object of the listener to remove.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "removeNotificationListener")</code>}.
+ * @see #addNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationEmitter#removeNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void removeNotificationListener(ObjectName name,
+ NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ throws InstanceNotFoundException, ListenerNotFoundException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. This includes all
+ * combinations of filters and passback objects registered for
+ * this listener. For more specific removal of listeners, see
+ * {@link #removeNotificationListener(ObjectName,
+ * ObjectName,NotificationFilter,Object)}
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the name of the listener to remove.
+ * @throws InstanceNotFoundException if a name doesn't match a registered
+ * bean.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "removeNotificationListener")</code>}.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ * @see NotificationBroadcaster#removeNotificationListener(NotificationListener)
+ */
+ void removeNotificationListener(ObjectName name, ObjectName listener)
+ throws InstanceNotFoundException, ListenerNotFoundException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. Only the first instance with
+ * the supplied filter and passback object is removed.
+ * <code>null</code> is used as a valid value for these parameters,
+ * rather than as a way to remove all registration instances for
+ * the specified listener; for this behaviour instead, see
+ * {@link #removeNotificationListener(ObjectName, ObjectName)}.
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the name of the listener to remove.
+ * @param filter the filter of the listener to remove.
+ * @param passback the passback object of the listener to remove.
+ * @throws InstanceNotFoundException if a name doesn't match a registered
+ * bean.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "removeNotificationListener")</code>}.
+ * @see #addNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationEmitter#removeNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void removeNotificationListener(ObjectName name,
+ ObjectName listener,
+ NotificationFilter filter,
+ Object passback)
+ throws InstanceNotFoundException, ListenerNotFoundException;
+
+ /**
+ * Sets the value of the specified attribute of the supplied
+ * management bean.
+ *
+ * @param name the name of the management bean.
+ * @param attribute the attribute to set.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws AttributeNotFoundException if the attribute does not
+ * correspond to an attribute
+ * of the bean.
+ * @throws InvalidAttributeValueException if the value is invalid
+ * for this particular
+ * attribute of the bean.
+ * @throws MBeanException if setting the attribute causes
+ * the bean to throw an exception (which
+ * becomes the cause of this exception).
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, name, bean,
+ * "setAttribute")</code>}.
+ * @see #getAttribute(ObjectName, String)
+ * @see DynamicMBean#setAttribute(Attribute)
+ */
+ void setAttribute(ObjectName name, Attribute attribute)
+ throws InstanceNotFoundException, AttributeNotFoundException,
+ InvalidAttributeValueException, MBeanException,
+ ReflectionException;
+
+ /**
+ * Sets the value of each of the specified attributes
+ * of the supplied management bean to that specified by
+ * the {@link Attribute} object. The returned list contains
+ * the attributes that were set and their new values.
+ *
+ * @param name the name of the management bean.
+ * @param attributes the attributes to set.
+ * @return a list of the changed attributes.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * list.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, bean,
+ * "setAttribute")</code>}. Additionally,
+ * for an attribute name, <code>n</code>, the
+ * caller's permission must imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, n, bean,
+ * "setAttribute")</code>} or that attribute will
+ * not be included.
+ * @see #getAttributes(ObjectName, String[])
+ * @see DynamicMBean#setAttributes(AttributeList)
+ */
+ AttributeList setAttributes(ObjectName name, AttributeList attributes)
+ throws InstanceNotFoundException, ReflectionException;
+
+ /**
+ * Unregisters the specified management bean. Following this operation,
+ * the bean instance is no longer accessible from the server via this
+ * name. Prior to unregistering the bean, the
+ * {@link MBeanRegistration#preDeregister()} method will be called if
+ * the bean implements the {@link MBeanRegistration} interface.
+ *
+ * @param name the name of the management bean.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preDeregister
+ * method.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean name or a
+ * request being made to unregister the
+ * {@link MBeanServerDelegate} bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "unregisterMBean")</code>}.
+ */
+ void unregisterMBean(ObjectName name)
+ throws InstanceNotFoundException, MBeanRegistrationException;
+
+}
diff --git a/libjava/classpath/javax/management/MBeanServerBuilder.java b/libjava/classpath/javax/management/MBeanServerBuilder.java
new file mode 100644
index 00000000000..4e280682900
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanServerBuilder.java
@@ -0,0 +1,102 @@
+/* MBeanServerBuilder.java -- Creates a default management server.
+ 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;
+
+import gnu.javax.management.Server;
+
+/**
+ * Constructs a default implementation of an {@link MBeanServer}.
+ * The {@link MBeanServerFactory} allows custom implementations of
+ * {@link MBeanServer} to be used by providing subclasses of this.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanServerBuilder
+{
+
+ /**
+ * Constructs a new {@link MBeanServerBuilder}.
+ */
+ public MBeanServerBuilder()
+ {
+ }
+
+ /**
+ * <p>
+ * Creates a new {@link MBeanServer} implementation with the specified
+ * default domain, delegate and outer server. The latter is the server
+ * passed to the {@link MBeanRegistration} interface of management beans,
+ * allowing an {@link MBeanServer} implementation to wrap another in order
+ * to provide additional checks, etc. If this value is <code>null</code>,
+ * <code>this</code> is passed to beans instead.
+ * </p>
+ * <p>
+ * The {@link MBeanServerFactory} calls this method after having first
+ * created a delegate using the {@link #newMBeanServerDelegate()} method.
+ * However, the delegate used in the call to this method may not be the
+ * same as that returned by {@link #newMBeanServerDelegate()} as the factory
+ * can optionally wrap the delegate before calling this method.
+ * </p>
+ *
+ * @param defaultDomain the default domain used by the new server.
+ * @param outer the {@link MBeanServer} passed to the {@link MBeanRegistration}
+ * interface of management beans.
+ * @param delegate the delegate bean associated with the server, which must
+ * be registered as a management bean by the server.
+ * @return a new instance of a server implementation.
+ */
+ public MBeanServer newMBeanServer(String defaultDomain, MBeanServer outer,
+ MBeanServerDelegate delegate)
+ {
+ return new Server(defaultDomain, outer, delegate);
+ }
+
+ /**
+ * Creates a new {@link MBeanServerDelegate}, which will be used by
+ * a management server. The returned delegate may either be used directly
+ * by the server, or may be further wrapped to add additional checks.
+ *
+ * @return a new instance of {@link MBeanServerDelegate}.
+ */
+ public MBeanServerDelegate newMBeanServerDelegate()
+ {
+ return new MBeanServerDelegate();
+ }
+
+}
diff --git a/libjava/classpath/javax/management/MBeanServerConnection.java b/libjava/classpath/javax/management/MBeanServerConnection.java
new file mode 100644
index 00000000000..dff03e8c0d4
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanServerConnection.java
@@ -0,0 +1,768 @@
+/* MBeanServerConnection.java -- Represents a connection to a management server.
+ 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;
+
+import java.io.IOException;
+
+import java.util.Set;
+
+/**
+ * This interface represents a communication mechanism which may
+ * be used to access an MBean server, whether this be local or
+ * remote. The {@link MBeanServer} interface extends this with
+ * additional methods that apply only to local servers.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface MBeanServerConnection
+{
+
+ /**
+ * Registers the supplied listener with the specified management
+ * bean. Notifications emitted by the management bean are forwarded
+ * to the listener via the server, which will convert any MBean
+ * references in the source to portable {@link ObjectName}
+ * instances. The notification is otherwise unchanged.
+ *
+ * @param name the name of the management bean with which the listener
+ * should be registered.
+ * @param listener the listener which will handle notifications from
+ * the bean.
+ * @param filter the filter to apply to incoming notifications, or
+ * <code>null</code> if no filtering should be applied.
+ * @param passback an object to be passed to the listener when a
+ * notification is emitted.
+ * @throws InstanceNotFoundException if the name of the management bean
+ * could not be resolved.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #removeNotificationListener(ObjectName, NotificationListener)
+ * @see #removeNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationBroadcaster#addNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void addNotificationListener(ObjectName name, NotificationListener listener,
+ NotificationFilter filter, Object passback)
+ throws InstanceNotFoundException, IOException;
+
+ /**
+ * <p>
+ * Registers the supplied listener with the specified management
+ * bean. Notifications emitted by the management bean are forwarded
+ * to the listener via the server, which will convert any MBean
+ * references in the source to portable {@link ObjectName}
+ * instances. The notification is otherwise unchanged.
+ * </p>
+ * <p>
+ * The listener that receives notifications will be the one that is
+ * registered with the given name at the time this method is called.
+ * Even if it later unregisters and ceases to use that name, it will
+ * still receive notifications.
+ * </p>
+ *
+ * @param name the name of the management bean with which the listener
+ * should be registered.
+ * @param listener the name of the listener which will handle
+ * notifications from the bean.
+ * @param filter the filter to apply to incoming notifications, or
+ * <code>null</code> if no filtering should be applied.
+ * @param passback an object to be passed to the listener when a
+ * notification is emitted.
+ * @throws InstanceNotFoundException if the name of the management bean
+ * could not be resolved.
+ * @throws RuntimeOperationsException if the bean associated with the given
+ * object name is not a
+ * {@link NotificationListener}. This
+ * exception wraps an
+ * {@link IllegalArgumentException}.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #removeNotificationListener(ObjectName, NotificationListener)
+ * @see #removeNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationBroadcaster#addNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void addNotificationListener(ObjectName name, ObjectName listener,
+ NotificationFilter filter, Object passback)
+ throws InstanceNotFoundException, RuntimeOperationsException, IOException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the default constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * {@link javax.management.loading.ClassLoaderRepository default
+ * loader repository} of the server.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #createMBean(String, ObjectName, Object[], String[])
+ * <code>createMBean(className, name, (Object[]) null,
+ * (String[]) null)</code>} with <code>null</code> parameters
+ * and signature.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #createMBean(String, ObjectName, Object[], String[])
+ */
+ ObjectInstance createMBean(String className, ObjectName name)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, IOException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the given constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * {@link javax.management.loading.ClassLoaderRepository default
+ * loader repository} of the server.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param params the parameters for the bean's constructor.
+ * @param sig the signature of the constructor to use.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ Object[] params, String[] sig)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, IOException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the default constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * given class loader. If this argument is <code>null</code>,
+ * then the same class loader as was used to load the server
+ * is used.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #createMBean(String, ObjectName, ObjectName, Object[], String)
+ * <code>createMBean(className, name, loaderName, (Object[]) null,
+ * (String) null)</code>} with <code>null</code> parameters
+ * and signature.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param loaderName the name of the class loader.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws InstanceNotFoundException if the specified class loader is not
+ * registered with the server.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #createMBean(String, ObjectName, ObjectName, Object[], String[])
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ ObjectName loaderName)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, InstanceNotFoundException,
+ IOException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the given constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * given class loader. If this argument is <code>null</code>,
+ * then the same class loader as was used to load the server
+ * is used.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param loaderName the name of the class loader.
+ * @param params the parameters for the bean's constructor.
+ * @param sig the signature of the constructor to use.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws InstanceNotFoundException if the specified class loader is not
+ * registered with the server.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ ObjectName loaderName, Object[] params,
+ String[] sig)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, InstanceNotFoundException,
+ IOException;
+
+ /**
+ * Returns the value of the supplied attribute from the specified
+ * management bean.
+ *
+ * @param bean the bean to retrieve the value from.
+ * @param name the name of the attribute to retrieve.
+ * @return the value of the attribute.
+ * @throws AttributeNotFoundException if the attribute could not be
+ * accessed from the bean.
+ * @throws MBeanException if the management bean's accessor throws
+ * an exception.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception was thrown in trying
+ * to invoke the bean's accessor.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see DynamicMBean#getAttribute(String)
+ */
+ Object getAttribute(ObjectName bean, String name)
+ throws MBeanException, AttributeNotFoundException,
+ InstanceNotFoundException, ReflectionException,
+ IOException;
+
+ /**
+ * Returns the values of the named attributes from the specified
+ * management bean.
+ *
+ * @param bean the bean to retrieve the value from.
+ * @param names the names of the attributes to retrieve.
+ * @return the values of the attributes.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception was thrown in trying
+ * to invoke the bean's accessor.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see DynamicMBean#getAttributes(String[])
+ */
+ AttributeList getAttributes(ObjectName bean, String[] names)
+ throws InstanceNotFoundException, ReflectionException,
+ IOException;
+
+ /**
+ * Returns the default domain this server applies to beans that have
+ * no specified domain.
+ *
+ * @return the default domain.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ String getDefaultDomain()
+ throws IOException;
+
+ /**
+ * Returns an array containing all the domains used by beans registered
+ * with this server. The ordering of the array is undefined.
+ *
+ * @return the list of domains.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see ObjectName#getDomain()
+ */
+ String[] getDomains()
+ throws IOException;
+
+ /**
+ * Returns the number of management beans registered with this server.
+ *
+ * @return the number of registered beans.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ Integer getMBeanCount()
+ throws IOException;
+
+ /**
+ * Returns information on the given management bean.
+ *
+ * @param name the name of the management bean.
+ * @return an instance of {@link MBeanInfo} for the bean.
+ * @throws IntrospectionException if an exception occurs in examining
+ * the bean.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception occurs when trying
+ * to invoke {@link DynamicMBean#getMBeanInfo()}
+ * on the bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see DynamicMBean#getMBeanInfo()
+ */
+ MBeanInfo getMBeanInfo(ObjectName name)
+ throws InstanceNotFoundException, IntrospectionException,
+ ReflectionException, IOException;
+
+ /**
+ * Returns the {@link ObjectInstance} created for the specified
+ * management bean on registration.
+ *
+ * @param name the name of the bean.
+ * @return the corresponding {@link ObjectInstance} instance.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #createMBean(String, ObjectName)
+ */
+ ObjectInstance getObjectInstance(ObjectName name)
+ throws InstanceNotFoundException, IOException;
+
+ /**
+ * Invokes the supplied operation on the specified management
+ * bean. The class objects specified in the signature are loaded
+ * using the same class loader as was used for the management bean.
+ *
+ * @param bean the management bean whose operation should be invoked.
+ * @param name the name of the operation to invoke.
+ * @param params the parameters of the operation.
+ * @param sig the signature of the operation.
+ * @return the return value of the method.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws MBeanException if the method invoked throws an exception.
+ * @throws ReflectionException if an exception is thrown in invoking the
+ * method.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see DynamicMBean#invoke(String, Object[], String[])
+ */
+ Object invoke(ObjectName bean, String name, Object[] params, String[] sig)
+ throws InstanceNotFoundException, MBeanException,
+ ReflectionException, IOException;
+
+ /**
+ * <p>
+ * Returns true if the specified management bean is an instance
+ * of the supplied class.
+ * </p>
+ * <p>
+ * A bean, B, is an instance of a class, C, if either of the following
+ * conditions holds:
+ * </p>
+ * <ul>
+ * <li>The class name in B's {@link MBeanInfo} is equal to the supplied
+ * name.</li>
+ * <li>Both the class of B and C were loaded by the same class loader,
+ * and B is assignable to C.</li>
+ * </ul>
+ *
+ * @param name the name of the management bean.
+ * @param className the name of the class to test if <code>name</code> is
+ * an instance of.
+ * @return true if either B is directly an instance of the named class,
+ * or B is assignable to the class, given that both it and B's
+ * current class were loaded using the same class loader.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ boolean isInstanceOf(ObjectName name, String className)
+ throws InstanceNotFoundException, IOException;
+
+ /**
+ * Returns true if the specified management bean is registered with
+ * the server.
+ *
+ * @param name the name of the management bean.
+ * @return true if the bean is registered.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean name.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ boolean isRegistered(ObjectName name)
+ throws IOException;
+
+ /**
+ * <p>
+ * Returns a set of {@link ObjectInstance}s matching the specified
+ * criteria. The full set of beans registered with the server
+ * are passed through two filters:
+ * </p>
+ * <ol>
+ * <li>Pattern matching is performed using the supplied
+ * {@link ObjectName}.</li>
+ * <li>The supplied query expression is applied.</li>
+ * </ol>
+ * <p>
+ * If both the object name and the query expression are <code>null</code>,
+ * or the object name has no domain and no key properties,
+ * no filtering will be performed and all beans are returned.
+ * </p>
+ *
+ * @param name an {@link ObjectName} to use as a filter.
+ * @param query a query expression to apply to each of the beans that match
+ * the given object name.
+ * @return a set of {@link ObjectInstance}s matching the filtered beans.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ Set queryMBeans(ObjectName name, QueryExp query)
+ throws IOException;
+
+ /**
+ * <p>
+ * Returns a set of {@link ObjectName}s matching the specified
+ * criteria. The full set of beans registered with the server
+ * are passed through two filters:
+ * </p>
+ * <ol>
+ * <li>Pattern matching is performed using the supplied
+ * {@link ObjectName}.</li>
+ * <li>The supplied query expression is applied.</li>
+ * </ol>
+ * <p>
+ * If both the object name and the query expression are <code>null</code>,
+ * or the object name has no domain and no key properties,
+ * no filtering will be performed and all beans are returned.
+ * </p>
+ *
+ * @param name an {@link ObjectName} to use as a filter.
+ * @param query a query expression to apply to each of the beans that match
+ * the given object name.
+ * @return a set of {@link ObjectName}s matching the filtered beans.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ Set queryNames(ObjectName name, QueryExp query)
+ throws IOException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. This includes all
+ * combinations of filters and passback objects registered for
+ * this listener. For more specific removal of listeners, see
+ * {@link #removeNotificationListener(ObjectName,
+ * NotificationListener,NotificationFilter,Object)}
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the listener to remove.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ * @see NotificationBroadcaster#removeNotificationListener(NotificationListener)
+ */
+ void removeNotificationListener(ObjectName name,
+ NotificationListener listener)
+ throws InstanceNotFoundException, ListenerNotFoundException,
+ IOException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. Only the first instance with
+ * the supplied filter and passback object is removed.
+ * <code>null</code> is used as a valid value for these parameters,
+ * rather than as a way to remove all registration instances for
+ * the specified listener; for this behaviour instead, see
+ * {@link #removeNotificationListener(ObjectName, NotificationListener)}.
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the listener to remove.
+ * @param filter the filter of the listener to remove.
+ * @param passback the passback object of the listener to remove.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #addNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationEmitter#removeNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void removeNotificationListener(ObjectName name,
+ NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ throws InstanceNotFoundException, ListenerNotFoundException,
+ IOException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. This includes all
+ * combinations of filters and passback objects registered for
+ * this listener. For more specific removal of listeners, see
+ * {@link #removeNotificationListener(ObjectName,
+ * ObjectName,NotificationFilter,Object)}
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the name of the listener to remove.
+ * @throws InstanceNotFoundException if a name doesn't match a registered
+ * bean.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ * @see NotificationBroadcaster#removeNotificationListener(NotificationListener)
+ */
+ void removeNotificationListener(ObjectName name, ObjectName listener)
+ throws InstanceNotFoundException, ListenerNotFoundException,
+ IOException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. Only the first instance with
+ * the supplied filter and passback object is removed.
+ * <code>null</code> is used as a valid value for these parameters,
+ * rather than as a way to remove all registration instances for
+ * the specified listener; for this behaviour instead, see
+ * {@link #removeNotificationListener(ObjectName, ObjectName)}.
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the name of the listener to remove.
+ * @param filter the filter of the listener to remove.
+ * @param passback the passback object of the listener to remove.
+ * @throws InstanceNotFoundException if a name doesn't match a registered
+ * bean.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #addNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationEmitter#removeNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void removeNotificationListener(ObjectName name,
+ ObjectName listener,
+ NotificationFilter filter,
+ Object passback)
+ throws InstanceNotFoundException, ListenerNotFoundException,
+ IOException;
+
+ /**
+ * Sets the value of the specified attribute of the supplied
+ * management bean.
+ *
+ * @param name the name of the management bean.
+ * @param attribute the attribute to set.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws AttributeNotFoundException if the attribute does not
+ * correspond to an attribute
+ * of the bean.
+ * @throws InvalidAttributeValueException if the value is invalid
+ * for this particular
+ * attribute of the bean.
+ * @throws MBeanException if setting the attribute causes
+ * the bean to throw an exception (which
+ * becomes the cause of this exception).
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #getAttribute(ObjectName, String)
+ * @see DynamicMBean#setAttribute(Attribute)
+ */
+ void setAttribute(ObjectName name, Attribute attribute)
+ throws InstanceNotFoundException, AttributeNotFoundException,
+ InvalidAttributeValueException, MBeanException,
+ ReflectionException, IOException;
+
+ /**
+ * Sets the value of each of the specified attributes
+ * of the supplied management bean to that specified by
+ * the {@link Attribute} object. The returned list contains
+ * the attributes that were set and their new values.
+ *
+ * @param name the name of the management bean.
+ * @param attributes the attributes to set.
+ * @return a list of the changed attributes.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * list.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #getAttributes(ObjectName, String[])
+ * @see DynamicMBean#setAttributes(AttributeList)
+ */
+ AttributeList setAttributes(ObjectName name, AttributeList attributes)
+ throws InstanceNotFoundException, ReflectionException,
+ IOException;
+
+ /**
+ * Unregisters the specified management bean. Following this operation,
+ * the bean instance is no longer accessible from the server via this
+ * name. Prior to unregistering the bean, the
+ * {@link MBeanRegistration#preDeregister()} method will be called if
+ * the bean implements the {@link MBeanRegistration} interface.
+ *
+ * @param name the name of the management bean.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preDeregister
+ * method.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean name or a
+ * request being made to unregister the
+ * {@link MBeanServerDelegate} bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ void unregisterMBean(ObjectName name)
+ throws InstanceNotFoundException, MBeanRegistrationException,
+ IOException;
+
+}
diff --git a/libjava/classpath/javax/management/MBeanServerDelegate.java b/libjava/classpath/javax/management/MBeanServerDelegate.java
new file mode 100644
index 00000000000..bf3f5f89420
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanServerDelegate.java
@@ -0,0 +1,308 @@
+/* MBeanServerDelegate.java -- The management server delegate.
+ 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;
+
+import gnu.classpath.ListenerData;
+import gnu.classpath.SystemProperties;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Provides an implementation of a delegate bean, which is associated
+ * with a management server. The delegate bean is responsible
+ * for providing metadata about the server and handling the
+ * registration and deregistration notifications.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanServerDelegate
+ implements MBeanServerDelegateMBean, NotificationEmitter
+{
+
+ /**
+ * The identifier of the server associated with this delegate.
+ */
+ private String id;
+
+ /**
+ * The listeners registered with the delegate.
+ */
+ private List listeners;
+
+ /**
+ * The sequence identifier used by the delegate.
+ */
+ private long seqNo;
+
+ /**
+ * Default constructor which generates the id.
+ */
+ public MBeanServerDelegate()
+ {
+ String hostName;
+ try
+ {
+ hostName = InetAddress.getLocalHost().getHostName();
+ }
+ catch (UnknownHostException e)
+ {
+ hostName = "Unknown host";
+ }
+ id = hostName + "_" + new Date().getTime();
+ }
+
+ /**
+ * Registers the specified listener as a new recipient of
+ * notifications from the delegate. If non-null, the filter
+ * argument will be used to select which notifications are
+ * delivered. The supplied object will also be passed to
+ * the recipient with each notification. This should not
+ * be modified by the broadcaster, but instead should be
+ * passed unmodified to the listener.
+ *
+ * @param listener the new listener, who will receive
+ * notifications from this broadcasting bean.
+ * @param filter a filter to determine which notifications are
+ * delivered to the listener, or <code>null</code>
+ * if no filtering is required.
+ * @param passback an object to be passed to the listener with
+ * each notification.
+ * @throws IllegalArgumentException if <code>listener</code> is
+ * <code>null</code>.
+ * @see #removeNotificationListener(NotificationListener)
+ */
+ public void addNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ throws IllegalArgumentException
+ {
+ if (listener == null)
+ throw new IllegalArgumentException("A null listener was supplied.");
+ if (listeners == null)
+ listeners = new ArrayList();
+ listeners.add(new ListenerData(listener, filter, passback));
+ }
+
+ /**
+ * Returns the name of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation name.
+ */
+ public String getImplementationName()
+ {
+ return "GNU JMX";
+ }
+
+ /**
+ * Returns the vendor of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation vendor.
+ */
+ public String getImplementationVendor()
+ {
+ return "The GNU Classpath Project";
+ }
+
+ /**
+ * Returns the version of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation version.
+ */
+ public String getImplementationVersion()
+ {
+ return SystemProperties.getProperty("gnu.classpath.version");
+ }
+
+ /**
+ * Returns the unique identifier for this management server.
+ *
+ * @return the unique id of the server.
+ */
+ public String getMBeanServerId()
+ {
+ return id;
+ }
+
+ /**
+ * Returns an array describing the notifications this
+ * bean may send to its registered listeners. Ideally, this
+ * array should be complete, but in some cases, this may
+ * not be possible. However, be aware that some listeners
+ * may expect this to be so.
+ *
+ * @return the array of possible notifications.
+ */
+ public MBeanNotificationInfo[] getNotificationInfo()
+ {
+ return new MBeanNotificationInfo[]
+ {
+ new MBeanNotificationInfo(new String[]
+ {
+ MBeanServerNotification.REGISTRATION_NOTIFICATION,
+ MBeanServerNotification.UNREGISTRATION_NOTIFICATION,
+ },
+ MBeanServerNotification.class.getName(),
+ "Server registration notifications")
+ };
+ }
+
+ /**
+ * Returns the name of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification name.
+ */
+ public String getSpecificationName()
+ {
+ return "JMX";
+ }
+
+
+ /**
+ * Returns the vendor of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification vendor.
+ */
+ public String getSpecificationVendor()
+ {
+ return "Sun Microsystems";
+ }
+
+ /**
+ * Returns the version of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification version.
+ */
+ public String getSpecificationVersion()
+ {
+ return "1.2";
+ }
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from this bean. This includes all combinations
+ * of filters and passback objects registered for this listener.
+ * For more specific removal of listeners, see
+ * {@link #removeNotificationListener(NotificationListener,
+ * NotificationFilter, java.lang.Object)}
+ *
+ * @param listener the listener to remove.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with this bean.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ */
+ public void removeNotificationListener(NotificationListener listener)
+ throws ListenerNotFoundException
+ {
+ Iterator it = listeners.iterator();
+ boolean foundOne = false;
+ while (it.hasNext())
+ {
+ ListenerData data = (ListenerData) it.next();
+ if (data.getListener() == listener)
+ {
+ it.remove();
+ foundOne = true;
+ }
+ }
+ if (!foundOne)
+ throw new ListenerNotFoundException("The specified listener, " + listener +
+ "is not registered with this bean.");
+ }
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from this delegate. Only the first instance with
+ * the supplied filter and passback object is removed.
+ * <code>null</code> is used as a valid value for these parameters,
+ * rather than as a way to remove all registration instances for
+ * the specified listener; for this behaviour instead, see
+ * {@link #removeNotificationListener(NotificationListener)}.
+ *
+ * @param listener the listener to remove.
+ * @param filter the filter of the listener to remove.
+ * @param passback the passback object of the listener to remove.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with this bean.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ * @see #removeNotificationListener(NotificationListener)
+ */
+ public void removeNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ throws ListenerNotFoundException
+ {
+ if (!(listeners.remove(new ListenerData(listener, filter, passback))))
+ {
+ throw new ListenerNotFoundException("The specified listener, " + listener +
+ " with filter " + filter +
+ "and passback " + passback +
+ ", is not registered with this bean.");
+ }
+ }
+
+ /**
+ * Allows the server to use the delegate to send a notification.
+ * If the supplied notification has a sequence number <= 0, then
+ * it is replaced with the delegate's own sequence number.
+ *
+ * @param notification the notification to send.
+ */
+ public void sendNotification(Notification notification)
+ {
+ if (notification.getSequenceNumber() <= 0)
+ notification.setSequenceNumber(++seqNo);
+ Iterator it = listeners.iterator();
+ while (it.hasNext())
+ {
+ ListenerData ldata = (ListenerData) it.next();
+ NotificationFilter filter = ldata.getFilter();
+ if (filter == null || filter.isNotificationEnabled(notification))
+ ldata.getListener().handleNotification(notification, ldata.getPassback());
+ }
+ }
+
+}
diff --git a/libjava/classpath/javax/management/MBeanServerDelegateMBean.java b/libjava/classpath/javax/management/MBeanServerDelegateMBean.java
new file mode 100644
index 00000000000..aa7b2730085
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanServerDelegateMBean.java
@@ -0,0 +1,101 @@
+/* MBeanServerDelegateMBean.java -- The interface of a management server delegate.
+ 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;
+
+/**
+ * Defines the interface for the delegate bean associated
+ * with a management server. The delegate bean is responsible
+ * for providing metadata about the server and handling the
+ * registration and deregistration notifications.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface MBeanServerDelegateMBean
+{
+
+ /**
+ * Returns the name of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation name.
+ */
+ String getImplementationName();
+
+ /**
+ * Returns the vendor of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation vendor.
+ */
+ String getImplementationVendor();
+
+ /**
+ * Returns the version of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation version.
+ */
+ String getImplementationVersion();
+
+ /**
+ * Returns the unique identifier for this management server.
+ *
+ * @return the unique id of the server.
+ */
+ String getMBeanServerId();
+
+ /**
+ * Returns the name of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification name.
+ */
+ String getSpecificationName();
+
+ /**
+ * Returns the vendor of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification vendor.
+ */
+ String getSpecificationVendor();
+
+ /**
+ * Returns the version of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification version.
+ */
+ String getSpecificationVersion();
+
+}
diff --git a/libjava/classpath/javax/management/MBeanServerFactory.java b/libjava/classpath/javax/management/MBeanServerFactory.java
new file mode 100644
index 00000000000..accbc56fc78
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanServerFactory.java
@@ -0,0 +1,413 @@
+/* MBeanServerFactory.java -- Manages server instances.
+ 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;
+
+import gnu.classpath.SystemProperties;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.management.loading.ClassLoaderRepository;
+
+/**
+ * <p>
+ * Creates and maintains a set of {@link MBeanServer} instances.
+ * Server instances, as of JMX 1.2, are created using a subclass
+ * of {@link MBeanServerBuilder}. The exact class used is controlled
+ * by the property <code>javax.management.builder.initial</code>,
+ * and allows the instances created by {@link MBeanServerBuilder}
+ * to be wrapped, thus providing additional functionality.
+ * </p>
+ * <p>
+ * The property is used as follows:
+ * </p>
+ * <ol>
+ * <li>If the property has no value, then an instance of
+ * {@link MBeanServerBuilder} is used.</li>
+ * <li>If a value is given, then:
+ * <ol>
+ * <li>The class is loaded using
+ * <code>Thread.currentThread().getContextClassLoader()</code>, or,
+ * if this is <code>null</code>, by <code>Class.forName()</code>.</li>
+ * <li><code>Class.newInstance()</code> is used to create an instance
+ * of the class. The class must be public and have a public empty
+ * constructor. If an exception is thrown, it is propogated as
+ * a {@link JMRuntimeException} and no new server instances may be
+ * created until the property is set to a valid value.</li>
+ * </ol></li>
+ * <li>The value is checked on each successive request for a server.
+ * If it differs from the class of the existing instance of
+ * {@link MBeanServerBuilder}, then the value is used to create
+ * a new instance.</li>
+ * </ol>
+ */
+public class MBeanServerFactory
+{
+
+ /**
+ * The last builder instance.
+ */
+ private static MBeanServerBuilder builder;
+
+ /**
+ * The map of registered servers (identifiers to servers).
+ */
+ private static Map servers;
+
+ /**
+ * Private constructor to prevent instance creation.
+ */
+ private MBeanServerFactory() {}
+
+ /**
+ * Returns a server implementation using the default domain name
+ * of <code>"DefaultDomain"</code>. The default domain name is
+ * used when the domain name specified by the user is <code>null</code.
+ * A reference to the created server is retained, so that it can
+ * be retrieved at a later date using {@link #findMBeanServer}.
+ * Calling this method is equivalent to calling
+ * {@link createMBeanServer(String)} with a <code>null</code> value.
+ *
+ * @return a new {@link MBeanServer} instance.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanServerPermission(String)}("createMBeanServer")
+ * @throws JMRuntimeException if the property
+ * <code>javax.management.builder.initial</code>
+ * exists but names a class which either can not be
+ * instantiated or provides an implementation that returns
+ * <code>null</code> from either
+ * {@link MBeanServerBuilder#newMBeanServerDelegate()}
+ * or {@link MBeanServerBuilder#newMBeanServer()}
+ * @throws ClassCastException if the property
+ * <code>javax.management.builder.initial</code>
+ * exists but names a class which is not a subclass
+ * of {@link MBeanServerBuilder}.
+ * @see #createMBeanServer(String)
+ */
+ public static MBeanServer createMBeanServer()
+ {
+ return createMBeanServer(null);
+ }
+
+ /**
+ * Returns a server implementation using the default domain name
+ * given, or <code>"DefaultDomain"</code> if this is <code>null</code>.
+ * The default domain name is used when the domain name specified by
+ * the user is <code>null</code. A reference to the created server is
+ * retained, so that it can be retrieved at a later date using
+ * {@link #findMBeanServer}.
+ *
+ * @param domain the default domain name of the server.
+ * @return a new {@link MBeanServer} instance.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanServerPermission(String)}("createMBeanServer")
+ * @throws JMRuntimeException if the property
+ * <code>javax.management.builder.initial</code>
+ * exists but names a class which either can not be
+ * instantiated or provides an implementation that returns
+ * <code>null</code> from either
+ * {@link MBeanServerBuilder#newMBeanServerDelegate()}
+ * or {@link MBeanServerBuilder#newMBeanServer()}
+ * @throws ClassCastException if the property
+ * <code>javax.management.builder.initial</code>
+ * exists but names a class which is not a subclass
+ * of {@link MBeanServerBuilder}.
+ */
+ public static MBeanServer createMBeanServer(String domain)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new MBeanServerPermission("createMBeanServer"));
+ MBeanServer server = createServer(domain);
+ if (servers == null)
+ servers = new HashMap();
+ try
+ {
+ ObjectName dn = new
+ ObjectName("JMImplementation:type=MBeanServerDelegate");
+ servers.put(server.getAttribute(dn, "MBeanServerId"), server);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw (Error)
+ (new InternalError("Malformed delegate bean name.").initCause(e));
+ }
+ catch (MBeanException e)
+ {
+ throw (Error)
+ (new InternalError("Exception in getMBeanServerId().").initCause(e));
+ }
+ catch (AttributeNotFoundException e)
+ {
+ throw (Error)
+ (new InternalError("Could not find MBeanServerId attribute.").initCause(e));
+ }
+ catch (InstanceNotFoundException e)
+ {
+ throw (Error)
+ (new InternalError("Could not find the delegate bean.").initCause(e));
+ }
+ catch (ReflectionException e)
+ {
+ throw (Error)
+ (new InternalError("Could not call getMBeanServerId().").initCause(e));
+ }
+ return server;
+ }
+
+ /**
+ * Returns the specified server, or, if <code>id</code> is <code>null</code>,
+ * a list of all registered servers. A registered server is one that
+ * was created using {@link #createMBeanServer()} or
+ * {@link #createMBeanServer(String)} and has not yet been released
+ * using {@link releaseMBeanServer(MBeanServer)}.
+ *
+ * @param id the id of the server to retrieve, or <code>null</code>
+ * to return all servers.
+ * @return a list of {@link MBeanServer}s.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanServerPermission(String)}("findMBeanServer")
+ */
+ public static ArrayList findMBeanServer(String id)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new MBeanServerPermission("findMBeanServer"));
+ if (id == null)
+ return new ArrayList(servers.values());
+ ArrayList list = new ArrayList();
+ MBeanServer server = (MBeanServer) servers.get(id);
+ if (server != null)
+ list.add(servers.get(id));
+ return list;
+ }
+
+ /**
+ * Returns the class loader repository used by the specified server.
+ * This is equivalent to calling {@link MBeanServer#getClassLoaderRepository()}
+ * on the given server.
+ *
+ * @param server the server whose class loader repository should be
+ * retrieved.
+ * @throws NullPointerException if <code>server</code> is <code>null</code>.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null, null,
+ * "getClassLoaderRepository")</code>
+ */
+ public static ClassLoaderRepository getClassLoaderRepository(MBeanServer server)
+ {
+ return server.getClassLoaderRepository();
+ }
+
+ /**
+ * Returns a server implementation using the default domain name
+ * of <code>"DefaultDomain"</code>. The default domain name is
+ * used when the domain name specified by the user is <code>null</code.
+ * No reference to the created server is retained, so the server is
+ * garbage collected when it is no longer used, but it can not be
+ * retrieved at a later date using {@link #findMBeanServer}.
+ * Calling this method is equivalent to calling
+ * {@link newMBeanServer(String)} with a <code>null</code> value.
+ *
+ * @return a new {@link MBeanServer} instance.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanServerPermission(String)}("newMBeanServer")
+ * @throws JMRuntimeException if the property
+ * <code>javax.management.builder.initial</code>
+ * exists but names a class which either can not be
+ * instantiated or provides an implementation that returns
+ * <code>null</code> from either
+ * {@link MBeanServerBuilder#newMBeanServerDelegate()}
+ * or {@link MBeanServerBuilder#newMBeanServer()}
+ * @throws ClassCastException if the property
+ * <code>javax.management.builder.initial</code>
+ * exists but names a class which is not a subclass
+ * of {@link MBeanServerBuilder}.
+ * @see #newMBeanServer(String)
+ */
+ public static MBeanServer newMBeanServer()
+ {
+ return newMBeanServer(null);
+ }
+
+ /**
+ * Returns a server implementation using the default domain name
+ * given, or <code>"DefaultDomain"</code> if this is <code>null</code>.
+ * The default domain name is used when the domain name specified by
+ * the user is <code>null</code. No reference to the created server is
+ * retained, so the server is garbage collected when it is no longer
+ * used, but it can not be retrieved at a later date using
+ * {@link #findMBeanServer}.
+ *
+ * @param domain the default domain name of the server.
+ * @return a new {@link MBeanServer} instance.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanServerPermission(String)}("newMBeanServer")
+ * @throws JMRuntimeException if the property
+ * <code>javax.management.builder.initial</code>
+ * exists but names a class which either can not be
+ * instantiated or provides an implementation that returns
+ * <code>null</code> from either
+ * {@link MBeanServerBuilder#newMBeanServerDelegate()}
+ * or {@link MBeanServerBuilder#newMBeanServer()}
+ * @throws ClassCastException if the property
+ * <code>javax.management.builder.initial</code>
+ * exists but names a class which is not a subclass
+ * of {@link MBeanServerBuilder}.
+ */
+ public static MBeanServer newMBeanServer(String domain)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new MBeanServerPermission("newMBeanServer"));
+ return createServer(domain);
+ }
+
+ /**
+ * Common method to create a server for the {@link #createMBeanServer(String)}
+ * and {@link #newMBeanServer(String)} methods above.
+ *
+ * @param domain the default domain name of the server.
+ * @throws JMRuntimeException if the property
+ * <code>javax.management.builder.initial</code>
+ * exists but names a class which either can not be
+ * instantiated or provides an implementation that returns
+ * <code>null</code> from either
+ * {@link MBeanServerBuilder#newMBeanServerDelegate()}
+ * or {@link MBeanServerBuilder#newMBeanServer()}
+ * @throws ClassCastException if the property
+ * <code>javax.management.builder.initial</code>
+ * exists but names a class which is not a subclass
+ * of {@link MBeanServerBuilder}.
+ */
+ private static MBeanServer createServer(String domain)
+ {
+ if (domain == null)
+ domain = "DefaultDomain";
+ String builderClass =
+ SystemProperties.getProperty("javax.management.builder.initial");
+ if (builderClass == null)
+ {
+ if (builder == null ||
+ builder.getClass() != MBeanServerBuilder.class)
+ builder = new MBeanServerBuilder();
+ }
+ else if (!(builderClass.equals(builder.getClass().getName())))
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null)
+ cl = MBeanServerFactory.class.getClassLoader();
+ try
+ {
+ Class bClass = Class.forName(builderClass, true, cl);
+ builder = (MBeanServerBuilder) bClass.newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw (JMRuntimeException) (new JMRuntimeException("The builder class, "
+ + builderClass +
+ ", could not be found."))
+ .initCause(e);
+ }
+ catch (InstantiationException e)
+ {
+ throw (JMRuntimeException) (new JMRuntimeException("The builder class, "
+ + builderClass +
+ ", could not be instantiated."))
+ .initCause(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw (JMRuntimeException) (new JMRuntimeException("The builder class, "
+ + builderClass +
+ ", could not be accessed."))
+ .initCause(e);
+ }
+ }
+ MBeanServerDelegate delegate = builder.newMBeanServerDelegate();
+ if (delegate == null)
+ throw new JMRuntimeException("A delegate could not be created.");
+ MBeanServer server = builder.newMBeanServer("DefaultDomain", null, delegate);
+ if (server == null)
+ throw new JMRuntimeException("A server could not be created.");
+ return server;
+ }
+
+ /**
+ * Removes the reference to the specified server, thus allowing it to
+ * be garbage collected.
+ *
+ * @param server the server to remove.
+ * @throws IllegalArgumentException if a reference to the server is not
+ * held (i.e. it wasn't created by
+ * {@link #createMBeanServer(String)}
+ * or this method has already been called
+ * on it.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanServerPermission(String)}("releaseMBeanServer")
+ */
+ public static void releaseMBeanServer(MBeanServer server)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new MBeanServerPermission("releaseMBeanServer"));
+ Iterator i = servers.values().iterator();
+ while (i.hasNext())
+ {
+ MBeanServer s = (MBeanServer) i.next();
+ if (server == s)
+ {
+ i.remove();
+ return;
+ }
+ }
+ throw new IllegalArgumentException("The server given is not referenced.");
+ }
+
+
+}
diff --git a/libjava/classpath/javax/management/MBeanServerNotification.java b/libjava/classpath/javax/management/MBeanServerNotification.java
new file mode 100644
index 00000000000..820fd61b354
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanServerNotification.java
@@ -0,0 +1,103 @@
+/* MBeanServerNotification.java -- The registration notification.
+ 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;
+
+/**
+ * The notification emitted by a management server on a registration
+ * or de-registration event. Events are emitted via the delegate
+ * management bean of the server. Other objects can listen for
+ * such events by registering their interest with the delegate
+ * bean. The bean can be obtained via the {@link ObjectName}
+ * <code>JMImplementation:type=MBeanServerDelegate</code>.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanServerNotification
+ extends Notification
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 2876477500475969677L;
+
+ /**
+ * Notification type for the registration event.
+ */
+ public static final String REGISTRATION_NOTIFICATION = "JMX.mbean.registered";
+
+ /**
+ * Notification type for the de-registration event.
+ */
+ public static final String UNREGISTRATION_NOTIFICATION = "JMX.mbean.unregistered";
+
+ /**
+ * The name of the bean which forms the subject of this notification.
+ */
+ private ObjectName objectName;
+
+ /**
+ * Constructs a new {@link MBeanServerNotification} of the specified
+ * type for an event relating to the supplied bean, with the given
+ * source and sequence number.
+ *
+ * @param type the type of notification (registration or de-registration).
+ * @param source the source of the notification.
+ * @param seqNo the sequence number of this notification, used to order
+ * multiple such notifications.
+ * @param name the name of the bean concerned by this event.
+ */
+ public MBeanServerNotification(String type, Object source, long seqNo,
+ ObjectName name)
+ {
+ super(type, source, seqNo);
+ objectName = name;
+ }
+
+ /**
+ * Returns the name of the bean this notification concerns.
+ *
+ * @return the name of the bean.
+ */
+ public ObjectName getMBeanName()
+ {
+ return objectName;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/MBeanServerPermission.java b/libjava/classpath/javax/management/MBeanServerPermission.java
new file mode 100644
index 00000000000..e6227814443
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanServerPermission.java
@@ -0,0 +1,470 @@
+/* MBeanServerPermission.java -- Permissions controlling server creation.
+ 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;
+
+import java.security.BasicPermission;
+import java.security.Permission;
+import java.security.PermissionCollection;
+
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+/**
+ * <p>
+ * Represents the permissions required to perform
+ * operations provided by the {@link MBeanServerFactory}.
+ * As with all {@link java.security.Permission} objects, an
+ * instance of this class either represents a permission
+ * already held or one that is required to access a
+ * particular service. In the case of {@link MBeanServerPermission}s,
+ * implication checks are made using an instance of this class
+ * when a user requests an operation from the factory, and a
+ * {@link SecurityManager} is in place.
+ * </p>
+ * <p>
+ * The permission is defined by its name, which may be
+ * either a <code>'*'</code> (to allow all) or one or
+ * more of the following, separated by a <code>','</code>:
+ * </p>
+ * <ul>
+ * <li><code>createMBeanServer</code> -- allows a registered
+ * instance of a server to be obtained from the factory.</li>
+ * <li><code>findMBeanServer</code> -- allows all or one
+ * particular server instance to be retrieved from the factory.</li>
+ * <li><code>newMBeanServer</code> -- allows an unregistered
+ * instance of a server to be obtained from the factory.</li>
+ * <li><code>releaseMBeanServer</code> -- allows a reference to
+ * a server instance to be removed from the factory.</li>
+ * </ul>
+ * <p>
+ * The names may be surrounded by arbitrary amounts of whitespace.
+ * <code>createMBeanServer</code> implies <code>newMBeanServer</code>.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanServerPermission
+ extends BasicPermission
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -5661980843569388590L;
+
+ /**
+ * <p>
+ * Constructs a new {@link MBeanServerPermission} with
+ * the given name. The name must not be <code>null</code>
+ * and must be equal to either <code>"*"</code> or a
+ * comma-separated list of valid permissions. The four
+ * valid constraints are:
+ * </p>
+ * <ol>
+ * <li><code>createMBeanServer</code></li>
+ * <li><code>findMBeanServer</code></li>
+ * <li><code>newMBeanServer</code></li>
+ * <li><code>releaseMBeanServer</code></li>
+ * </ol>
+ * <p>
+ * Calling this constructor is equivalent to calling
+ * <code>MBeanPermission(name, null)</code>.
+ * </p>
+ *
+ * @param name the name of this permission.
+ * @throws NullPointerException if <code>name</code>
+ * is <code>null</code>.
+ * @throws IllegalArgumentException if <code>name</code>
+ * is not either equal to
+ * <code>"*"</code> or forms
+ * a comma-separated list of
+ * valid constraints.
+ * @see #MBeanServerPermission(String,String)
+ */
+ public MBeanServerPermission(String name)
+ {
+ this(name, null);
+ }
+
+ /**
+ * <p>
+ * Constructs a new {@link MBeanServerPermission} with
+ * the given name and actions. The actions are unused,
+ * and must be either <code>null</code> or the empty
+ * string. The name must not be <code>null</code>
+ * and must be equal to either <code>"*"</code> or a
+ * comma-separated list of valid permissions. The four
+ * valid constraints are:
+ * </p>
+ * <ol>
+ * <li><code>createMBeanServer</code></li>
+ * <li><code>findMBeanServer</code></li>
+ * <li><code>newMBeanServer</code></li>
+ * <li><code>releaseMBeanServer</code></li>
+ * </ol>
+ * <p>
+ * Calling this constructor is equivalent to calling
+ * <code>MBeanPermission(name, null)</code>.
+ * </p>
+ *
+ * @param name the name of this permission.
+ * @throws NullPointerException if <code>name</code>
+ * is <code>null</code>.
+ * @throws IllegalArgumentException if <code>name</code>
+ * is not either equal to
+ * <code>"*"</code> or forms
+ * a comma-separated list of
+ * valid constraints, or if
+ * <code>actions</code> is not
+ * <code>null</code> or the
+ * empty string.
+ * @see #MBeanServerPermission(String,String)
+ */
+ public MBeanServerPermission(String name, String actions)
+ {
+ super(checkName(name), actions);
+ if (actions != null && actions.length() > 0)
+ throw new IllegalArgumentException("The supplied action list " +
+ "was not equal to null or the " +
+ "empty string.");
+ }
+
+ /**
+ * Returns true if the given object is also an {@link MBeanServerPermission}
+ * with the same name.
+ *
+ * @param obj the object to compare with this one.
+ * @return true if the object is an {@link MBeanPermission}
+ * with the same name.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof MBeanServerPermission)
+ {
+ MBeanServerPermission o = (MBeanServerPermission) obj;
+ return o.getName().equals(getName());
+ }
+ return false;
+ }
+
+ /**
+ * Returns a unique hash code for this permission.
+ * This is simply the hashcode of {@link BasicPermission#getName()}.
+ *
+ * @return the hashcode of this permission.
+ */
+ public int hashCode()
+ {
+ return getName().hashCode();
+ }
+
+ /**
+ * Returns true if this {@link MBeanServerPermission} implies
+ * the given permission. This occurs if the given permission
+ * is also an {@link MBeanServerPermission} and its target names
+ * are a subset of the target names of this permission. Note that
+ * the name <code>createMBeanServer</code> implies
+ * <code>newMBeanServer</code>.
+ *
+ * @param p the permission to check for implication.
+ * @return true if this permission implies <code>p</code>.
+ */
+ public boolean implies(Permission p)
+ {
+ if (p instanceof MBeanServerPermission)
+ {
+ if (getName().equals("*"))
+ return true;
+ MBeanServerPermission msp = (MBeanServerPermission) p;
+ String[] thisCaps = getName().split(",");
+ String[] mspCaps = msp.getName().split(",");
+ for (int a = 0; a < mspCaps.length; ++a)
+ {
+ boolean found = false;
+ String mc = mspCaps[a].trim();
+ for (int b = 0; b < thisCaps.length; ++b)
+ {
+ String tc = thisCaps[b].trim();
+ if (tc.equals(mc))
+ found = true;
+ if (tc.equals("createMBeanServer") &&
+ mc.equals("newMBeanServer"))
+ found = true;
+ }
+ if (!found)
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns a {@link PermissionCollection} which stores
+ * a series of {@link MBeanServerPermission}s as the union
+ * of their capabilities.
+ *
+ * @return a collection for {@link MBeanServerPermission}s.
+ */
+ public PermissionCollection newPermissionCollection()
+ {
+ return new MBeanServerPermissionCollection();
+ }
+
+ /**
+ * A collection of {@link MBeanServerPermission}s, stored
+ * as a single permission with the union of the capabilities
+ * as its capabilities.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+ private class MBeanServerPermissionCollection
+ extends PermissionCollection
+ {
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -5661980843569388590L;
+
+ /**
+ * The collected permission. This is <code>null</code> or
+ * the union of the permissions held by all the collected
+ * permissions.
+ */
+ private MBeanServerPermission collectionPermission;
+
+ /**
+ * Adds a new permission by unifying it with the existing
+ * collection permission.
+ *
+ * @param p the permission to add.
+ * @throws SecurityException if the collection is read only.
+ * @see #isReadOnly()
+ * @see #setReadOnly(boolean)
+ */
+ public void add(Permission p)
+ {
+ if (isReadOnly())
+ throw new SecurityException("This collection is read only.");
+ if (p instanceof MBeanServerPermission)
+ {
+ MBeanServerPermission msp = (MBeanServerPermission) p;
+ if (collectionPermission == null)
+ collectionPermission = msp;
+ else
+ {
+ String finalString = collectionPermission.getName();
+ String[] cp = finalString.split(",");
+ String[] np = msp.getName().split(",");
+ int createms = finalString.indexOf("createMBeanServer");
+ int newms = finalString.indexOf("newMBeanServer");
+ for (int a = 0; a < np.length; ++a)
+ {
+ boolean found = false;
+ String nps = np[a].trim();
+ for (int b = 0; b < cp.length; ++b)
+ {
+ String cps = cp[b].trim();
+ if (cps.equals(nps))
+ found = true;
+ if (np.equals("newMBeanServer")
+ && createms != -1)
+ found = true;
+ if (np.equals("createMBeanServer")
+ && newms != -1)
+ finalString.replace("newMBeanServer",
+ "createMBeanServer");
+ }
+ if (!found)
+ finalString += "," + nps;
+ }
+ collectionPermission =
+ new MBeanServerPermission(finalString);
+ }
+ }
+ }
+
+ /**
+ * Returns an enumeration over the single permission.
+ *
+ * @return an enumeration over the collection permission.
+ */
+ public Enumeration elements()
+ {
+ return new
+ MBeanServerPermissionEnumeration(collectionPermission);
+ }
+
+ /**
+ * Provides an enumeration over a comma-separated list
+ * of capabilities.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+ private class MBeanServerPermissionEnumeration
+ implements Enumeration
+ {
+
+ /**
+ * The collected permission.
+ */
+ private MBeanServerPermission p;
+
+ /**
+ * True if we have returned the permission.
+ */
+ private boolean done;
+
+ /**
+ * Constructs a new {@link MBeanServerPermissionEnumeration}
+ * using the given collected permission.
+ *
+ * @param p the collected permission.
+ */
+ public MBeanServerPermissionEnumeration(MBeanServerPermission p)
+ {
+ this.p = p;
+ done = false;
+ }
+
+ /**
+ * Returns true if there are more capabilities to return.
+ *
+ * @return true if there are more capabilities available.
+ */
+ public boolean hasMoreElements()
+ {
+ return !done;
+ }
+
+ /**
+ * Returns the next capability.
+ *
+ * @return the next capability.
+ */
+ public Object nextElement()
+ {
+ if (hasMoreElements())
+ {
+ done = true;
+ return p;
+ }
+ else
+ throw new NoSuchElementException("No more elements are available.");
+ }
+
+ }
+
+ /**
+ * Returns true if the collected {@link MBeanServerPermission}
+ * implies the given permission. This occurs if the given permission
+ * is also an {@link MBeanServerPermission} and its target names
+ * are a subset of the target names of this permission. Note that
+ * the name <code>createMBeanServer</code> implies
+ * <code>newMBeanServer</code>.
+ *
+ * @param p the permission to check for implication.
+ * @return true if this permission implies <code>p</code>.
+ */
+ public boolean implies(Permission p)
+ {
+ return collectionPermission.implies(p);
+ }
+ }
+
+ /**
+ * Checks the name is valid, including removing
+ * the <code>newMBeanServer</code> permission when
+ * <code>createMBeanServer</code> is present.
+ *
+ * @param name the name to check.
+ * @throws NullPointerException if <code>name</code>
+ * is <code>null</code>.
+ * @throws IllegalArgumentException if <code>name</code>
+ * is not either equal to
+ * <code>"*"</code> or forms
+ * a comma-separated list of
+ * valid constraints.
+ */
+ private static String checkName(String name)
+ {
+ if (!(name.equals("*")))
+ {
+ String[] constraints = name.split(",");
+ name = "";
+ boolean seenCreate = false;
+ boolean seenNew = false;
+ boolean start = true;
+ for (int a = 0; a < constraints.length; ++a)
+ {
+ String next = constraints[a].trim();
+ if (!(next.equals("createMBeanServer") ||
+ next.equals("findMBeanServer") ||
+ next.equals("newMBeanServer") ||
+ next.equals("releaseMBeanServer")))
+ throw new IllegalArgumentException("An invalid constraint, " +
+ next + ", was specified.");
+ if (next.equals("newMBeanServer"))
+ seenNew = true;
+ else if (next.equals("createMBeanServer"))
+ seenCreate = true;
+ else
+ {
+ if (!start)
+ name += ",";
+ name += next;
+ start = false;
+ }
+ }
+ if (seenNew && !seenCreate)
+ name += (start ? "" : ",") + "newMBeanServer";
+ else if (seenCreate)
+ name += (start ? "" : ",") + "createMBeanServer";
+ }
+ return name;
+ }
+
+}
+
+
+
+
diff --git a/libjava/classpath/javax/management/MBeanTrustPermission.java b/libjava/classpath/javax/management/MBeanTrustPermission.java
new file mode 100644
index 00000000000..57d0e6889b0
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanTrustPermission.java
@@ -0,0 +1,105 @@
+/* MBeanTrustPermission.java -- Represents a trusted bean source.
+ 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;
+
+import java.security.BasicPermission;
+
+/**
+ * Represents the permission held by a trusted source of
+ * management beans. For a bean to be added to a management
+ * server, the source of that bean must hold this permission.
+ * It has a target, but no actions. Valid values for the target
+ * are <code>"register"</code> and <code>"*"</code>, the latter
+ * representing both the existing <code>"register"</code> target
+ * and any future targets.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanTrustPermission
+ extends BasicPermission
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -2952178077029018140L;
+
+ /**
+ * Constructs a {@link MBeanTrustPermission} with the given target.
+ * The target must be either <code>"register"</code> or <code>"*"</code>.
+ * The actions of the permission default to <code>null</code>,
+ * so this is equivalent to calling
+ * <code>MBeanTrustPermission(target, null)</code>.
+ *
+ * @param target the target of this permission.
+ * @throws NullPointerException if <code>target</code> is null.
+ * @throws IllegalArgumentException if the target is other than
+ * <code>"register"</code> or <code>"*"</code>.
+ * @see #MBeanTrustPermission(String, String)
+ */
+ public MBeanTrustPermission(String target)
+ {
+ this(target, null);
+ }
+
+ /**
+ * Constructs a {@link MBeanTrustPermission} with the given target
+ * and actions. The target must be either <code>"register"</code>
+ * or <code>"*"</code>. The actions must be either <code>null</code>
+ * or the empty string, <code>""</code>.
+ *
+ * @param target the target of this permission.
+ * @param actions the actions for this permission.
+ * @throws NullPointerException if <code>target</code> is null.
+ * @throws IllegalArgumentException if the target is other than
+ * <code>"register"</code> or <code>"*"</code>
+ * or actions is other than
+ * <code>null</code> or <code>""</code>.
+ */
+ public MBeanTrustPermission(String target, String actions)
+ {
+ super(target, actions);
+ if ((!(target.equals("register"))) &&
+ (!(target.equals("*"))))
+ throw new IllegalArgumentException("The target must be 'register' or '*'");
+ if (actions != null && !(actions.length() == 0))
+ throw new IllegalArgumentException("The actions must be null or ''");
+ }
+
+}
diff --git a/libjava/classpath/javax/management/MalformedObjectNameException.java b/libjava/classpath/javax/management/MalformedObjectNameException.java
new file mode 100644
index 00000000000..e2f5774908c
--- /dev/null
+++ b/libjava/classpath/javax/management/MalformedObjectNameException.java
@@ -0,0 +1,76 @@
+/* MalformedObjectNameException.java -- Thrown by invalid values.
+ 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;
+
+/**
+ * Thrown when a string used as an {@link ObjectName}
+ * is invalid.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MalformedObjectNameException
+ extends OperationsException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -572689714442915824L;
+
+ /**
+ * Constructs a new <code>MalformedObjectNameException</code>.
+ */
+ public MalformedObjectNameException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>MalformedObjectNameException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public MalformedObjectNameException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/ObjectInstance.java b/libjava/classpath/javax/management/ObjectInstance.java
new file mode 100644
index 00000000000..df364cffc89
--- /dev/null
+++ b/libjava/classpath/javax/management/ObjectInstance.java
@@ -0,0 +1,147 @@
+/* ObjectInstance.java -- Represent the bean instance used by a server.
+ 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;
+
+import java.io.Serializable;
+
+/**
+ * A simple class used to link a bean instance to its class name.
+ * If the bean is a {@link DynamicMBean}, the class name may be
+ * obtained using {@link MBeanInfo#getClassName()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class ObjectInstance
+ implements Serializable
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -4099952623687795850L;
+
+ /**
+ * The name of the bean.
+ */
+ private ObjectName name;
+
+ /**
+ * The class name of the bean.
+ */
+ private String className;
+
+ /**
+ * Constructs a new {@link ObjectInstance} for the specified bean
+ * with the supplied class name. The class name should include
+ * the full package name.
+ *
+ * @param name the name of the bean.
+ * @param className the class name of the bean.
+ */
+ public ObjectInstance(ObjectName name, String className)
+ {
+ this.name = name;
+ this.className = className;
+ }
+
+ /**
+ * Constructs a new {@link ObjectInstance} for the specified bean
+ * with the supplied class name. The class name should include
+ * the full package name.
+ *
+ * @param name the name of the bean.
+ * @param className the class name of the bean.
+ * @throws MalformedObjectNameException if the name of the bean
+ * does not match the syntax
+ * of an {@link ObjectName}.
+ */
+ public ObjectInstance(String name, String className)
+ throws MalformedObjectNameException
+ {
+ this(new ObjectName(name), className);
+ }
+
+ /**
+ * Returns true if the supplied object is also an {@link ObjectInstance}
+ * with the same bean and class name.
+ *
+ * @param obj the object to compare.
+ * @return true if the the supplied object is equal to <code>this</code>.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof ObjectInstance))
+ return false;
+ ObjectInstance i = (ObjectInstance) obj;
+ return (i.getClassName().equals(className) &&
+ i.getObjectName().equals(name));
+ }
+
+ /**
+ * Returns the class name of the bean.
+ *
+ * @return the class name.
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Returns the name of the bean.
+ *
+ * @return the name of the bean.
+ */
+ public ObjectName getObjectName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns a hash code for this instance. This is calculated as
+ * the sum of the hashcodes for the bean's name and the class name.
+ *
+ * @return the hash code of this instance.
+ */
+ public int hashCode()
+ {
+ return name.hashCode() + className.hashCode();
+ }
+
+}
diff --git a/libjava/classpath/javax/management/ObjectName.java b/libjava/classpath/javax/management/ObjectName.java
new file mode 100644
index 00000000000..0e6bf2fd9cf
--- /dev/null
+++ b/libjava/classpath/javax/management/ObjectName.java
@@ -0,0 +1,775 @@
+/* ObjectName.java -- Represent the name of a bean, or a pattern for a name.
+ 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;
+
+import java.io.Serializable;
+
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * <p>
+ * An {@link ObjectName} instance represents the name of a management
+ * bean, or a pattern which may match the name of one or more
+ * management beans. Patterns are distinguished from names by the
+ * presence of the '?' and '*' characters (which match a single
+ * character and a series of zero or more characters, respectively).
+ * </p>
+ * <p>
+ * Each name begins with a domain element, which is terminated by
+ * a ':' character. The domain may be empty. If so, it will be
+ * replaced by the default domain of the bean server in certain
+ * contexts. The domain is a pattern, if it contains either '?'
+ * or '*'. To avoid collisions, it is usual to use reverse
+ * DNS names for the domain, as in Java package and property names.
+ * </p>
+ * <p>
+ * Following the ':' character is a series of properties. The list
+ * is separated by commas, and largely consists of unordered key-value
+ * pairs, separated by an equals sign ('='). At most one element may
+ * be an asterisk ('*'), which turns the {@link ObjectName} instance
+ * into a <emph>property pattern</emph>. In this situation, the pattern
+ * matches a name if the name contains at least those key-value pairs
+ * given and has the same domain.
+ * </p>
+ * <p>
+ * A <emph>key</emph> is a string of characters which doesn't include
+ * any of those used as delimiters or in patterns (':', '=', ',', '?'
+ * and '*'). Keys must be unique.
+ * </p>
+ * <p>
+ * A value may be <emph>quoted</emph> or <emph>unquoted</emph>. Unquoted
+ * values obey the same rules as given for keys above. Quoted values are
+ * surrounded by quotation marks ("), and use a backslash ('\') character
+ * to include quotes ('\"'), backslashes ('\\'), newlines ('\n'), and
+ * the pattern characters ('\?' and '\*'). The quotes and backslashes
+ * (after expansion) are considered part of the value.
+ * </p>
+ * <p>
+ * Spaces are maintained within the different parts of the name. Thus,
+ * '<code>domain: key1 = value1 </code>' has a key ' key1 ' with value
+ * ' value1 '. Newlines are disallowed, except where escaped in quoted
+ * values.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class ObjectName
+ implements Serializable, QueryExp
+{
+
+ /**
+ * The domain of the name.
+ */
+ private String domain;
+
+ /**
+ * The properties, as key-value pairs.
+ */
+ private TreeMap properties;
+
+ /**
+ * The properties as a string (stored for ordering).
+ */
+ private String propertyListString;
+
+ /**
+ * True if this object name is a property pattern.
+ */
+ private boolean propertyPattern;
+
+ /**
+ * The management server associated with this object name.
+ */
+ private MBeanServer server;
+
+ /**
+ * Constructs an {@link ObjectName} instance from the given string,
+ * which should be of the form
+ * &lt;domain&gt;:&lt;properties&gt;&lt;wild&gt;. &lt;domain&gt;
+ * represents the domain section of the name. &lt;properties&gt;
+ * represents the key-value pairs, as returned by {@link
+ * #getKeyPropertyListString()}. &lt;wild&gt; is the optional
+ * asterisk present in the property list. If the string doesn't
+ * represent a property pattern, it will be empty. If it does,
+ * it will be either ',*' or '*', depending on whether other
+ * properties are present or not, respectively.
+ *
+ * @param name the string to use to construct this instance.
+ * @throws MalformedObjectNameException if the string is of the
+ * wrong format.
+ * @throws NullPointerException if <code>name</code> is
+ * <code>null</code>.
+ */
+ public ObjectName(String name)
+ throws MalformedObjectNameException
+ {
+ int domainSep = name.indexOf(':');
+ if (domainSep == -1)
+ throw new MalformedObjectNameException("No domain separator was found.");
+ domain = name.substring(0, domainSep);
+ String rest = name.substring(domainSep + 1);
+ if (rest.equals("*"))
+ propertyPattern = true;
+ else
+ {
+ if (rest.endsWith(",*"))
+ {
+ propertyPattern = true;
+ propertyListString = rest.substring(0, rest.length() - 2);
+ }
+ else
+ propertyListString = rest;
+ String[] pairs = propertyListString.split(",");
+ if (pairs.length == 0 && !isPattern())
+ throw new MalformedObjectNameException("A name that is not a " +
+ "pattern must contain at " +
+ "least one key-value pair.");
+ properties = new TreeMap();
+ for (int a = 0; a < pairs.length; ++a)
+ {
+ int sep = pairs[a].indexOf('=');
+ String key = pairs[a].substring(0, sep);
+ if (properties.containsKey(key))
+ throw new MalformedObjectNameException("The same key occurs " +
+ "more than once.");
+ properties.put(key, pairs[a].substring(sep + 1));
+ }
+ }
+ checkComponents();
+ }
+
+ /**
+ * Constructs an {@link ObjectName} instance using the given
+ * domain and the one specified property.
+ *
+ * @param domain the domain part of the object name.
+ * @param key the key of the property.
+ * @param value the value of the property.
+ * @throws MalformedObjectNameException the domain, key or value
+ * contains an illegal
+ * character or the value
+ * does not follow the quoting
+ * specifications.
+ * @throws NullPointerException if one of the parameters is
+ * <code>null</code>.
+ */
+ public ObjectName(String domain, String key, String value)
+ throws MalformedObjectNameException
+ {
+ this.domain = domain;
+ properties = new TreeMap();
+ properties.put(key, value);
+ checkComponents();
+ }
+
+ /**
+ * Constructs an {@link ObjectName} instance using the given
+ * domain and properties.
+ *
+ * @param domain the domain part of the object name.
+ * @param properties the key-value property pairs.
+ * @throws MalformedObjectNameException the domain, a key or a value
+ * contains an illegal
+ * character or a value
+ * does not follow the quoting
+ * specifications.
+ * @throws NullPointerException if one of the parameters is
+ * <code>null</code>.
+ */
+ public ObjectName(String domain, Hashtable properties)
+ throws MalformedObjectNameException
+ {
+ this.domain = domain;
+ this.properties.putAll(properties);
+ checkComponents();
+ }
+
+ /**
+ * Checks the legality of the domain and the properties.
+ *
+ * @throws MalformedObjectNameException the domain, a key or a value
+ * contains an illegal
+ * character or a value
+ * does not follow the quoting
+ * specifications.
+ */
+ private void checkComponents()
+ throws MalformedObjectNameException
+ {
+ if (domain.indexOf(':') != -1)
+ throw new MalformedObjectNameException("The domain includes a ':' " +
+ "character.");
+ if (domain.indexOf('\n') != -1)
+ throw new MalformedObjectNameException("The domain includes a newline " +
+ "character.");
+ char[] chars = new char[] { ':', ',', '*', '?', '=' };
+ Iterator i = properties.entrySet().iterator();
+ while (i.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ String key = (String) entry.getKey();
+ for (int a = 0; a < chars.length; ++a)
+ if (key.indexOf(chars[a]) != -1)
+ throw new MalformedObjectNameException("A key contains a '" +
+ chars[a] + "' " +
+ "character.");
+ String value = (String) entry.getValue();
+ int quote = value.indexOf('"');
+ if (quote == 0)
+ {
+ try
+ {
+ unquote(value);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new MalformedObjectNameException("The quoted value is " +
+ "invalid.");
+ }
+ }
+ else if (quote != -1)
+ throw new MalformedObjectNameException("A value contains " +
+ "a '\"' character.");
+ else
+ {
+ for (int a = 0; a < chars.length; ++a)
+ if (value.indexOf(chars[a]) != -1)
+ throw new MalformedObjectNameException("A value contains " +
+ "a '" + chars[a] + "' " +
+ "character.");
+ }
+ }
+ }
+
+ /**
+ * <p>
+ * Attempts to find a match between this name and the one supplied.
+ * The following criteria are used:
+ * </p>
+ * <ul>
+ * <li>If the supplied name is a pattern, <code>false</code> is
+ * returned.</li>
+ * <li>If this name is a pattern, this method returns <code>true</code>
+ * if the supplied name matches the pattern.</li>
+ * <li>If this name is not a pattern, the result of
+ * <code>equals(name)</code> is returned.
+ * </ul>
+ *
+ * @param name the name to find a match with.
+ * @return true if the name either matches this pattern or is
+ * equivalent to this name under the criteria of
+ * {@link #equals(java.lang.Object)}
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
+ */
+ public boolean apply(ObjectName name)
+ {
+ if (name.isPattern())
+ return false;
+ if (isPattern())
+ {
+ boolean domainMatch, propMatch;
+ if (isDomainPattern())
+ {
+ String oDomain = name.getDomain();
+ int oLength = oDomain.length();
+ for (int a = 0; a < domain.length(); ++a)
+ {
+ char n = domain.charAt(a);
+ if (oLength == a && n != '*')
+ return false;
+ if (n == '?')
+ continue;
+ if (n == '*')
+ if ((a + 1) < domain.length())
+ {
+ if (oLength == a)
+ return false;
+ char next;
+ do
+ {
+ next = domain.charAt(a + 1);
+ } while (next == '*');
+ if (next == '?')
+ continue;
+ int pos = a;
+ while (oDomain.charAt(pos) != next)
+ {
+ ++pos;
+ if (pos == oLength)
+ return false;
+ }
+ }
+ if (n != oDomain.charAt(a))
+ return false;
+ }
+ domainMatch = true;
+ }
+ else
+ domainMatch = domain.equals(name.getDomain());
+ if (isPropertyPattern())
+ {
+ Hashtable oProps = name.getKeyPropertyList();
+ Iterator i = properties.entrySet().iterator();
+ while (i.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ String key = (String) entry.getKey();
+ if (!(oProps.containsKey(key)))
+ return false;
+ String val = (String) entry.getValue();
+ if (!(val.equals(oProps.get(key))))
+ return false;
+ }
+ propMatch = true;
+ }
+ else
+ propMatch =
+ getCanonicalKeyPropertyListString().equals
+ (name.getCanonicalKeyPropertyListString());
+ return domainMatch && propMatch;
+ }
+ return equals(name);
+ }
+
+ /**
+ * Compares the specified object with this one. The two
+ * are judged to be equivalent if the given object is an
+ * instance of {@link ObjectName} and has an equal canonical
+ * form (as returned by {@link #getCanonicalName()}).
+ *
+ * @param obj the object to compare with this.
+ * @return true if the object is also an {@link ObjectName}
+ * with an equivalent canonical form.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ObjectName)
+ {
+ ObjectName o = (ObjectName) obj;
+ return getCanonicalName().equals(o.getCanonicalName());
+ }
+ return false;
+ }
+
+ /**
+ * Returns the property list in canonical form. The keys
+ * are ordered using the lexicographic ordering used by
+ * {@link java.lang.String#compareTo(java.lang.Object)}.
+ *
+ * @return the property list, with the keys in lexicographic
+ * order.
+ */
+ public String getCanonicalKeyPropertyListString()
+ {
+ StringBuilder builder = new StringBuilder();
+ Iterator i = properties.entrySet().iterator();
+ while (i.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ builder.append(entry.getKey() + "=" + entry.getValue());
+ if (i.hasNext())
+ builder.append(",");
+ }
+ return builder.toString();
+ }
+
+ /**
+ * <p>
+ * Returns the name as a string in canonical form. More precisely,
+ * this returns a string of the format
+ * &lt;domain&gt;:&lt;properties&gt;&lt;wild&gt;. &lt;properties&gt;
+ * is the same value as returned by
+ * {@link #getCanonicalKeyPropertyListString()}. &lt;wild&gt;
+ * is:
+ * </p>
+ * <ul>
+ * <li>an empty string, if the object name is not a property pattern.</li>
+ * <li>'*' if &lt;properties&gt; is empty.</li>
+ * <li>',*' if there is at least one key-value pair.</li>
+ * </ul>
+ *
+ * @return the canonical string form of the object name, as specified
+ * above.
+ */
+ public String getCanonicalName()
+ {
+ return domain + ":" +
+ getCanonicalKeyPropertyListString() +
+ (isPropertyPattern() ? (properties.isEmpty() ? "*" : ",*") : "");
+ }
+
+ /**
+ * Returns the domain part of the object name.
+ *
+ * @return the domain.
+ */
+ public String getDomain()
+ {
+ return domain;
+ }
+
+ /**
+ * Returns an {@link ObjectName} instance that is substitutable for the
+ * one given. The instance returned may be a subclass of {@link ObjectName},
+ * but is not guaranteed to be of the same type as the given name, if that
+ * should also turn out to be a subclass. The returned instance may or may
+ * not be equivalent to the one given. The purpose of this method is to provide
+ * an instance of {@link ObjectName} with a well-defined semantics, such as may
+ * be used in cases where the given name is not trustworthy.
+ *
+ * @param name the {@link ObjectName} to provide a substitute for.
+ * @return a substitute for the given name, which may or may not be a subclass
+ * of {@link ObjectName}. In either case, the returned object is
+ * guaranteed to have the semantics defined here.
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
+ */
+ public static ObjectName getInstance(ObjectName name)
+ {
+ try
+ {
+ return new ObjectName(name.getCanonicalName());
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw (InternalError)
+ (new InternalError("The canonical name of " +
+ "the given name is invalid.").initCause(e));
+ }
+ }
+
+ /**
+ * Returns an {@link ObjectName} instance for the specified name, represented
+ * as a {@link java.lang.String}. The instance returned may be a subclass of
+ * {@link ObjectName} and may or may not be equivalent to earlier instances
+ * returned by this method for the same string.
+ *
+ * @param name the {@link ObjectName} to provide an instance of.
+ * @return a instance for the given name, which may or may not be a subclass
+ * of {@link ObjectName}.
+ * @throws MalformedObjectNameException the domain, a key or a value
+ * contains an illegal
+ * character or a value
+ * does not follow the quoting
+ * specifications.
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
+ */
+ public static ObjectName getInstance(String name)
+ throws MalformedObjectNameException
+ {
+ return new ObjectName(name);
+ }
+
+ /**
+ * Returns an {@link ObjectName} instance for the specified name, represented
+ * as a series of {@link java.lang.String} objects for the domain and a single
+ * property, as a key-value pair. The instance returned may be a subclass of
+ * {@link ObjectName} and may or may not be equivalent to earlier instances
+ * returned by this method for the same parameters.
+ *
+ * @param domain the domain part of the object name.
+ * @param key the key of the property.
+ * @param value the value of the property.
+ * @return a instance for the given name, which may or may not be a subclass
+ * of {@link ObjectName}.
+ * @throws MalformedObjectNameException the domain, a key or a value
+ * contains an illegal
+ * character or a value
+ * does not follow the quoting
+ * specifications.
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
+ */
+ public static ObjectName getInstance(String domain, String key, String value)
+ throws MalformedObjectNameException
+ {
+ return new ObjectName(domain, key, value);
+ }
+
+ /**
+ * Returns an {@link ObjectName} instance for the specified name, represented
+ * as a domain {@link java.lang.String} and a table of properties. The
+ * instance returned may be a subclass of {@link ObjectName} and may or may
+ * not be equivalent to earlier instances returned by this method for the
+ * same string.
+ *
+ * @param domain the domain part of the object name.
+ * @param properties the key-value property pairs.
+ * @return a instance for the given name, which may or may not be a subclass
+ * of {@link ObjectName}.
+ * @throws MalformedObjectNameException the domain, a key or a value
+ * contains an illegal
+ * character or a value
+ * does not follow the quoting
+ * specifications.
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
+ */
+ public static ObjectName getInstance(String domain, Hashtable properties)
+ throws MalformedObjectNameException
+ {
+ return new ObjectName(domain, properties);
+ }
+
+ /**
+ * Returns the property value corresponding to the given key.
+ *
+ * @param key the key of the property to be obtained.
+ * @return the value of the specified property.
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
+ */
+ public String getKeyProperty(String key)
+ {
+ if (key == null)
+ throw new NullPointerException("Null key given in request for a value.");
+ return (String) properties.get(key);
+ }
+
+ /**
+ * Returns the properties in a {@link java.util.Hashtable}. The table
+ * contains each of the properties as keys mapped to their value. The
+ * returned table may be unmodifiable. If the case that the table is
+ * modifiable, changes made to it will not be reflected in the object
+ * name.
+ *
+ * @return a {@link java.util.Hashtable}, containing each of the object
+ * name's properties.
+ */
+ public Hashtable getKeyPropertyList()
+ {
+ return (Hashtable) Collections.unmodifiableMap(new Hashtable(properties));
+ }
+
+ /**
+ * Returns a {@link java.lang.String} representation of the property
+ * list. If the object name was created using {@link
+ * ObjectName(String)}, then this string will contain the properties
+ * in the same order they were given in at creation.
+ *
+ * @return the property list.
+ */
+ public String getKeyPropertyListString()
+ {
+ if (propertyListString != null)
+ return propertyListString;
+ return getCanonicalKeyPropertyListString();
+ }
+
+ /**
+ * Returns a hash code for this object name. This is calculated as the
+ * summation of the hash codes of the domain and the properties.
+ *
+ * @return a hash code for this object name.
+ */
+ public int hashCode()
+ {
+ return domain.hashCode() + properties.hashCode();
+ }
+
+ /**
+ * Returns true if the domain of this object name is a pattern.
+ * This is the case if it contains one or more wildcard characters
+ * ('*' or '?').
+ *
+ * @return true if the domain is a pattern.
+ */
+ public boolean isDomainPattern()
+ {
+ return domain.contains("?") || domain.contains("*");
+ }
+
+ /**
+ * Returns true if this is an object name pattern. An object
+ * name pattern has a domain containing a wildcard character
+ * ('*' or '?') and/or a '*' in the list of properties.
+ * This method will return true if either {@link #isDomainPattern()}
+ * or {@link #isPropertyPattern()} does.
+ *
+ * @return true if this is an object name pattern.
+ */
+ public boolean isPattern()
+ {
+ return isDomainPattern() || isPropertyPattern();
+ }
+
+ /**
+ * Returns true if this object name is a property pattern. This is
+ * the case if the list of properties contains an '*'.
+ *
+ * @return true if this is a property pattern.
+ */
+ public boolean isPropertyPattern()
+ {
+ return propertyPattern;
+ }
+
+ /**
+ * <p>
+ * Returns a quoted version of the supplied string. The string may
+ * contain any character. The resulting quoted version is guaranteed
+ * to be usable as the value of a property, so this method provides
+ * a good way of ensuring that a value is legal.
+ * </p>
+ * <p>
+ * The string is transformed as follows:
+ * </p>
+ * <ul>
+ * <li>The string is prefixed with an opening quote character, '"'.
+ * <li>For each character, s:
+ * <ul>
+ * <li>If s is a quote ('"'), it is replaced by a backslash
+ * followed by a quote.</li>
+ * <li>If s is a star ('*'), it is replaced by a backslash followed
+ * by a star.</li>
+ * <li>If s is a question mark ('?'), it is replaced by a backslash
+ * followed by a question mark.</li>
+ * <li>If s is a backslash ('\'), it is replaced by two backslashes.</li>
+ * <li>If s is a newline character, it is replaced by a backslash followed by
+ * a '\n'.</li>
+ * <li>Otherwise, s is used verbatim.
+ * </ul></li>
+ * <li>The string is terminated with a closing quote character, '"'.</li>
+ * </ul>
+ *
+ * @param string the string to quote.
+ * @return a quoted version of the supplied string.
+ * @throws NullPointerException if <code>string</code> is <code>null</code>.
+ */
+ public static String quote(String string)
+ {
+ StringBuilder builder = new StringBuilder('"');
+ for (int a = 0; a < string.length(); ++a)
+ {
+ char s = string.charAt(a);
+ switch (s)
+ {
+ case '"':
+ builder.append("\\\"");
+ break;
+ case '*':
+ builder.append("\\*");
+ break;
+ case '?':
+ builder.append("\\?");
+ break;
+ case '\\':
+ builder.append("\\\\");
+ break;
+ case '\n':
+ builder.append("\\\n");
+ break;
+ default:
+ builder.append(s);
+ }
+ }
+ builder.append('"');
+ return builder.toString();
+ }
+
+ /**
+ * Changes the {@link MBeanServer} on which this query is performed.
+ *
+ * @param server the new server to use.
+ */
+ public void setMBeanServer(MBeanServer server)
+ {
+ this.server = server;
+ }
+
+ /**
+ * Returns a textual representation of the object name.
+ * The format is unspecified, but it should be expected that
+ * two equivalent object names will return the same string
+ * from this method.
+ *
+ * @return a textual representation of the object name.
+ */
+ public String toString()
+ {
+ return getClass().toString() +
+ "[domain = " + domain +
+ ",properties = " + properties +
+ ",propertyPattern = " + propertyPattern +
+ "]";
+ }
+
+ /**
+ * Unquotes the supplied string. The quotation marks are removed as
+ * are the backslashes preceding the escaped characters ('"', '?',
+ * '*', '\n', '\\'). A one-to-one mapping exists between quoted and
+ * unquoted values. As a result, a string <code>s</code> should be
+ * equal to <code>unquote(quote(s))</code>.
+ *
+ * @param q the quoted string to unquote.
+ * @return the unquoted string.
+ * @throws NullPointerException if <code>q</code> is <code>null</code>.
+ * @throws IllegalArgumentException if the string is not a valid
+ * quoted string i.e. it is not
+ * surrounded by quotation marks
+ * and/or characters are not properly
+ * escaped.
+ */
+ public static String unquote(String q)
+ {
+ if (q.charAt(0) != '"')
+ throw new IllegalArgumentException("The string does " +
+ "not start with a quote.");
+ if (q.charAt(q.length() - 1) != '"')
+ throw new IllegalArgumentException("The string does " +
+ "not end with a quote.");
+ StringBuilder builder = new StringBuilder();
+ for (int a = 1; a < (q.length() - 1); ++a)
+ {
+ char n = q.charAt(a);
+ if (n == '\\')
+ {
+ n = q.charAt(++a);
+ if (n != '"' && n != '?' && n != '*' &&
+ n != '\n' && n != '\\')
+ throw new IllegalArgumentException("Illegal escaped character: "
+ + n);
+ }
+ builder.append(n);
+ }
+
+ return builder.toString();
+ }
+
+}
diff --git a/libjava/classpath/javax/management/QueryExp.java b/libjava/classpath/javax/management/QueryExp.java
new file mode 100644
index 00000000000..124228c784a
--- /dev/null
+++ b/libjava/classpath/javax/management/QueryExp.java
@@ -0,0 +1,87 @@
+/* QueryExp.java -- Represents a query expression.
+ 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;
+
+import java.io.Serializable;
+
+/**
+ * Applies the type of relational constraints seen in the
+ * <code>where</code> clauses of databases to an
+ * {@link ObjectName}. Instances of this class are usually
+ * returned by the static methods of the {@link Query} classes.
+ * If a custom implementation is required, it is better to
+ * extend the {@link QueryEval} class, rather than simply
+ * implementing this interface, in order to ensure that
+ * the {@link #setMBeanServer(MBeanServer)} method functions
+ * correctly.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface QueryExp
+ extends Serializable
+{
+
+ /**
+ * Applies the query to the specified management bean.
+ *
+ * @param name the name of the management bean.
+ * @return true if the query was applied successfully.
+ * @throws BadStringOperationException if an invalid string
+ * operation is used by
+ * the query.
+ * @throws BadBinaryOpValueExpException if an invalid expression
+ * is used by the query.
+ * @throws BadAttributeValueExpException if an invalid attribute
+ * is used by the query.
+ * @throws InvalidApplicationException if the query is applied
+ * to the wrong type of bean.
+ */
+ boolean apply(ObjectName name)
+ throws BadStringOperationException, BadBinaryOpValueExpException,
+ BadAttributeValueExpException, InvalidApplicationException;
+
+ /**
+ * Changes the {@link MBeanServer} on which this query is performed.
+ *
+ * @param server the new server to use.
+ */
+ void setMBeanServer(MBeanServer server);
+
+}
+
diff --git a/libjava/classpath/javax/management/RuntimeErrorException.java b/libjava/classpath/javax/management/RuntimeErrorException.java
new file mode 100644
index 00000000000..811dc40f2fb
--- /dev/null
+++ b/libjava/classpath/javax/management/RuntimeErrorException.java
@@ -0,0 +1,115 @@
+/* RuntimeErrorException.java -- A user-defined management error.
+ 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;
+
+/**
+ * Represents an arbitrary error thrown by a management
+ * bean. When a management bean executes code that causes
+ * an error to be thrown, the resulting error is
+ * wrapped inside an {@link RuntimeErrorException}. Calling
+ * {@link getTargetError()} will return the wrapped
+ * exception.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class RuntimeErrorException
+ extends JMRuntimeException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 704338937753949796L;
+
+ /**
+ * The target error.
+ *
+ * @serial the target error.
+ */
+ private Error error;
+
+ /**
+ * Constructs a new <code>RuntimeErrorException</code> wrapping
+ * the specified error.
+ *
+ * @param e the error to be wrapped.
+ */
+ public RuntimeErrorException(Error e)
+ {
+ super();
+ error = e;
+ }
+
+ /**
+ * Constructs a new <code>RuntimeErrorException</code> wrapping
+ * the specified error and using the supplied message.
+ *
+ * @param e the error to be wrapped.
+ * @param message the error message to give to the user.
+ */
+ public RuntimeErrorException(Error e, String message)
+ {
+ super(message);
+ error = e;
+ }
+
+ /**
+ * Returns the true cause of this error, the wrapped
+ * error.
+ *
+ * @return the wrapped error.
+ */
+ public Throwable getCause()
+ {
+ return error;
+ }
+
+ /**
+ * Returns the true cause of this error, the wrapped
+ * error.
+ *
+ * @return the wrapped error.
+ */
+ public Error getTargetError()
+ {
+ return error;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/RuntimeMBeanException.java b/libjava/classpath/javax/management/RuntimeMBeanException.java
new file mode 100644
index 00000000000..95225a80ab7
--- /dev/null
+++ b/libjava/classpath/javax/management/RuntimeMBeanException.java
@@ -0,0 +1,114 @@
+/* RuntimeMBeanException.java -- A user-defined management exception.
+ 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;
+
+/**
+ * Represents an arbitrary runtime exception thrown by a management
+ * bean. When a management bean executes code that causes a runtime
+ * exception to be thrown, the resulting exception is wrapped inside a
+ * {@link RuntimeMBeanException}. Calling {@link
+ * getTargetException()} will return the wrapped exception.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class RuntimeMBeanException
+ extends JMRuntimeException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 5274912751982730171L;
+
+ /**
+ * The target exception.
+ *
+ * @serial the target exception.
+ */
+ private RuntimeException runtimeException;
+
+ /**
+ * Constructs a new <code>RuntimeMBeanException</code> wrapping
+ * the specified exception.
+ *
+ * @param e the exception to be wrapped.
+ */
+ public RuntimeMBeanException(RuntimeException e)
+ {
+ super();
+ runtimeException = e;
+ }
+
+ /**
+ * Constructs a new <code>RuntimeMBeanException</code> wrapping
+ * the specified exception and using the supplied message.
+ *
+ * @param e the exception to be wrapped.
+ * @param message the error message to give to the user.
+ */
+ public RuntimeMBeanException(RuntimeException e, String message)
+ {
+ super(message);
+ runtimeException = e;
+ }
+
+ /**
+ * Returns the true cause of this exception, the wrapped runtime
+ * exception.
+ *
+ * @return the wrapped exception.
+ */
+ public Throwable getCause()
+ {
+ return runtimeException;
+ }
+
+ /**
+ * Returns the true cause of this exception, the wrapped runtime
+ * exception.
+ *
+ * @return the wrapped exception.
+ */
+ public RuntimeException getTargetException()
+ {
+ return runtimeException;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/ServiceNotFoundException.java b/libjava/classpath/javax/management/ServiceNotFoundException.java
new file mode 100644
index 00000000000..602e1490db4
--- /dev/null
+++ b/libjava/classpath/javax/management/ServiceNotFoundException.java
@@ -0,0 +1,75 @@
+/* ServiceNotFoundException.java -- Thrown by invalid values.
+ 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;
+
+/**
+ * Thrown when a requested service is unsupported.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class ServiceNotFoundException
+ extends OperationsException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -3990675661956646827L;
+
+ /**
+ * Constructs a new <code>ServiceNotFoundException</code>.
+ */
+ public ServiceNotFoundException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>ServiceNotFoundException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public ServiceNotFoundException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/StandardMBean.java b/libjava/classpath/javax/management/StandardMBean.java
index 736192ee2ac..16b6f0b6687 100644
--- a/libjava/classpath/javax/management/StandardMBean.java
+++ b/libjava/classpath/javax/management/StandardMBean.java
@@ -205,17 +205,13 @@ public class StandardMBean
Method getter;
try
{
- getter = iface.getMethod("get" +
- name.substring(0, 1).toUpperCase() +
- name.substring(1), null);
+ getter = iface.getMethod("get" + name, null);
}
catch (NoSuchMethodException e)
{
try
{
- getter = iface.getMethod("is" +
- name.substring(0, 1).toUpperCase() +
- name.substring(1), null);
+ getter = iface.getMethod("is" + name, null);
}
catch (NoSuchMethodException ex)
{
@@ -564,11 +560,9 @@ public class StandardMBean
Method[] amethods;
String attrib;
if (name.startsWith("is"))
- attrib = name.substring(2,3).toLowerCase()
- + name.substring(3);
+ attrib = name.substring(2);
else
- attrib = name.substring(3,4).toLowerCase()
- + name.substring(4);
+ attrib = name.substring(3);
if (attributes.containsKey(attrib))
amethods = (Method[]) attributes.get(attrib);
else
@@ -583,8 +577,7 @@ public class StandardMBean
methods[a].getParameterTypes().length == 1)
{
Method[] amethods;
- String attrib = name.substring(3,4).toLowerCase()
- + name.substring(4);
+ String attrib = name.substring(3);
if (attributes.containsKey(attrib))
amethods = (Method[]) attributes.get(attrib);
else
@@ -595,7 +588,8 @@ public class StandardMBean
amethods[1] = methods[a];
}
else
- operations.add(new MBeanOperationInfo("", methods[a]));
+ operations.add(new MBeanOperationInfo(methods[a].getName(),
+ methods[a]));
}
List attribs = new ArrayList(attributes.size());
Iterator it = attributes.entrySet().iterator();
@@ -605,7 +599,8 @@ public class StandardMBean
Method[] amethods = (Method[]) entry.getValue();
try
{
- attribs.add(new MBeanAttributeInfo((String) entry.getKey(), "",
+ attribs.add(new MBeanAttributeInfo((String) entry.getKey(),
+ (String) entry.getKey(),
amethods[0], amethods[1]));
}
catch (IntrospectionException e)
@@ -632,7 +627,8 @@ public class StandardMBean
MBeanConstructorInfo[] cinfo = new MBeanConstructorInfo[cons.length];
for (int a = 0; a < cinfo.length; ++a)
{
- MBeanConstructorInfo oldInfo = new MBeanConstructorInfo("", cons[a]);
+ MBeanConstructorInfo oldInfo = new MBeanConstructorInfo(cons[a].getName(),
+ cons[a]);
String desc = getDescription(oldInfo);
MBeanParameterInfo[] params = oldInfo.getSignature();
MBeanParameterInfo[] pinfo = new MBeanParameterInfo[params.length];
@@ -665,8 +661,8 @@ public class StandardMBean
oinfo[a] = new MBeanOperationInfo(oldInfo.getName(), desc, pinfo,
oldInfo.getReturnType(), impact);
}
- info = new MBeanInfo(impl.getClass().getName(), "", ainfo, cinfo,
- oinfo, null);
+ info = new MBeanInfo(impl.getClass().getName(), impl.getClass().getName(),
+ ainfo, cinfo, oinfo, null);
String cname = getClassName(info);
String desc = getDescription(info);
info = new MBeanInfo(cname, desc, ainfo, cinfo, oinfo, null);
@@ -679,7 +675,7 @@ public class StandardMBean
*
* @return the management interface.
*/
- public Class getMBeanInterface()
+ public final Class getMBeanInterface()
{
return iface;
}
diff --git a/libjava/classpath/javax/management/ValueExp.java b/libjava/classpath/javax/management/ValueExp.java
new file mode 100644
index 00000000000..503f2322194
--- /dev/null
+++ b/libjava/classpath/javax/management/ValueExp.java
@@ -0,0 +1,86 @@
+/* ValueExp.java -- Represents values that can be passed to queries.
+ 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;
+
+import java.io.Serializable;
+
+/**
+ * Represents values that may be passed as arguments to
+ * {@link QueryExp}s. Strings, numbers and bean attributes
+ * are all valid argument types for query expressions, and
+ * so should be represented as implementations of this
+ * interface.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface ValueExp
+ extends Serializable
+{
+
+ /**
+ * Applies the value expression to the specified management bean.
+ *
+ * @param name the name of the management bean.
+ * @return the value expression.
+ * @throws BadStringOperationException if an invalid string
+ * operation is used by
+ * the value expression.
+ * @throws BadBinaryOpValueExpException if an invalid expression
+ * is used by the value expression.
+ * @throws BadAttributeValueExpException if an invalid attribute
+ * is used by the value expression.
+ * @throws InvalidApplicationException if the value expression is applied
+ * to the wrong type of bean.
+ */
+ ValueExp apply(ObjectName name)
+ throws BadStringOperationException, BadBinaryOpValueExpException,
+ BadAttributeValueExpException, InvalidApplicationException;
+
+ /**
+ * Changes the {@link MBeanServer} on which this query is performed.
+ *
+ * @param server the new server to use.
+ * @deprecated This method is superfluous, as the {@link ValueExp}
+ * can access the server using
+ * {@link QueryEval#getMBeanServer()}.
+ */
+ void setMBeanServer(MBeanServer server);
+
+}
+
diff --git a/libjava/classpath/javax/management/loading/ClassLoaderRepository.java b/libjava/classpath/javax/management/loading/ClassLoaderRepository.java
new file mode 100644
index 00000000000..e2c8b7c5bf7
--- /dev/null
+++ b/libjava/classpath/javax/management/loading/ClassLoaderRepository.java
@@ -0,0 +1,139 @@
+/* ClassLoaderRepository.java -- Represents a collection of class loadersx.
+ 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.loading;
+
+/**
+ * Implementations of this interface maintain a list of
+ * {@link ClassLoader}s for use by the management servers,
+ * allowing classes to be loaded by the first {@link ClassLoader}
+ * that will do so. A class loader is added to the list
+ * whenever a {@link ClassLoader} instance is registered with
+ * the management server, and it does not implement the
+ * {@link PrivateClassLoader} interface. They are removed when
+ * unregistered. The first class loader in the list is always
+ * the one which was used to load the management server itself.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ * @see MBeanServerFactory
+ */
+public interface ClassLoaderRepository
+{
+
+ /**
+ * Attempts to load the given class using class loaders
+ * supplied by the list. The {@link ClassLoader#loadClass(String)}
+ * method of each class loader is called. If the method
+ * returns successfully, then the returned {@link Class} instance
+ * is returned. If a {@link ClassNotFoundException} is thrown,
+ * then the next loader is tried. Any other exception thrown
+ * by the method is passed back to the caller. This method
+ * throws a {@link ClassNotFoundException} itself if all the
+ * class loaders listed prove fruitless.
+ *
+ * @param name the name of the class to load.
+ * @return the loaded class.
+ * @throws ClassNotFoundException if all the class loaders fail
+ * to load the class.
+ */
+ Class loadClass(String name)
+ throws ClassNotFoundException;
+
+ /**
+ * <p>
+ * Attempts to load the given class using class loaders
+ * supplied by the list, stopping when the specified
+ * loader is reached. The {@link ClassLoader#loadClass(String)}
+ * method of each class loader is called. If the method
+ * returns successfully, then the returned {@link Class} instance
+ * is returned. If a {@link ClassNotFoundException} is thrown,
+ * then the next loader is tried. Any other exception thrown
+ * by the method is passed back to the caller. This method
+ * throws a {@link ClassNotFoundException} itself if all the
+ * class loaders listed prove fruitless.
+ * </p>
+ * <p>
+ * This method is usually used by the class loader specified
+ * by the <code>stop</code> argument to load classes using the
+ * loaders that appear before it in the list. By stopping when
+ * the loader is reached, the deadlock that occurs when the loader
+ * is merely skipped is avoided.
+ * </p>
+ *
+ * @param stop the class loader at which to stop, or <code>null</code>
+ * to obtain the same behaviour as {@link #loadClass(String)}.
+ * @param name the name of the class to load.
+ * @return the loaded class.
+ * @throws ClassNotFoundException if all the class loaders fail
+ * to load the class.
+ */
+ Class loadClassBefore(ClassLoader stop, String name)
+ throws ClassNotFoundException;
+
+ /**
+ * <p>
+ * Attempts to load the given class using class loaders
+ * supplied by the list, excluding the one specified.
+ * The {@link ClassLoader#loadClass(String)}
+ * method of each class loader is called. If the method
+ * returns successfully, then the returned {@link Class} instance
+ * is returned. If a {@link ClassNotFoundException} is thrown,
+ * then the next loader is tried. Any other exception thrown
+ * by the method is passed back to the caller. This method
+ * throws a {@link ClassNotFoundException} itself if all the
+ * class loaders listed prove fruitless.
+ * </p>
+ * <p>
+ * Note that this method may deadlock if called simultaneously
+ * by two class loaders in the list.
+ * {@link loadClassBefore(ClassLoader, String)} should be used
+ * in preference to this method to avoid this.
+ * </p>
+ *
+ * @param exclude the class loader to exclude, or <code>null</code>
+ * to obtain the same behaviour as {@link #loadClass(String)}.
+ * @param name the name of the class to load.
+ * @return the loaded class.
+ * @throws ClassNotFoundException if all the class loaders fail
+ * to load the class.
+ */
+ Class loadClassWithout(ClassLoader exclude, String name)
+ throws ClassNotFoundException;
+
+}
+
diff --git a/libjava/classpath/javax/management/openmbean/InvalidOpenTypeException.java b/libjava/classpath/javax/management/openmbean/InvalidOpenTypeException.java
new file mode 100644
index 00000000000..9c9ff8cfab8
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/InvalidOpenTypeException.java
@@ -0,0 +1,76 @@
+/* InvalidOpenTypeException.java -- Thrown by an invalid open type.
+ 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;
+
+/**
+ * Thrown when a open data value has an erroneous open
+ * type.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class InvalidOpenTypeException
+ extends IllegalArgumentException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -2837312755412327534L;
+
+ /**
+ * Constructs a new <code>InvalidOpenTypeException</code>.
+ */
+ public InvalidOpenTypeException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>InvalidOpenTypeException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public InvalidOpenTypeException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/openmbean/KeyAlreadyExistsException.java b/libjava/classpath/javax/management/openmbean/KeyAlreadyExistsException.java
new file mode 100644
index 00000000000..cc6bba63621
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/KeyAlreadyExistsException.java
@@ -0,0 +1,77 @@
+/* KeyAlreadyExistsException.java -- Thrown when a key clashes with another.
+ 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;
+
+/**
+ * Thrown when a key (a field name or row index) is passed to a method
+ * of the {@link CompositeData} or {@link TabularData} classes and it
+ * is found to already be in use.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class KeyAlreadyExistsException
+ extends IllegalArgumentException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 1845183636745282866L;
+
+ /**
+ * Constructs a new <code>KeyAlreadyExistsException</code>.
+ */
+ public KeyAlreadyExistsException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>KeyAlreadyExistsException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public KeyAlreadyExistsException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfo.java
new file mode 100644
index 00000000000..1b276fd197f
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfo.java
@@ -0,0 +1,120 @@
+/* OpenMBeanAttributeInfo.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;
+
+/**
+ * Describes an attribute associated with an open management bean.
+ * This interface includes those methods specified by {@link
+ * javax.management.MBeanAttributeInfo}, so implementations should
+ * extend this class.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface OpenMBeanAttributeInfo
+ extends OpenMBeanParameterInfo
+{
+
+ /**
+ * Compares this attribute with the supplied object. This returns
+ * true iff the object is an instance of {@link OpenMBeanAttributeInfo}
+ * with an equal name and open type, the same default, minimum,
+ * maximum and legal values and the same access properties
+ * ({@link #isIs()}, {@link #isReadable()}, {@link #isWritable()}).
+ *
+ * @param obj the object to compare.
+ * @return true if the object is a {@link OpenMBeanParameterInfo}
+ * instance,
+ * <code>name.equals(object.getName())</code>,
+ * <code>openType.equals(object.getOpenType())</code>,
+ * <code>defaultValue.equals(object.getDefaultValue())</code>,
+ * <code>minValue.equals(object.getMinValue())</code>,
+ * <code>maxValue.equals(object.getMaxValue())</code>,
+ * <code>legalValues.equals(object.getLegalValues())</code>,
+ * <code>is == object.isIs()</code>,
+ * <code>isRead == object.isReadable()</code>,
+ * and <code>isWrite == object.isWritable()</code>.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hashcode of the attribute information as the sum of
+ * the hashcodes of the name, open type, default value, maximum
+ * value, minimum value, the set of legal values and the access
+ * properties.
+ *
+ * @return the hashcode of the attribute information.
+ */
+ int hashCode();
+
+ /**
+ * Returns true if the accessor method of this attribute
+ * is of the form <code>isXXX</code>.
+ *
+ * @return true if the accessor takes the form <code>isXXX</code>.
+ */
+ boolean isIs();
+
+ /**
+ * Returns true if value of this attribute can be read.
+ *
+ * @return true if the value of the attribute can be read.
+ */
+ boolean isReadable();
+
+ /**
+ * Returns true if the value of this attribute can be changed.
+ *
+ * @return true if the value of the attribute can be changed.
+ */
+ boolean isWritable();
+
+ /**
+ * 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, default, minimum, maximum
+ * and legal values of the parameter and the access permissions
+ * ({@link #isIs()}, {@link #isReadable()}, {@link #isWritable()}).
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ String toString();
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
new file mode 100644
index 00000000000..83e043640b4
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
@@ -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 (gnu_andrew@member.fsf.org)
+ * @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 {@link 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 {@link 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, {@link ArrayType} and {@link
+ * 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 {@link ArrayType} or {@link 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 {@link 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, {@link
+ * ArrayType} and {@link 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 {@link 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, {@link
+ * ArrayType} and {@link 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 {@link 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 {@link 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 {@link 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;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfo.java
new file mode 100644
index 00000000000..34cef131f26
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfo.java
@@ -0,0 +1,112 @@
+/* OpenMBeanConstructorInfo.java -- Open typed info about a 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 javax.management.MBeanParameterInfo;
+
+/**
+ * Describes a constructor for an open management bean.
+ * This interface includes those methods specified by {@link
+ * javax.management.MBeanConstructorInfo}, so implementations should
+ * extend this class. The {@link #getSignature()} method should
+ * return an array containing instances of {@link OpenMBeanParameterInfo}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface OpenMBeanConstructorInfo
+{
+
+ /**
+ * Compares this attribute with the supplied object. This returns
+ * true iff the object is an instance of {@link OpenMBeanConstructorInfo}
+ * with an equal name and signature.
+ *
+ * @param obj the object to compare.
+ * @return true if the object is a {@link OpenMBeanParameterInfo}
+ * instance,
+ * <code>name.equals(object.getName())</code>,
+ * and <code>signature.equals(object.getSignature())</code>.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns a description of this constructor.
+ *
+ * @return a human-readable description.
+ */
+ String getDescription();
+
+ /**
+ * Returns the name of this constructor.
+ *
+ * @return the name of the constructor.
+ */
+ String getName();
+
+ /**
+ * Returns the constructor's signature, in the form of
+ * information on each parameter. Each parameter is
+ * described by an instance of {@link OpenMBeanParameterInfo}.
+ *
+ * @return an array of {@link OpenMBeanParameterInfo} objects,
+ * describing the constructor parameters.
+ */
+ MBeanParameterInfo[] getSignature();
+
+ /**
+ * 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>).
+ *
+ * @return the hashcode of the constructor information.
+ */
+ int hashCode();
+
+ /**
+ * 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.
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ String toString();
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java
new file mode 100644
index 00000000000..9dac01a596a
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java
@@ -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 (gnu_andrew@member.fsf.org)
+ * @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 {@link 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
+ * {@link 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 {@link OpenMBeanConstructorInfo}
+ * with an equal name and signature.
+ *
+ * @param obj the object to compare.
+ * @return true if the object is a {@link 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=" + Arrays.toString(getSignature())
+ + "]";
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanInfo.java
new file mode 100644
index 00000000000..5aa4df4511c
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanInfo.java
@@ -0,0 +1,154 @@
+/* OpenMBeanInfo.java -- Open typed info about a management 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 javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanOperationInfo;
+
+/**
+ * Describes an open management bean. Open management beans are
+ * management beans where {@link
+ * javax.management.DynamicMBean#getMBeanInfo()} returns an
+ * implementation of this interface. This interface includes those
+ * methods specified by {@link javax.management.MBeanInfo},
+ * so implementations should extend this class. Each method
+ * which returns an array of one of the <code>MBeanXXXInfo</code>
+ * classes should return an array containing instances
+ * of the equivalent open version (<code>OpenMBeanXXXInfo</code>).
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface OpenMBeanInfo
+{
+
+ /**
+ * Compares this attribute with the supplied object. This returns
+ * true iff the object is an instance of {@link 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 {@link OpenMBeanInfo}
+ * instance,
+ * <code>className.equals(object.getClassName())</code>
+ * and each info class has an equal in the other object.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns descriptions of each of the attributes provided by this
+ * management bean. The elements should be implementations of the
+ * {@link OpenMBeanAttributeInfo} class.
+ *
+ * @return an array of {@link OpenMBeanAttributeInfo} objects,
+ * representing the attributes emitted by this
+ * management bean.
+ */
+ MBeanAttributeInfo[] getAttributes();
+
+ /**
+ * Returns the class name of the management bean.
+ *
+ * @return the bean's class name.
+ */
+ String getClassName();
+
+ /**
+ * Returns descriptions of each of the constructors provided by this
+ * management bean. The elements should be implementations of the
+ * {@link OpenMBeanConstructorInfo} class.
+ *
+ * @return an array of {@link OpenMBeanConstructorInfo} objects,
+ * representing the constructors emitted by this
+ * management bean.
+ */
+ MBeanConstructorInfo[] getConstructors();
+
+ /**
+ * Returns a description of this operation.
+ *
+ * @return a human-readable description.
+ */
+ String getDescription();
+
+ /**
+ * Returns descriptions of each of the notifications provided by this
+ * management bean. The elements should be implementations of the
+ * {@link OpenMBeanNotificationInfo} class.
+ *
+ * @return an array of {@link OpenMBeanNotificationInfo} objects,
+ * representing the notifications emitted by this
+ * management bean.
+ */
+ MBeanNotificationInfo[] getNotifications();
+
+ /**
+ * Returns descriptions of each of the operations provided by this
+ * management bean. The elements should be implementations of the
+ * {@link OpenMBeanOperationInfo} class.
+ *
+ * @return an array of {@link OpenMBeanOperationInfo} objects,
+ * representing the operations emitted by this
+ * management bean.
+ */
+ MBeanOperationInfo[] getOperations();
+
+ /**
+ * 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>).
+ *
+ * @return the hashcode of the bean information.
+ */
+ int hashCode();
+
+ /**
+ * 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.
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ String toString();
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java
new file mode 100644
index 00000000000..5f8d55b8377
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java
@@ -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 (gnu_andrew@member.fsf.org)
+ * @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 {@link 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 {@link 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 {@link 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=" + Arrays.toString(getAttributes())
+ + ",constructors=" + Arrays.toString(getConstructors())
+ + ",notifications=" + Arrays.toString(getNotifications())
+ + ",operations=" + Arrays.toString(getOperations())
+ + "]";
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java
new file mode 100644
index 00000000000..8b61329d966
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java
@@ -0,0 +1,154 @@
+/* OpenMBeanOperationInfo.java -- Open typed info about a 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 javax.management.MBeanParameterInfo;
+
+/**
+ * Describes a operation for an open management bean.
+ * This interface includes those methods specified by {@link
+ * javax.management.MBeanOperationInfo}, so implementations should
+ * extend this class. The {@link #getSignature()} method should
+ * return an array containing instances of {@link OpenMBeanParameterInfo}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface OpenMBeanOperationInfo
+{
+
+ /**
+ * Compares this attribute with the supplied object. This returns
+ * true iff the object is an instance of {@link OpenMBeanOperationInfo}
+ * with an equal name, signature, open return type and impact.
+ *
+ * @param obj the object to compare.
+ * @return true if the object is a {@link 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>.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns a description of this operation.
+ *
+ * @return a human-readable description.
+ */
+ String getDescription();
+
+ /**
+ * <p>
+ * Returns the impact of performing this operation.
+ * The value is equal to one of the following:
+ * </p>
+ * <ol>
+ * <li>{@link javax.management.MBeanOperationInfo#INFO}
+ * &mdash; the method just returns
+ * information (akin to an accessor).</li>
+ * <li>{@link javax.management.MBeanOperationInfo#ACTION}
+ * the method just alters the state of the bean, without
+ * returning a value (akin to a mutator).</li>
+ * <li>{@link javax.management.MBeanOperationInfo#ACTION_INFO}
+ * the method both makes state changes and returns a value.</li>
+ * <li>{@link javax.management.MBeanOperationInfo#UNKNOWN}
+ * the behaviour of the operation is unknown.</li>
+ * </ol>
+ *
+ * @return the impact of performing the operation.
+ */
+ int getImpact();
+
+ /**
+ * Returns the name of this operation.
+ *
+ * @return the name of the operation.
+ */
+ String getName();
+
+ /**
+ * Returns the open type instance which represents the type of the
+ * return value.
+ *
+ * @return the open type of the return value.
+ */
+ OpenType getReturnOpenType();
+
+ /**
+ * Returns the return type of the operation, as the class
+ * name. This should be identical to
+ * <code>getReturnOpenType.getClassName()</code>.
+ *
+ * @return the return type.
+ */
+ String getReturnType();
+
+ /**
+ * Returns the operation's signature, in the form of
+ * information on each parameter. Each parameter is
+ * described by an instance of {@link OpenMBeanParameterInfo}.
+ *
+ * @return an array of {@link OpenMBeanParameterInfo} objects,
+ * describing the operation parameters.
+ */
+ MBeanParameterInfo[] getSignature();
+
+ /**
+ * 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>).
+ *
+ * @return the hashcode of the operation information.
+ */
+ int hashCode();
+
+ /**
+ * 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.
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ String toString();
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java
new file mode 100644
index 00000000000..07564897c2c
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java
@@ -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 (gnu_andrew@member.fsf.org)
+ * @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
+ * ({@link javax.management.MBeanOperationInfo#INFO},
+ * {@link javax.management.MBeanOperationInfo#ACTION},
+ * {@link javax.management.MBeanOperationInfo#ACTION_INFO} and
+ * {@link 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 {@link 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
+ * {@link 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 {@link OpenMBeanOperationInfo}
+ * with an equal name, signature, open return type and impact.
+ *
+ * @param obj the object to compare.
+ * @return true if the object is a {@link 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=" + Arrays.toString(getSignature())
+ + ",returnOpenType=" + returnOpenType
+ + ",impact=" + impactString
+ + "]";
+ }
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java
new file mode 100644
index 00000000000..780e8ba1159
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java
@@ -0,0 +1,190 @@
+/* OpenMBeanParameterInfo.java -- Open typed info about a parameter.
+ 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.Set;
+
+/**
+ * Describes the parameters of a constructor or operation associated
+ * with an open management bean. This interface includes those methods
+ * specified by {@link javax.management.MBeanParameterInfo}, so
+ * implementations should extend this class.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface OpenMBeanParameterInfo
+{
+
+ /**
+ * Compares this parameter with the supplied object. This returns
+ * true iff the object is an instance of {@link OpenMBeanParameterInfo}
+ * with an equal name and open type and the same default, minimum,
+ * maximum and legal values.
+ *
+ * @param obj the object to compare.
+ * @return true if the object is a {@link OpenMBeanParameterInfo}
+ * instance,
+ * <code>name.equals(object.getName())</code>,
+ * <code>openType.equals(object.getOpenType())</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>.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the default value of this parameter, or <code>null</code>
+ * if there is no default value.
+ *
+ * @return the default value of the parameter, or <code>null</code>
+ * if there is no default.
+ */
+ Object getDefaultValue();
+
+ /**
+ * Returns a description of this parameter.
+ *
+ * @return a human-readable description.
+ */
+ String getDescription();
+
+ /**
+ * Returns a {@link java.util.Set} enumerating the legal values
+ * of this parameter, or <code>null</code> if no such limited
+ * set exists for this parameter.
+ *
+ * @return a set of legal values, or <code>null</code> if no such
+ * set exists.
+ */
+ Set getLegalValues();
+
+ /**
+ * Returns the maximum value of this parameter, or <code>null</code>
+ * if there is no maximum.
+ *
+ * @return the maximum value, or <code>null</code> if none exists.
+ */
+ Comparable getMaxValue();
+
+ /**
+ * Returns the minimum value of this parameter, or <code>null</code>
+ * if there is no minimum.
+ *
+ * @return the minimum value, or <code>null</code> if none exists.
+ */
+ Comparable getMinValue();
+
+ /**
+ * Returns the name of this parameter.
+ *
+ * @return the name of the parameter.
+ */
+ String getName();
+
+ /**
+ * Returns the open type instance which represents the type of this
+ * parameter.
+ *
+ * @return the open type of this parameter.
+ */
+ OpenType getOpenType();
+
+ /**
+ * Returns true if this parameter has a default value.
+ *
+ * @return true if this parameter has a default.
+ */
+ boolean hasDefaultValue();
+
+ /**
+ * Returns the hashcode of the parameter information as the sum of
+ * the hashcodes of the name, open type, default value, maximum
+ * value, minimum value and the set of legal values.
+ *
+ * @return the hashcode of the parameter information.
+ */
+ int hashCode();
+
+ /**
+ * Returns true if there is a set of legal values for this
+ * parameter.
+ *
+ * @return true if a set of legal values exists for this
+ * parameter.
+ */
+ boolean hasLegalValues();
+
+ /**
+ * Returns true if there is a maximum value for this parameter.
+ *
+ * @return true if a maximum value exists for this parameter.
+ */
+ boolean hasMaxValue();
+
+ /**
+ * Returns true if there is a minimum value for this parameter.
+ *
+ * @return true if a minimum value exists for this parameter.
+ */
+ boolean hasMinValue();
+
+ /**
+ * Returns true if the specified object is a valid value for
+ * this parameter.
+ *
+ * @param obj the object to test.
+ * @return true if <code>obj</code> is a valid value for this
+ * parameter.
+ */
+ boolean isValue(Object obj);
+
+ /**
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.openmbean.OpenMBeanParameterInfo</code>)
+ * along with the name, open type, default, minimum, maximum
+ * and legal values of the parameter.
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ String toString();
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
new file mode 100644
index 00000000000..af3bda6c738
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
@@ -0,0 +1,511 @@
+/* OpenMBeanParameterInfoSupport.java -- Open typed info about a parameter.
+ 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.MBeanParameterInfo;
+
+/**
+ * Describes the parameters of a constructor or operation associated
+ * with an open management bean.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class OpenMBeanParameterInfoSupport
+ extends MBeanParameterInfo
+ implements OpenMBeanParameterInfo
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -7235016873758443122L;
+
+ /**
+ * The open type of the parameter.
+ */
+ private OpenType openType;
+
+ /**
+ * The default value of the parameter (may be <code>null</code>).
+ */
+ private Object defaultValue;
+
+ /**
+ * The possible legal values of the parameter (may be <code>null</code>).
+ */
+ private Set legalValues;
+
+ /**
+ * The minimum value of the parameter (may be <code>null</code>).
+ */
+ private Comparable minValue;
+
+ /**
+ * The maximum value of the parameter (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 {@link OpenMBeanParameterInfo} using the specified
+ * name, description and open type. None of these values may be
+ * <code>null</code> and the name and description may not be equal
+ * to the empty string.
+ *
+ * @param name the name of the parameter.
+ * @param desc a description of the parameter.
+ * @param type the open type of the parameter.
+ * @throws IllegalArgumentException if the name, description or
+ * open type are <code>null</code>
+ * or the name or description are
+ * the empty string.
+ */
+ public OpenMBeanParameterInfoSupport(String name, String desc, OpenType type)
+ {
+ 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.");
+ openType = type;
+ }
+
+ /**
+ * Constructs a new {@link OpenMBeanParameterInfo} 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, {@link ArrayType} and {@link
+ * TabularType}.
+ *
+ * @param name the name of the parameter.
+ * @param desc a description of the parameter.
+ * @param type the open type of the parameter.
+ * @param defaultValue the default value of the parameter.
+ * @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 {@link ArrayType} or {@link TabularType}.
+ */
+ public OpenMBeanParameterInfoSupport(String name, String desc, OpenType type,
+ Object defaultValue)
+ throws OpenDataException
+ {
+ this(name, desc, type, defaultValue, null);
+ }
+
+ /**
+ * <p>
+ * Constructs a new {@link OpenMBeanParameterInfo} using the
+ * specified name, description, open type, 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
+ * parameters 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, {@link
+ * ArrayType} and {@link 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 parameter.
+ * @param desc a description of the parameter.
+ * @param type the open type of the parameter.
+ * @param defaultValue the default value of the parameter, or <code>null</code>.
+ * @param minimumValue the minimum value of the parameter, or <code>null</code>.
+ * @param maximumValue the maximum value of the parameter, 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 OpenMBeanParameterInfoSupport(String name, String desc, OpenType type,
+ Object defaultValue, Comparable minimumValue,
+ Comparable maximumValue)
+ throws OpenDataException
+ {
+ 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.");
+ 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.");
+
+ this.defaultValue = defaultValue;
+ minValue = minimumValue;
+ maxValue = maximumValue;
+ }
+
+ /**
+ * <p>
+ * Constructs a new {@link OpenMBeanParameterInfo} using the
+ * specified name, description, open type, 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
+ * parameters 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, {@link
+ * ArrayType} and {@link 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 parameter.
+ * @param desc a description of the parameter.
+ * @param type the open type of the parameter.
+ * @param defaultValue the default value of the parameter, or <code>null</code>.
+ * @param legalValues the legal values of the parameter. 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 OpenMBeanParameterInfoSupport(String name, String desc, OpenType type,
+ Object defaultValue, Object[] legalValues)
+ throws OpenDataException
+ {
+ 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.");
+ 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);
+ }
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * Compares this parameter with the supplied object. This returns
+ * true iff the object is an instance of {@link OpenMBeanParameterInfo}
+ * with an equal name and open type and the same default, minimum,
+ * maximum and legal values.
+ *
+ * @param obj the object to compare.
+ * @return true if the object is a {@link OpenMBeanParameterInfo}
+ * instance,
+ * <code>name.equals(object.getName())</code>,
+ * <code>openType.equals(object.getOpenType())</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 OpenMBeanParameterInfo))
+ return false;
+ OpenMBeanParameterInfo o = (OpenMBeanParameterInfo) obj;
+ return getName().equals(o.getName()) &&
+ openType.equals(o.getOpenType()) &&
+ (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 parameter, or <code>null</code>
+ * if there is no default value.
+ *
+ * @return the default value of the parameter, or <code>null</code>
+ * if there is no default.
+ */
+ public Object getDefaultValue()
+ {
+ return defaultValue;
+ }
+
+ /**
+ * Returns a {@link java.util.Set} enumerating the legal values
+ * of this parameter, or <code>null</code> if no such limited
+ * set exists for this parameter.
+ *
+ * @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 parameter, 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 parameter, 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
+ * parameter.
+ *
+ * @return the open type of this parameter.
+ */
+ public OpenType getOpenType()
+ {
+ return openType;
+ }
+
+ /**
+ * Returns true if this parameter has a default value
+ * (i.e. the value is non-null).
+ *
+ * @return true if this parameter has a default.
+ */
+ public boolean hasDefaultValue()
+ {
+ return defaultValue != null;
+ }
+
+ /**
+ * <p>
+ * Returns the hashcode of the parameter 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 parameter information.
+ */
+ public int hashCode()
+ {
+ if (hashCode == null)
+ hashCode = Integer.valueOf(getName().hashCode() +
+ openType.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
+ * parameter (i.e. the value is non-null).
+ *
+ * @return true if a set of legal values exists for this
+ * parameter.
+ */
+ public boolean hasLegalValues()
+ {
+ return legalValues != null;
+ }
+
+ /**
+ * Returns true if there is a maximum value for this parameter
+ * (i.e. the value is non-null).
+ *
+ * @return true if a maximum value exists for this parameter.
+ */
+ public boolean hasMaxValue()
+ {
+ return maxValue != null;
+ }
+
+ /**
+ * Returns true if there is a minimum value for this parameter.
+ * (i.e. the value is non-null).
+ *
+ * @return true if a minimum value exists for this parameter.
+ */
+ public boolean hasMinValue()
+ {
+ return minValue != null;
+ }
+
+ /**
+ * Returns true if the specified object is a valid value for
+ * this parameter.
+ *
+ * @param obj the object to test.
+ * @return true if <code>obj</code> is a valid value for this
+ * parameter.
+ */
+ 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.OpenMBeanParameterInfo</code>)
+ * along with the name, open type, default, minimum, maximum
+ * and legal values of the parameter.
+ * </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
+ + ",defaultValue=" + defaultValue
+ + ",minValue=" + minValue
+ + ",maxValue=" + maxValue
+ + ",legalValues=" + legalValues
+ + "]";
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/OpenType.java b/libjava/classpath/javax/management/openmbean/OpenType.java
index b08c40cccce..13c9e8a3e01 100644
--- a/libjava/classpath/javax/management/openmbean/OpenType.java
+++ b/libjava/classpath/javax/management/openmbean/OpenType.java
@@ -133,11 +133,11 @@ public abstract class OpenType
testString = className;
boolean openTypeFound = false;
for (int a = 0; a < ALLOWED_CLASSNAMES.length; ++a)
- if (ALLOWED_CLASSNAMES[a].equals(className))
+ if (ALLOWED_CLASSNAMES[a].equals(testString))
openTypeFound = true;
if (!openTypeFound)
- throw new OpenDataException("The class name does not specify " +
- "a valid open type.");
+ throw new OpenDataException("The class name, " + testString +
+ ", does not specify a valid open type.");
this.className = className;
typeName = name;
description = desc;
diff --git a/libjava/classpath/javax/management/openmbean/SimpleType.java b/libjava/classpath/javax/management/openmbean/SimpleType.java
index 3962909d4bb..39753f1c6ea 100644
--- a/libjava/classpath/javax/management/openmbean/SimpleType.java
+++ b/libjava/classpath/javax/management/openmbean/SimpleType.java
@@ -53,7 +53,7 @@ import java.io.ObjectStreamException;
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
-public class SimpleType
+public final class SimpleType
extends OpenType
{
diff --git a/libjava/classpath/javax/management/openmbean/TabularData.java b/libjava/classpath/javax/management/openmbean/TabularData.java
index 17c8de98109..7e57e0fd815 100644
--- a/libjava/classpath/javax/management/openmbean/TabularData.java
+++ b/libjava/classpath/javax/management/openmbean/TabularData.java
@@ -55,12 +55,14 @@ public interface TabularData
/**
* Calculates the index the specified {@link CompositeData} value
* would have, if it was to be added to this {@link TabularData}
- * instance. This method includes a check that the type of
- * the given value is the same as the row type of this instance,
- * but not a check for existing instances of the given value.
- * The value must also not be <code>null</code>. Possible indices
- * are returned by the {@link TabularType#getIndexNames()} method
- * of this instance's tabular type.
+ * instance. This method includes a check that the type of the
+ * given value is the same as the row type of this instance, but not
+ * a check for existing instances of the given value. The value
+ * must also not be <code>null</code>. Possible indices are
+ * returned by the {@link TabularType#getIndexNames()} method of
+ * this instance's tabular type. The returned indices are the
+ * values of the fields in the supplied {@link CompositeData}
+ * instance that match the names given in the {@link TabularType}.
*
* @param val the {@link CompositeData} value whose index should
* be calculated.
@@ -106,7 +108,7 @@ public interface TabularData
* Compares the specified object with this object for equality.
* The object is judged equivalent if it is non-null, and also
* an instance of {@link TabularData} with the same row type,
- * and index to value mappings. The two compared instances may
+ * and {@link CompositeData} values. The two compared instances may
* be equivalent even if they represent different implementations
* of {@link TabularData}.
*
@@ -123,9 +125,9 @@ public interface TabularData
* @return the matching {@link CompositeData} value, or
* <code>null</code> if one does not exist.
* @throws NullPointerException if the key is <code>null</code>.
- * @throws InvalidOpenTypeException if the key does not match
- * the {@link TabularType} of this
- * instance.
+ * @throws InvalidKeyException if the key does not match
+ * the {@link TabularType} of this
+ * instance.
*/
CompositeData get(Object[] key);
@@ -138,14 +140,12 @@ public interface TabularData
TabularType getTabularType();
/**
- * Returns the hash code of the composite data type.
- * This is computed as the sum of the hash codes of the
- * each index and its value, together with the hash
- * code of the tabular type. These are the same elements
- * of the type that are compared as part of the
- * {@link #equals(java.lang.Object)} method, thus ensuring
- * that the hashcode is compatible with the equality
- * test.
+ * Returns the hash code of the composite data type. This is
+ * computed as the sum of the hash codes of each value, together
+ * with the hash code of the tabular type. These are the same
+ * elements of the type that are compared as part of the {@link
+ * #equals(java.lang.Object)} method, thus ensuring that the
+ * hashcode is compatible with the equality test.
*
* @return the hash code of this instance.
*/
@@ -196,15 +196,16 @@ public interface TabularData
* values in the array, as well as from the existing values
* in the table. The operation should be atomic; if one
* value can not be added, then none of the values should
- * be.
+ * be. If the array is <code>null</code> or empty, the
+ * method simply returns.
*
* @param vals the {@link CompositeData} values to add.
- * @throws NullPointerException if <code>val</code> is
+ * @throws NullPointerException if a value from the array is
* <code>null</code>.
- * @throws InvalidOpenTypeException if the type of the
+ * @throws InvalidOpenTypeException if the type of a
* given value does not
* match the row type.
- * @throws KeyAlreadyExistsException if the value has the
+ * @throws KeyAlreadyExistsException if a value has the
* same calculated index
* as an existing value or
* of one of the other
diff --git a/libjava/classpath/javax/management/openmbean/TabularDataSupport.java b/libjava/classpath/javax/management/openmbean/TabularDataSupport.java
new file mode 100644
index 00000000000..9dc8a0e9727
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/TabularDataSupport.java
@@ -0,0 +1,652 @@
+/* TabularDataSupport.java -- Tables of composite data structures.
+ 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.io.Serializable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Provides an implementation of the {@link TabularData}
+ * interface using a {@link java.util.HashMap}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class TabularDataSupport
+ implements TabularData, Serializable, Cloneable, Map
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 5720150593236309827L;
+
+ /**
+ * Mapping of rows to column values.
+ *
+ * @serial the map of rows to column values.
+ */
+ private Map dataMap;
+
+ /**
+ * The tabular type which represents this tabular data instance.
+ *
+ * @serial the type information for this instance.
+ */
+ private TabularType tabularType;
+
+ /**
+ * Constructs a new empty {@link TabularDataSupport} with the
+ * specified type. The type may not be null. This constructor
+ * simply calls the other, with the default initial capacity of
+ * <code>101</code> and default load factor of <code>0.75</code>.
+ *
+ * @param type the tabular type of this tabular data instance.
+ * @throws IllegalArgumentException if <code>type</code> is
+ * <code>null</code>.
+ */
+ public TabularDataSupport(TabularType type)
+ {
+ this(type, 101, 0.75f);
+ }
+
+ /**
+ * Constructs a new empty {@link TabularDataSupport} with the
+ * specified type and the supplied initial capacity and load factor
+ * being used for the underlying {@link java.util.HashMap}. The
+ * type may not be null and the initial capacity and load factor
+ * must be positive.
+ *
+ * @param type the tabular type of this tabular data instance.
+ * @param cap the initial capacity of the underlying map.
+ * @param lf the load factor of the underlying map.
+ * @throws IllegalArgumentException if <code>type</code> is
+ * <code>null</code>, or
+ * <code>cap</code> or
+ * <code>lf</code> are
+ * negative.
+ */
+ public TabularDataSupport(TabularType type, int cap, float lf)
+ {
+ if (type == null)
+ throw new IllegalArgumentException("The type may not be null.");
+ tabularType = type;
+ dataMap = new HashMap(cap, lf);
+ }
+
+ /**
+ * Calculates the index the specified {@link CompositeData} value
+ * would have, if it was to be added to this {@link TabularData}
+ * instance. This method includes a check that the type of the
+ * given value is the same as the row type of this instance, but not
+ * a check for existing instances of the given value. The value
+ * must also not be <code>null</code>. Possible indices are
+ * selected by the {@link TabularType#getIndexNames()} method of
+ * this instance's tabular type. The returned indices are the
+ * values of the fields in the supplied {@link CompositeData}
+ * instance that match the names given in the {@link TabularType}.
+ *
+ * @param val the {@link CompositeData} value whose index should
+ * be calculated.
+ * @return the index the value would take on, if it were to be added.
+ * @throws NullPointerException if the value is <code>null</code>.
+ * @throws InvalidOpenTypeException if the value does not match the
+ * row type of this instance.
+ */
+ public Object[] calculateIndex(CompositeData val)
+ {
+ if (!(val.getCompositeType().equals(tabularType.getRowType())))
+ throw new InvalidOpenTypeException("The type of the given value " +
+ "does not match the row type " +
+ "of this instance.");
+ List indexNames = tabularType.getIndexNames();
+ List matchingIndicies = new ArrayList(indexNames.size());
+ Iterator it = indexNames.iterator();
+ while (it.hasNext())
+ {
+ String name = (String) it.next();
+ matchingIndicies.add(val.get(name));
+ }
+ return matchingIndicies.toArray();
+ }
+
+ /**
+ * Removes all {@link CompositeData} values from the table.
+ */
+ public void clear()
+ {
+ dataMap.clear();
+ }
+
+ /**
+ * Returns a shallow clone of the information, as obtained by the
+ * {@link Object} implementation of {@link Object#clone()}. The map
+ * is also cloned, but it still references the same objects.
+ *
+ * @return a shallow clone of this {@link TabularDataSupport}.
+ */
+ public Object clone()
+ {
+ TabularDataSupport clone = null;
+ try
+ {
+ clone = (TabularDataSupport) super.clone();
+ clone.setMap((HashMap) ((HashMap) dataMap).clone());
+ }
+ catch (CloneNotSupportedException e)
+ {
+ /* This won't happen as we implement Cloneable */
+ }
+ return clone;
+ }
+
+ /**
+ * Returns true iff this instance of the {@link TabularData} class
+ * contains a {@link CompositeData} value at the specified index.
+ * The method returns <code>false</code> if the given key can
+ * not be cast to an {@link java.lang.Object} array; otherwise
+ * it returns the result of {@link #containsKey(java.lang.Object[])}.
+ *
+ *
+ * @param key the key to test for.
+ * @return true if the key maps to a {@link CompositeData} value.
+ */
+ public boolean containsKey(Object key)
+ {
+ if (key instanceof Object[])
+ return containsKey((Object[]) key);
+ else
+ return false;
+ }
+
+ /**
+ * Returns true iff this instance of the {@link TabularData} class
+ * contains a {@link CompositeData} value at the specified index.
+ * In any other circumstance, including if the given key
+ * is <code>null</code> or of the incorrect type, according to
+ * the {@link TabularType} of this instance, this method returns
+ * false.
+ *
+ * @param key the key to test for.
+ * @return true if the key maps to a {@link CompositeData} value.
+ */
+ public boolean containsKey(Object[] key)
+ {
+ if (key == null)
+ return false;
+ if (!(isKeyValid(key)))
+ return false;
+ return dataMap.containsKey(key);
+ }
+
+ /**
+ * Returns true iff this instance of the {@link TabularData} class
+ * contains the specified {@link CompositeData} value. If the given
+ * value is not an instance of {@link CompositeData}, this method
+ * simply returns false.
+ *
+ * @param val the value to test for.
+ * @return true if the value exists.
+ */
+ public boolean containsValue(Object val)
+ {
+ if (val instanceof CompositeData)
+ return containsValue((CompositeData) val);
+ else
+ return false;
+ }
+
+ /**
+ * Returns true iff this instance of the {@link TabularData} class
+ * contains the specified {@link CompositeData} value.
+ * In any other circumstance, including if the given value
+ * is <code>null</code> or of the incorrect type, according to
+ * the {@link TabularType} of this instance, this method returns
+ * false.
+ *
+ * @param val the value to test for.
+ * @return true if the value exists.
+ */
+ public boolean containsValue(CompositeData val)
+ {
+ if (val == null)
+ return false;
+ if (!(val.getCompositeType().equals(tabularType.getRowType())))
+ return false;
+ return dataMap.containsValue(val);
+ }
+
+ /**
+ * <p>
+ * Returns a set view of the mappings in this Map. Each element in the
+ * set is a Map.Entry. The set is backed by the map, so that changes in
+ * one show up in the other. Modifications made while an iterator is
+ * in progress cause undefined behavior. If the set supports removal,
+ * these methods remove the underlying mapping from the map:
+ * <code>Iterator.remove</code>, <code>Set.remove</code>,
+ * <code>removeAll</code>, <code>retainAll</code>, and <code>clear</code>.
+ * Element addition, via <code>add</code> or <code>addAll</code>, is
+ * not supported via this set.
+ * </p>
+ * <p>
+ * <strong>Note</strong>: using the
+ * {@link java.util.Map.Entry#setValue(Object) will cause corruption of
+ * the index to row mappings.
+ * </p>
+ *
+ * @return the set view of all mapping entries
+ * @see java.util.Map.Entry
+ */
+ public Set entrySet()
+ {
+ return dataMap.entrySet();
+ }
+
+ /**
+ * Compares the specified object with this object for equality.
+ * The object is judged equivalent if it is non-null, and also
+ * an instance of {@link TabularData} with the same row type,
+ * and {@link CompositeData} values. The two compared instances may
+ * be equivalent even if they represent different implementations
+ * of {@link TabularData}.
+ *
+ * @param obj the object to compare for equality.
+ * @return true if <code>obj</code> is equal to <code>this</code>.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof TabularData))
+ return false;
+ TabularData data = (TabularData) obj;
+ return tabularType.equals(data.getTabularType()) &&
+ dataMap.values().equals(data.values());
+ }
+
+ /**
+ * Retrieves the value for the specified key by simply
+ * calling <code>get((Object[]) key)</code>.
+ *
+ * @param key the key whose value should be returned.
+ * @return the matching {@link CompositeData} value, or
+ * <code>null</code> if one does not exist.
+ * @throws NullPointerException if the key is <code>null</code>.
+ * @throws ClassCastException if the key is not an instance
+ * of <code>Object[]</code>.
+ * @throws InvalidKeyException if the key does not match
+ * the {@link TabularType} of this
+ * instance.
+ */
+ public Object get(Object key)
+ {
+ return get((Object[]) key);
+ }
+
+ /**
+ * Retrieves the {@link CompositeData} value for the specified
+ * key, or <code>null</code> if no such mapping exists.
+ *
+ * @param key the key whose value should be returned.
+ * @return the matching {@link CompositeData} value, or
+ * <code>null</code> if one does not exist.
+ * @throws NullPointerException if the key is <code>null</code>.
+ * @throws InvalidKeyException if the key does not match
+ * the {@link TabularType} of this
+ * instance.
+ */
+ public CompositeData get(Object[] key)
+ {
+ if (!(isKeyValid(key)))
+ throw new InvalidKeyException("The key does not match the " +
+ "tabular type of this instance.");
+ return (CompositeData) dataMap.get(key);
+ }
+
+ /**
+ * Returns the tabular type which corresponds to this instance
+ * of {@link TabularData}.
+ *
+ * @return the tabular type for this instance.
+ */
+ public TabularType getTabularType()
+ {
+ return tabularType;
+ }
+
+ /**
+ * Returns the hash code of the composite data type. This is
+ * computed as the sum of the hash codes of each value, together
+ * with the hash code of the tabular type. These are the same
+ * elements of the type that are compared as part of the {@link
+ * #equals(java.lang.Object)} method, thus ensuring that the
+ * hashcode is compatible with the equality test.
+ *
+ * @return the hash code of this instance.
+ */
+ public int hashCode()
+ {
+ return tabularType.hashCode() + dataMap.values().hashCode();
+ }
+
+ /**
+ * Returns true if this {@link TabularData} instance
+ * contains no {@link CompositeData} values.
+ *
+ * @return true if the instance is devoid of rows.
+ */
+ public boolean isEmpty()
+ {
+ return dataMap.isEmpty();
+ }
+
+ /**
+ * Returns true if the given key is valid for the
+ * @link{TabularType} of this instance.
+ *
+ * @return true if the key is valid.
+ * @throws NullPointerException if <code>key</code>
+ * is null.
+ */
+ private boolean isKeyValid(Object[] key)
+ {
+ Iterator it = tabularType.getIndexNames().iterator();
+ CompositeType rowType = tabularType.getRowType();
+ for (int a = 0; it.hasNext(); ++a)
+ {
+ OpenType type = rowType.getType((String) it.next());
+ if (!(type.isValue(key[a])))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns a set view of the keys in this Map. The set is backed by the
+ * map, so that changes in one show up in the other. Modifications made
+ * while an iterator is in progress cause undefined behavior. If the set
+ * supports removal, these methods remove the underlying mapping from
+ * the map: <code>Iterator.remove</code>, <code>Set.remove</code>,
+ * <code>removeAll</code>, <code>retainAll</code>, and <code>clear</code>.
+ * Element addition, via <code>add</code> or <code>addAll</code>, is
+ * not supported via this set.
+ *
+ * @return the set view of all keys
+ */
+ public Set keySet()
+ {
+ return dataMap.keySet();
+ }
+
+ /**
+ * Adds the specified {@link CompositeData} value to the
+ * table. The value must be non-null, of the same type
+ * as the row type of this instance, and must not have
+ * the same index as an existing value. The index is
+ * calculated using the index names of the
+ * {@link TabularType} for this instance.
+ *
+ * @param val the {@link CompositeData} value to add.
+ * @throws NullPointerException if <code>val</code> is
+ * <code>null</code>.
+ * @throws InvalidOpenTypeException if the type of the
+ * given value does not
+ * match the row type.
+ * @throws KeyAlreadyExistsException if the value has the
+ * same calculated index
+ * as an existing value.
+ */
+ public void put(CompositeData val)
+ {
+ Object[] key = calculateIndex(val);
+ if (dataMap.containsKey(key))
+ throw new KeyAlreadyExistsException("A value with this index " +
+ "already exists.");
+ dataMap.put(key, val);
+ }
+
+ /**
+ * Adds the specified {@link CompositeData} value to the
+ * table, ignoring the supplied key, by simply calling
+ * <code>put((CompositeData) val)</code>.
+ *
+ * @param key ignored.
+ * @param val the {@link CompositeData} value to add.
+ * @return the {@link CompositeData} value.
+ * @throws NullPointerException if <code>val</code> is
+ * <code>null</code>.
+ * @throws InvalidOpenTypeException if the type of the
+ * given value does not
+ * match the row type.
+ * @throws KeyAlreadyExistsException if the value has the
+ * same calculated index
+ * as an existing value.
+ */
+ public Object put(Object key, Object val)
+ {
+ put((CompositeData) val);
+ return val;
+ }
+
+ /**
+ * Adds each of the specified {@link CompositeData} values
+ * to the table. Each element of the array must meet the
+ * conditions given for the {@link #put(CompositeData)}
+ * method. In addition, the index of each value in the
+ * array must be distinct from the index of the other
+ * values in the array, as well as from the existing values
+ * in the table. The operation should be atomic; if one
+ * value can not be added, then none of the values should
+ * be. If the array is <code>null</code> or empty, the
+ * method simply returns.
+ *
+ * @param vals the {@link CompositeData} values to add.
+ * @throws NullPointerException if a value from the array is
+ * <code>null</code>.
+ * @throws InvalidOpenTypeException if the type of a
+ * given value does not
+ * match the row type.
+ * @throws KeyAlreadyExistsException if a value has the
+ * same calculated index
+ * as an existing value or
+ * of one of the other
+ * specified values.
+ */
+ public void putAll(CompositeData[] vals)
+ {
+ if (vals == null || vals.length == 0)
+ return;
+ Map mapToAdd = new HashMap(vals.length);
+ for (int a = 0; a < vals.length; ++a)
+ {
+ Object[] key = calculateIndex(vals[a]);
+ if (dataMap.containsKey(key))
+ throw new KeyAlreadyExistsException("Element " + a + ": A " +
+ "value with this index " +
+ "already exists.");
+ mapToAdd.put(key, vals[a]);
+ }
+ dataMap.putAll(mapToAdd);
+ }
+
+ /**
+ * Converts each value from the specified map to a member of an
+ * array of {@link CompositeData} values and adds them using {@link
+ * #put(CompositeData[])}, if possible. As in {@link
+ * #put(Object,Object)}, the keys are simply ignored. This method
+ * is useful for adding the {@link CompositeData} values from a
+ * different {@link TabularData} instance, which uses the same
+ * {@link TabularType} but a different selection of index names, to
+ * this one. If the map is <code>null</code> or empty, the method
+ * simply returns.
+ *
+ * @param m the map to add. Only the values are used and must
+ * all be instances of {@link CompositeData}.
+ * @throws NullPointerException if a value from the map is
+ * <code>null</code>.
+ * @throws ClassCastException if a value from the map is not
+ * an instance of {@link CompositeData}.
+ * @throws InvalidOpenTypeException if the type of the
+ * given value does not
+ * match the row type.
+ * @throws KeyAlreadyExistsException if the value has the
+ * same calculated index
+ * as an existing value or
+ * of one of the other
+ * specified values.
+ */
+ public void putAll(Map m)
+ {
+ if (m == null || m.size() == 0)
+ return;
+ Collection vals = m.values();
+ CompositeData[] data = new CompositeData[vals.size()];
+ Iterator it = vals.iterator();
+ for (int a = 0; it.hasNext(); ++a)
+ {
+ data[a] = (CompositeData) it.next();
+ }
+ putAll(data);
+ }
+
+ /**
+ * Removes the value for the specified key by simply
+ * calling <code>remove((Object[]) key)</code>.
+ *
+ * @param key the key whose value should be removed.
+ * @return the removed value, or <code>null</code> if
+ * there is no value for the given key.
+ * @throws NullPointerException if the key is <code>null</code>.
+ * @throws ClassCastException if the key is not an instance
+ * of <code>Object[]</code>.
+ * @throws InvalidOpenTypeException if the key does not match
+ * the {@link TabularType} of this
+ * instance.
+ */
+ public Object remove(Object key)
+ {
+ return remove((Object[]) key);
+ }
+
+ /**
+ * Removes the {@link CompositeData} value located at the
+ * specified index. <code>null</code> is returned if the
+ * value does not exist. Otherwise, the removed value is
+ * returned.
+ *
+ * @param key the key of the value to remove.
+ * @return the removed value, or <code>null</code> if
+ * there is no value for the given key.
+ * @throws NullPointerException if the key is <code>null</code>.
+ * @throws InvalidOpenTypeException if the key does not match
+ * the {@link TabularType} of this
+ * instance.
+ */
+ public CompositeData remove(Object[] key)
+ {
+ if (!(isKeyValid(key)))
+ throw new InvalidKeyException("The key does not match the " +
+ "tabular type of this instance.");
+ return (CompositeData) dataMap.remove(key);
+ }
+
+ /**
+ * Package-private method to set the internal {@link java.util.Map}
+ * instance (used in cloning).
+ *
+ * @param map the new map used.
+ */
+ void setMap(Map map)
+ {
+ dataMap = map;
+ }
+
+ /**
+ * Returns the number of {@link CompositeData} values or rows
+ * in the table.
+ *
+ * @return the number of rows in the table.
+ */
+ public int size()
+ {
+ return dataMap.size();
+ }
+
+ /**
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.openmbean.TabularDataSupport</code>)
+ * and the result of calling <code>toString()</code> on the
+ * tabular type and underlying hash map instance.
+ *
+ * @return a {@link java.lang.String} representation of the
+ * object.
+ */
+ public String toString()
+ {
+ return getClass().getName()
+ + "[tabularType=" + tabularType
+ + ",dataMap=" + dataMap
+ + "]";
+ }
+
+ /**
+ * Returns a collection (or bag) view of the values in this Map. The
+ * collection is backed by the map, so that changes in one show up in
+ * the other. Modifications made while an iterator is in progress cause
+ * undefined behavior. If the collection supports removal, these methods
+ * remove the underlying mapping from the map: <code>Iterator.remove</code>,
+ * <code>Collection.remove</code>, <code>removeAll</code>,
+ * <code>retainAll</code>, and <code>clear</code>. Element addition, via
+ * <code>add</code> or <code>addAll</code>, is not supported via this
+ * collection.
+ *
+ * @return the collection view of all values
+ */
+ public Collection values()
+ {
+ return dataMap.values();
+ }
+
+}
+