APIdia Launch Partner
Top Description Fields Constructors Methods
javax.management

public Class MBeanInfo

extends Object
implements Cloneable, Serializable, DescriptorRead
Class Inheritance
All Implemented Interfaces
javax.management.DescriptorRead, java.io.Serializable, java.lang.Cloneable
Known Direct Subclasses
javax.management.modelmbean.ModelMBeanInfoSupport, javax.management.openmbean.OpenMBeanInfoSupport
Imports
java.io.IOException, .StreamCorruptedException, .Serializable, .ObjectOutputStream, .ObjectInputStream, java.lang.reflect.Method, java.util.Arrays, .Map, .WeakHashMap, .Objects

Describes the management interface exposed by an MBean; that is, the set of attributes and operations which are available for management operations. Instances of this class are immutable. Subclasses may be mutable but this is not recommended.

Usually the MBeanInfo for any given MBean does not change over the lifetime of that MBean. Dynamic MBeans can change their MBeanInfo and in that case it is recommended that they emit a Notification with a type of "jmx.mbean.info.changed" and a userData that is the new MBeanInfo. This is not required, but provides a conventional way for clients of the MBean to discover the change. See also the immutableInfo and infoTimeout fields in the MBeanInfo Descriptor.

The contents of the MBeanInfo for a Dynamic MBean are determined by its getMBeanInfo() method. This includes Open MBeans and Model MBeans, which are kinds of Dynamic MBeans.

The contents of the MBeanInfo for a Standard MBean are determined by the MBean server as follows:

The description returned by getDescription() and the descriptions of the contained attributes and operations are not specified.

The remaining details of the MBeanInfo for a Standard MBean are not specified. This includes the description of any contained constructors, and notifications; the names of parameters to constructors and operations; and the descriptions of constructor parameters.

Since
1.5

Field Summary

Modifier and TypeField and Description
private final transient boolean
arrayGettersSafe

True if this class is known not to override the array-valued getters of MBeanInfo.

private static final Map<Class<?>, Boolean>
arrayGettersSafeMap

Cached results of previous calls to arrayGettersSafe.

private final MBeanAttributeInfo[]
private final String
private final MBeanConstructorInfo[]
private final String
private transient Descriptor
private transient int
private final MBeanNotificationInfo[]
private final MBeanOperationInfo[]
pack-priv static final long

Constructor Summary

AccessConstructor and Description
public
MBeanInfo(String
The name of the Java class of the MBean described by this MBeanInfo. This value may be any syntactically legal Java class name. It does not have to be a Java class known to the MBean server or to the MBean's ClassLoader. If it is a Java class known to the MBean's ClassLoader, it is recommended but not required that the class's public methods include those that would appear in a Standard MBean implementing the attributes and operations in this MBeanInfo.
className
,
String
A human readable description of the MBean (optional).
description
,
MBeanAttributeInfo[]
The list of exposed attributes of the MBean. This may be null with the same effect as a zero-length array.
attributes
,
MBeanConstructorInfo[]
The list of public constructors of the MBean. This may be null with the same effect as a zero-length array.
constructors
,
MBeanOperationInfo[]
The list of operations of the MBean. This may be null with the same effect as a zero-length array.
operations
,
MBeanNotificationInfo[]
The list of notifications emitted. This may be null with the same effect as a zero-length array.
notifications
)

Constructs an MBeanInfo.

public
MBeanInfo(String
The name of the Java class of the MBean described by this MBeanInfo. This value may be any syntactically legal Java class name. It does not have to be a Java class known to the MBean server or to the MBean's ClassLoader. If it is a Java class known to the MBean's ClassLoader, it is recommended but not required that the class's public methods include those that would appear in a Standard MBean implementing the attributes and operations in this MBeanInfo.
className
,
String
A human readable description of the MBean (optional).
description
,
MBeanAttributeInfo[]
The list of exposed attributes of the MBean. This may be null with the same effect as a zero-length array.
attributes
,
MBeanConstructorInfo[]
The list of public constructors of the MBean. This may be null with the same effect as a zero-length array.
constructors
,
MBeanOperationInfo[]
The list of operations of the MBean. This may be null with the same effect as a zero-length array.
operations
,
MBeanNotificationInfo[]
The list of notifications emitted. This may be null with the same effect as a zero-length array.
notifications
,
Descriptor
The descriptor for the MBean. This may be null which is equivalent to an empty descriptor.
descriptor
)

Constructs an MBeanInfo.

Method Summary

Modifier and TypeMethod and Description
pack-priv static boolean
arrayGettersSafe(Class<?> subclass, Class<?> immutableClass)

Return true if subclass is known to preserve the immutability of immutableClass.

private static boolean
arrayGettersSafeHelper(Class<?> subclass, Class<?> immutableClass)

public Object
clone()

Overrides java.lang.Object.clone.

Returns a shallow clone of this instance.

public boolean

Returns:

true if and only if o is an MBeanInfo that is equal to this one according to the rules above.
equals
(Object
the object to compare to.
o
)

Overrides java.lang.Object.equals.

Compare this MBeanInfo to another.

private MBeanAttributeInfo[]
private MBeanConstructorInfo[]
private MBeanNotificationInfo[]
private MBeanOperationInfo[]
public MBeanAttributeInfo[]

Returns:

An array of MBeanAttributeInfo objects.
getAttributes
()

Returns the list of attributes exposed for management.

public String

Returns:

the class name.
getClassName
()

Returns the name of the Java class of the MBean described by this MBeanInfo.

public MBeanConstructorInfo[]

Returns:

An array of MBeanConstructorInfo objects.
getConstructors
()

Returns the list of the public constructors of the MBean.

public String

Returns:

the description.
getDescription
()

Returns a human readable description of the MBean.

public Descriptor

Returns:

a descriptor that is either immutable or a copy of the original.
getDescriptor
()

Implements javax.management.DescriptorRead.getDescriptor.

Get the descriptor of this MBeanInfo.

public MBeanNotificationInfo[]

Returns:

An array of MBeanNotificationInfo objects.
getNotifications
()

Returns the list of the notifications emitted by the MBean.

public MBeanOperationInfo[]

Returns:

An array of MBeanOperationInfo objects.
getOperations
()

Returns the list of operations of the MBean.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

private static boolean
private MBeanAttributeInfo[]
nonNullAttributes()

Return the value of the attributes field, or an empty array if the field is null.

private MBeanConstructorInfo[]
private MBeanNotificationInfo[]
private MBeanOperationInfo[]
private void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private void
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

arrayGettersSafeback to summary
private final transient boolean arrayGettersSafe

True if this class is known not to override the array-valued getters of MBeanInfo. Obviously true for MBeanInfo itself, and true for a subclass where we succeed in reflecting on the methods and discover they are not overridden.

The purpose of this variable is to avoid cloning the arrays when doing operations like equals where we know they will not be changed. If a subclass overrides a getter, we cannot access the corresponding array directly.

arrayGettersSafeMapback to summary
private static final Map<Class<?>, Boolean> arrayGettersSafeMap

Cached results of previous calls to arrayGettersSafe. This is a WeakHashMap so that we don't prevent a class from being garbage collected just because we know whether it's immutable.

attributesback to summary
private final MBeanAttributeInfo[] attributes
classNameback to summary
private final String className
constructorsback to summary
private final MBeanConstructorInfo[] constructors
descriptionback to summary
private final String description
descriptorback to summary
private transient Descriptor descriptor
hashCodeback to summary
private transient int hashCode
notificationsback to summary
private final MBeanNotificationInfo[] notifications
operationsback to summary
private final MBeanOperationInfo[] operations
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Constructor Detail

MBeanInfoback to summary
public MBeanInfo(String className, String description, MBeanAttributeInfo[] attributes, MBeanConstructorInfo[] constructors, MBeanOperationInfo[] operations, MBeanNotificationInfo[] notifications) throws IllegalArgumentException

Constructs an MBeanInfo.

Parameters
className:String

The name of the Java class of the MBean described by this MBeanInfo. This value may be any syntactically legal Java class name. It does not have to be a Java class known to the MBean server or to the MBean's ClassLoader. If it is a Java class known to the MBean's ClassLoader, it is recommended but not required that the class's public methods include those that would appear in a Standard MBean implementing the attributes and operations in this MBeanInfo.

description:String

A human readable description of the MBean (optional).

attributes:MBeanAttributeInfo[]

The list of exposed attributes of the MBean. This may be null with the same effect as a zero-length array.

constructors:MBeanConstructorInfo[]

The list of public constructors of the MBean. This may be null with the same effect as a zero-length array.

operations:MBeanOperationInfo[]

The list of operations of the MBean. This may be null with the same effect as a zero-length array.

notifications:MBeanNotificationInfo[]

The list of notifications emitted. This may be null with the same effect as a zero-length array.

MBeanInfoback to summary
public MBeanInfo(String className, String description, MBeanAttributeInfo[] attributes, MBeanConstructorInfo[] constructors, MBeanOperationInfo[] operations, MBeanNotificationInfo[] notifications, Descriptor descriptor) throws IllegalArgumentException

Constructs an MBeanInfo.

Parameters
className:String

The name of the Java class of the MBean described by this MBeanInfo. This value may be any syntactically legal Java class name. It does not have to be a Java class known to the MBean server or to the MBean's ClassLoader. If it is a Java class known to the MBean's ClassLoader, it is recommended but not required that the class's public methods include those that would appear in a Standard MBean implementing the attributes and operations in this MBeanInfo.

description:String

A human readable description of the MBean (optional).

attributes:MBeanAttributeInfo[]

The list of exposed attributes of the MBean. This may be null with the same effect as a zero-length array.

constructors:MBeanConstructorInfo[]

The list of public constructors of the MBean. This may be null with the same effect as a zero-length array.

operations:MBeanOperationInfo[]

The list of operations of the MBean. This may be null with the same effect as a zero-length array.

notifications:MBeanNotificationInfo[]

The list of notifications emitted. This may be null with the same effect as a zero-length array.

descriptor:Descriptor

The descriptor for the MBean. This may be null which is equivalent to an empty descriptor.

Since
1.6

Method Detail

arrayGettersSafeback to summary
pack-priv static boolean arrayGettersSafe(Class<?> subclass, Class<?> immutableClass)

Return true if subclass is known to preserve the immutability of immutableClass. The class immutableClass is a reference class that is known to be immutable. The subclass subclass is considered immutable if it does not override any public method of immutableClass whose name begins with "get". This is obviously not an infallible test for immutability, but it works for the public interfaces of the MBean*Info classes.

Annotations
@SuppressWarnings:removal
arrayGettersSafeHelperback to summary
private static boolean arrayGettersSafeHelper(Class<?> subclass, Class<?> immutableClass)
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Returns a shallow clone of this instance. The clone is obtained by simply calling super.clone(), thus calling the default native shallow cloning mechanism implemented by Object.clone(). No deeper cloning of any internal field is made.

Since this class is immutable, the clone method is chiefly of interest to subclasses.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Compare this MBeanInfo to another. Two MBeanInfo objects are equal if and only if they return equal values for getClassName(), for getDescription(), and for getDescriptor(), and the arrays returned by the two objects for getAttributes(), getOperations(), getConstructors(), and getNotifications() are pairwise equal. Here "equal" means Object#equals(Object), not identity.

If two MBeanInfo objects return the same values in one of their arrays but in a different order then they are not equal.

Parameters
o:Object

the object to compare to.

Returns:boolean

true if and only if o is an MBeanInfo that is equal to this one according to the rules above.

Annotations
@Override
fastGetAttributesback to summary
private MBeanAttributeInfo[] fastGetAttributes()
fastGetConstructorsback to summary
private MBeanConstructorInfo[] fastGetConstructors()
fastGetNotificationsback to summary
private MBeanNotificationInfo[] fastGetNotifications()
fastGetOperationsback to summary
private MBeanOperationInfo[] fastGetOperations()
getAttributesback to summary
public MBeanAttributeInfo[] getAttributes()

Returns the list of attributes exposed for management. Each attribute is described by an MBeanAttributeInfo object. The returned array is a shallow copy of the internal array, which means that it is a copy of the internal array of references to the MBeanAttributeInfo objects but that each referenced MBeanAttributeInfo object is not copied.

Returns:MBeanAttributeInfo[]

An array of MBeanAttributeInfo objects.

getClassNameback to summary
public String getClassName()

Returns the name of the Java class of the MBean described by this MBeanInfo.

Returns:String

the class name.

getConstructorsback to summary
public MBeanConstructorInfo[] getConstructors()

Returns the list of the public constructors of the MBean. Each constructor is described by an MBeanConstructorInfo object.

The returned array is a shallow copy of the internal array, which means that it is a copy of the internal array of references to the MBeanConstructorInfo objects but that each referenced MBeanConstructorInfo object is not copied.

The returned list is not necessarily exhaustive. That is, the MBean may have a public constructor that is not in the list. In this case, the MBean server can construct another instance of this MBean's class using that constructor, even though it is not listed here.

Returns:MBeanConstructorInfo[]

An array of MBeanConstructorInfo objects.

getDescriptionback to summary
public String getDescription()

Returns a human readable description of the MBean.

Returns:String

the description.

getDescriptorback to summary
public Descriptor getDescriptor()

Implements javax.management.DescriptorRead.getDescriptor.

Get the descriptor of this MBeanInfo. Changing the returned value will have no affect on the original descriptor.

Returns:Descriptor

a descriptor that is either immutable or a copy of the original.

Since
1.6
getNotificationsback to summary
public MBeanNotificationInfo[] getNotifications()

Returns the list of the notifications emitted by the MBean. Each notification is described by an MBeanNotificationInfo object. The returned array is a shallow copy of the internal array, which means that it is a copy of the internal array of references to the MBeanNotificationInfo objects but that each referenced MBeanNotificationInfo object is not copied.

Returns:MBeanNotificationInfo[]

An array of MBeanNotificationInfo objects.

getOperationsback to summary
public MBeanOperationInfo[] getOperations()

Returns the list of operations of the MBean. Each operation is described by an MBeanOperationInfo object. The returned array is a shallow copy of the internal array, which means that it is a copy of the internal array of references to the MBeanOperationInfo objects but that each referenced MBeanOperationInfo object is not copied.

Returns:MBeanOperationInfo[]

An array of MBeanOperationInfo objects.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
isEqualback to summary
private static boolean isEqual(String s1, String s2)
nonNullAttributesback to summary
private MBeanAttributeInfo[] nonNullAttributes()

Return the value of the attributes field, or an empty array if the field is null. This can't happen with a normally-constructed instance of this class, but can if the instance was deserialized from another implementation that allows the field to be null. It would be simpler if we enforced the class invariant that these fields cannot be null by writing a readObject() method, but that would require us to define the various array fields as non-final, which is annoying because conceptually they are indeed final.

nonNullConstructorsback to summary
private MBeanConstructorInfo[] nonNullConstructors()
nonNullNotificationsback to summary
private MBeanNotificationInfo[] nonNullNotifications()
nonNullOperationsback to summary
private MBeanOperationInfo[] nonNullOperations()
readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException

Deserializes an MBeanInfo from an ObjectInputStream.

Since
1.6
Serial data
For compatibility reasons, an object of this class is deserialized as follows.

The method defaultReadObject() is called first to deserialize the object except the field descriptor, which is not serialized in the default way. Then the method read() is called to read a byte, the field descriptor is deserialized according to the value of the byte value:

  • 1. The method readObject() is called twice to obtain the field names (a String[]) and the field values (an Object[]) of the descriptor. The two obtained values then are used to construct an ImmutableDescriptor instance for the field descriptor;
  • 0. The value for the field descriptor is obtained directly by calling the method readObject(). If the obtained value is null, the field descriptor is set to EMPTY_DESCRIPTOR;
  • -1. This means that there is no byte to read and that the object is from an earlier version of the JMX API. The field descriptor is set to EMPTY_DESCRIPTOR.
  • Any other value. A StreamCorruptedException is thrown.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
writeObjectback to summary
private void writeObject(ObjectOutputStream out) throws IOException

Serializes an MBeanInfo to an ObjectOutputStream.

Since
1.6
Serial data
For compatibility reasons, an object of this class is serialized as follows.

The method defaultWriteObject() is called first to serialize the object except the field descriptor which is declared as transient. The field descriptor is serialized as follows:

  • If descriptor is an instance of the class ImmutableDescriptor, the method write(int val) is called to write a byte with the value 1, then the method writeObject(Object obj) is called twice to serialize the field names and the field values of the descriptor, respectively as a String[] and an Object[];
  • Otherwise, the method write(int val) is called to write a byte with the value 0, then the method writeObject(Object obj) is called to serialize the field descriptor directly.