javax.management.openmbean package

Provides the open data types and Open MBean descriptor classes. An Open MBean is an MBean where the types of attributes and of operation parameters and return values are built using a small set of predefined Java classes. Open MBeans facilitate operation with remote management programs that do not necessarily have access to application-specific types, including non-Java programs.

Every MBean has an {@link javax.management.MBeanInfo MBeanInfo} with information about the MBean itself, and its attributes, operations, constructors, and notifications. In an Open MBean, this `MBeanInfo` implements the {@link javax.management.openmbean.OpenMBeanInfo OpenMBeanInfo} interface, usually by being an instance of {@link javax.management.openmbean.OpenMBeanInfoSupport OpenMBeanInfoSupport}.

The attribute information returned by {@link javax.management.MBeanInfo#getAttributes() MBeanInfo.getAttributes} for an Open MBean is an array of objects implementing {@link javax.management.openmbean.OpenMBeanAttributeInfo OpenMBeanAttributeInfo}, usually instances of {@link javax.management.openmbean.OpenMBeanAttributeInfoSupport OpenMBeanAttributeInfoSupport}. In addition to the usual information about attributes, an `OpenMBeanAttributeInfo` specifies the {@link javax.management.openmbean.OpenType OpenType} of the attribute. The possible `OpenType` values are predefined, which is what ensures that remote managers will understand them.

Similar remarks apply to the parameter types of operations and constructors, and to the return types of operations.

There is a distinction between an attribute's Java language type, as returned by {@link javax.management.MBeanAttributeInfo#getType() getType()}, and its `OpenType`, as returned by {@link javax.management.openmbean.OpenMBeanAttributeInfo#getOpenType() getOpenType()}. For example, if the Java language type is `java.lang.String`, the `OpenType` will be {@link javax.management.openmbean.SimpleType#STRING SimpleType.String}. If the Java language type is {@link javax.management.openmbean.CompositeData}, the `OpenType` will be a {@link javax.management.openmbean.CompositeType CompositeType} that describes the items in the `CompositeData` instances for the attribute.

## Default values and constraints

In Open MBeans, attributes and parameters can have default values and/or constraints associated with them in the {@code OpenMBeanAttributeInfo} or {@code OpenMBeanParameterInfo}. There are two ways to specify these constraints. Either the values are directly specified as parameters to one of the constructors of {@code OpenMBeanAttributeInfoSupport} or {@code OpenMBeanParameterInfoSupport}, for example {@link javax.management.openmbean.OpenMBeanParameterInfoSupport#OpenMBeanParameterInfoSupport( String, String, OpenType, Object, Object[])}; or the values are specified in a {@link javax.management.Descriptor Descriptor} given as a parameter to one of the constructors.

When a {@code Descriptor} is used, the fields of interest are these:

- {@code defaultValue} defines the value returned by {@link javax.management.openmbean.OpenMBeanParameterInfo#getDefaultValue() getDefaultValue()};
- {@code minValue} defines the value returned by {@link javax.management.openmbean.OpenMBeanParameterInfo#getMinValue() getMinValue()};
- {@code maxValue} defines the value returned by {@link javax.management.openmbean.OpenMBeanParameterInfo#getMaxValue() getMaxValue()};
- {@code legalValues} defines the values returned by {@link javax.management.openmbean.OpenMBeanParameterInfo#getLegalValues() getLegalValues()}.

For {@code defaultValue}, {@code minValue}, and {@code maxValue}, the associated value must either be of the Java type corresponding to {@code openType}, or be a string that can be converted into that type. The conversion uses the static method {@code valueOf(String)} if it finds one; otherwise a constructor with a single {@code String} parameter if it finds one; otherwise it fails.

For {@code legalValues}, the associated value must be either an array or a {@code Set}, and the elements of the array or set must be convertible as described for {@code defaultValue} etc.

The following conditions must be met for these fields:

- the values must be of the appropriate type, or be strings that can be converted to the appropriate type as explained above;
- if {@code legalValues} is present then neither {@code minValue} nor {@code maxValue} must be present;
- if {@code defaultValue} is present then it must satisfy the constraints defined by {@code legalValues}, {@code minValue}, or {@code maxValue} when any of these is also present;
- if {@code minValue} and {@code maxValue} are both present then {@code minValue} must not be greater than {@code maxValue}.

@see JMX Specification, version 1.4 @since 1.5