FileDocCategorySizeDatePackage
Descriptor.javaAPI DocJava SE 6 API20937Tue Jun 10 00:26:12 BST 2008javax.management

Descriptor

public interface Descriptor implements Serializable, Cloneable

Additional metadata for a JMX element. A {@code Descriptor} is associated with a {@link MBeanInfo}, {@link MBeanAttributeInfo}, etc. It consists of a collection of fields. A field is a name and an associated value.

Field names are not case-sensitive. The names {@code descriptorType}, {@code descriptortype}, and {@code DESCRIPTORTYPE} are all equivalent. However, the case that was used when the field was first set is preserved in the result of the {@link #getFields} and {@link #getFieldNames} methods.

Not all field names and values are predefined. New fields can be defined and added by any program.

A descriptor can be mutable or immutable. An immutable descriptor, once created, never changes. The Descriptor methods that could modify the contents of the descriptor will throw an exception for an immutable descriptor. Immutable descriptors are usually instances of {@link ImmutableDescriptor} or a subclass. Mutable descriptors are usually instances of {@link javax.management.modelmbean.DescriptorSupport} or a subclass.

Certain fields are used by the JMX implementation. This means either that the presence of the field may change the behavior of the JMX API or that the field may be set in descriptors returned by the JMX API. These fields appear in italics in the table below, and each one has a corresponding constant in the {@link JMX} class. For example, the field {@code defaultValue} is represented by the constant {@link JMX#DEFAULT_VALUE_FIELD}.

Certain other fields have conventional meanings described in the table below but they are not required to be understood or set by the JMX implementation.

Field names defined by the JMX specification in this and all future versions will never contain a period (.). Users can safely create their own fields by including a period in the name and be sure that these names will not collide with any future version of the JMX API. It is recommended to follow the Java package naming convention to avoid collisions between field names from different origins. For example, a field created by {@code example.com} might have the name {@code com.example.interestLevel}.

Note that the values in the {@code defaultValue}, {@code legalValues}, {@code maxValue}, and {@code minValue} fields should be consistent with the type returned by the {@code getType()} method for the associated {@code MBeanAttributeInfo} or {@code MBeanParameterInfo}. For MXBeans, this means that they should be of the mapped Java type, called opendata(J) in the MXBean type mapping rules.

NameTypeUsed inMeaning
defaultValueObject MBeanAttributeInfo
MBeanParameterInfo
Default value for an attribute or parameter. See {@link javax.management.openmbean}.
deprecatedStringAny An indication that this element of the information model is no longer recommended for use. A set of MBeans defined by an application is collectively called an information model. The convention is for the value of this field to contain a string that is the version of the model in which the element was first deprecated, followed by a space, followed by an explanation of the deprecation, for example {@code "1.3 Replaced by the Capacity attribute"}.
descriptionResource
BundleBaseName
StringAny The base name for the {@link ResourceBundle} in which the key given in the {@code descriptionResourceKey} field can be found, for example {@code "com.example.myapp.MBeanResources"}. The meaning of this field is defined by this specification but the field is not set or used by the JMX API itself.
descriptionResourceKeyStringAny A resource key for the description of this element. In conjunction with the {@code descriptionResourceBundleBaseName}, this can be used to find a localized version of the description. The meaning of this field is defined by this specification but the field is not set or used by the JMX API itself.
enabledString MBeanAttributeInfo
MBeanNotificationInfo
MBeanOperationInfo
The string {@code "true"} or {@code "false"} according as this item is enabled. When an attribute or operation is not enabled, it exists but cannot currently be accessed. A user interface might present it as a greyed-out item. For example, an attribute might only be meaningful after the {@code start()} method of an MBean has been called, and is otherwise disabled. Likewise, a notification might be disabled if it cannot currently be emitted but could be in other circumstances.
immutableInfoString MBeanInfo The string {@code "true"} or {@code "false"} according as this MBean's MBeanInfo is immutable. When this field is true, the MBeanInfo for the given MBean is guaranteed not to change over the lifetime of the MBean. Hence, a client can read it once and cache the read value. When this field is false or absent, there is no such guarantee, although that does not mean that the MBeanInfo will necessarily change.
infoTimeoutString
Long
MBeanInfo The time in milli-seconds that the MBeanInfo can reasonably be expected to be unchanged. The value can be a {@code Long} or a decimal string. This provides a hint from a DynamicMBean or any MBean that does not define {@code immutableInfo} as {@code true} that the MBeanInfo is not likely to change within this period and therefore can be cached. When this field is missing or has the value zero, it is not recommended to cache the MBeanInfo unless it has the {@code immutableInfo} set to {@code true}.
interfaceClassName StringMBeanInfo The Java interface name for a Standard MBean or MXBean, as returned by {@link Class#getName()}. A Standard MBean or MXBean registered directly in the MBean Server or created using the {@link StandardMBean} class will have this field in its MBeanInfo Descriptor.
legalValues {@literal Set}MBeanAttributeInfo
MBeanParameterInfo
Legal values for an attribute or parameter. See {@link javax.management.openmbean}.
maxValueObject MBeanAttributeInfo
MBeanParameterInfo
Maximum legal value for an attribute or parameter. See {@link javax.management.openmbean}.
metricTypeString MBeanAttributeInfo
MBeanOperationInfo
The type of a metric, one of the strings "counter" or "gauge". A metric is a measurement exported by an MBean, usually an attribute but sometimes the result of an operation. A metric that is a counter has a value that never decreases except by being reset to a starting value. Counter metrics are almost always non-negative integers. An example might be the number of requests received. A metric that is a gauge has a numeric value that can increase or decrease. Examples might be the number of open connections or a cache hit rate or a temperature reading.
minValueObject MBeanAttributeInfo
MBeanParameterInfo
Minimum legal value for an attribute or parameter. See {@link javax.management.openmbean}.
mxbeanString MBeanInfo The string {@code "true"} or {@code "false"} according as this MBean is an {@link MXBean}. A Standard MBean or MXBean registered directly with the MBean Server or created using the {@link StandardMBean} class will have this field in its MBeanInfo Descriptor.
openType{@link OpenType} MBeanAttributeInfo
MBeanOperationInfo
MBeanParameterInfo

The Open Type of this element. In the case of {@code MBeanAttributeInfo} and {@code MBeanParameterInfo}, this is the Open Type of the attribute or parameter. In the case of {@code MBeanOperationInfo}, it is the Open Type of the return value. This field is set in the Descriptor for all instances of {@link OpenMBeanAttributeInfoSupport}, {@link OpenMBeanOperationInfoSupport}, and {@link OpenMBeanParameterInfoSupport}. It is also set for attributes, operations, and parameters of MXBeans.

This field can be set for an {@code MBeanNotificationInfo}, in which case it indicates the Open Type that the {@link Notification#getUserData() user data} will have.

originalTypeString MBeanAttributeInfo
MBeanOperationInfo
MBeanParameterInfo

The original Java type of this element as it appeared in the {@link MXBean} interface method that produced this {@code MBeanAttributeInfo} (etc). For example, a method
public {@link MemoryUsage} getHeapMemoryUsage();
in an MXBean interface defines an attribute called {@code HeapMemoryUsage} of type {@link CompositeData}. The {@code originalType} field in the Descriptor for this attribute will have the value {@code "java.lang.management.MemoryUsage"}.

The format of this string is described in the section Type Names of the MXBean specification.

severityString
Integer
MBeanNotificationInfo The severity of this notification. It can be 0 to mean unknown severity or a value from 1 to 6 representing decreasing levels of severity. It can be represented as a decimal string or an {@code Integer}.
sinceStringAny The version of the information model in which this element was introduced. A set of MBeans defined by an application is collectively called an information model. The application may also define versions of this model, and use the {@code "since"} field to record the version in which an element first appeared.
unitsString MBeanAttributeInfo
MBeanParameterInfo
MBeanOperationInfo
The units in which an attribute, parameter, or operation return value is measured, for example {@code "bytes"} or {@code "seconds"}.

Some additional fields are defined by Model MBeans. See {@link javax.management.modelmbean.ModelMBeanInfo ModelMBeanInfo} and related classes and the chapter "Model MBeans" of the JMX Specification.

since
1.5

Fields Summary
Constructors Summary
Methods Summary
public java.lang.Objectclone()

Returns a descriptor which is equal to this descriptor. Changes to the returned descriptor will have no effect on this descriptor, and vice versa. If this descriptor is immutable, it may fulfill this condition by returning itself.

exception
RuntimeOperationsException for illegal value for field names or field values. If the descriptor construction fails for any reason, this exception will be thrown.
return
A descriptor which is equal to this descriptor.

public booleanequals(java.lang.Object obj)
Compares this descriptor to the given object. The objects are equal if the given object is also a Descriptor, and if the two Descriptors have the same field names (possibly differing in case) and the same associated values. The respective values for a field in the two Descriptors are equal if the following conditions hold:

  • If one value is null then the other must be too.
  • If one value is a primitive array then the other must be a primitive array of the same type with the same elements.
  • If one value is an object array then the other must be too and {@link Arrays#deepEquals(Object[],Object[])} must return true.
  • Otherwise {@link Object#equals(Object)} must return true.

param
obj the object to compare with.
return
{@code true} if the objects are the same; {@code false} otherwise.
since
1.6

public java.lang.String[]getFieldNames()
Returns all the field names in the descriptor.

return
String array of field names. If the descriptor is empty, you will get an empty array.

public java.lang.ObjectgetFieldValue(java.lang.String fieldName)
Returns the value for a specific field name, or null if no value is present for that name.

param
fieldName the field name.
return
the corresponding value, or null if the field is not present.
exception
RuntimeOperationsException if the field name is illegal.

public java.lang.Object[]getFieldValues(java.lang.String fieldNames)
Returns all the field values in the descriptor as an array of Objects. The returned values are in the same order as the {@code fieldNames} String array parameter.

param
fieldNames String array of the names of the fields that the values should be returned for. If the array is empty then an empty array will be returned. If the array is null then all values will be returned, as if the parameter were the array returned by {@link #getFieldNames()}. If a field name in the array does not exist, including the case where it is null or the empty string, then null is returned for the matching array element being returned.
return
Object array of field values. If the list of {@code fieldNames} is empty, you will get an empty array.

public java.lang.String[]getFields()
Returns all of the fields contained in this descriptor as a string array.

return
String array of fields in the format fieldName=fieldValue
If the value of a field is not a String, then the toString() method will be called on it and the returned value, enclosed in parentheses, used as the value for the field in the returned array. If the value of a field is null, then the value of the field in the returned array will be empty. If the descriptor is empty, you will get an empty array.
see
#setFields

public inthashCode()

Returns the hash code value for this descriptor. The hash code is computed as the sum of the hash codes for each field in the descriptor. The hash code of a field with name {@code n} and value {@code v} is {@code n.toLowerCase().hashCode() ^ h}. Here {@code h} is the hash code of {@code v}, computed as follows:

  • If {@code v} is null then {@code h} is 0.
  • If {@code v} is a primitive array then {@code h} is computed using the appropriate overloading of {@code java.util.Arrays.hashCode}.
  • If {@code v} is an object array then {@code h} is computed using {@link Arrays#deepHashCode(Object[])}.
  • Otherwise {@code h} is {@code v.hashCode()}.

return
A hash code value for this object.
since
1.6

public booleanisValid()
Returns true if all of the fields have legal values given their names.

return
true if the values are legal.
exception
RuntimeOperationsException If the validity checking fails for any reason, this exception will be thrown. The method returns false if the descriptor is not valid, but throws this exception if the attempt to determine validity fails.

public voidremoveField(java.lang.String fieldName)
Removes a field from the descriptor.

param
fieldName String name of the field to be removed. If the field name is illegal or the field is not found, no exception is thrown.
exception
RuntimeOperationsException if a field of the given name exists and the descriptor is immutable. The wrapped exception will be an {@link UnsupportedOperationException}.

public voidsetField(java.lang.String fieldName, java.lang.Object fieldValue)

Sets the value for a specific field name. This will modify an existing field or add a new field.

The field value will be validated before it is set. If it is not valid, then an exception will be thrown. The meaning of validity is dependent on the descriptor implementation.

param
fieldName The field name to be set. Cannot be null or empty.
param
fieldValue The field value to be set for the field name. Can be null if that is a valid value for the field.
exception
RuntimeOperationsException if the field name or field value is illegal (wrapped exception is {@link IllegalArgumentException}); or if the descriptor is immutable (wrapped exception is {@link UnsupportedOperationException}).

public voidsetFields(java.lang.String[] fieldNames, java.lang.Object[] fieldValues)

Sets all fields in the field names array to the new value with the same index in the field values array. Array sizes must match.

The field value will be validated before it is set. If it is not valid, then an exception will be thrown. If the arrays are empty, then no change will take effect.

param
fieldNames String array of field names. The array and array elements cannot be null.
param
fieldValues Object array of the corresponding field values. The array cannot be null. Elements of the array can be null.
throws
RuntimeOperationsException if the change fails for any reason. Wrapped exception is {@link IllegalArgumentException} if {@code fieldNames} or {@code fieldValues} is null, or if the arrays are of different lengths, or if there is an illegal value in one of them. Wrapped exception is {@link UnsupportedOperationException} if the descriptor is immutable, and the call would change its contents.
see
#getFields