Methods Summary |
---|
private static int | arrayHashCode(java.lang.Object[] array)
int hash = 0;
for (int i = 0; i < array.length; i++)
hash ^= array[i].hashCode();
return hash;
|
public 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.
try {
return super.clone() ;
} catch (CloneNotSupportedException e) {
// should not happen as this class is cloneable
return null;
}
|
public boolean | equals(java.lang.Object o)Compare this MBeanInfo to another. Two MBeanInfo objects
are equal iff they return equal values for {@link
#getClassName()} and for {@link #getDescription()}, and the
arrays returned by the two objects for {@link
#getAttributes()}, {@link #getOperations()}, {@link
#getConstructors()}, and {@link #getNotifications()} are
pairwise equal. Here "equal" means {@link
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.
if (o == this)
return true;
if (!(o instanceof MBeanInfo))
return false;
MBeanInfo p = (MBeanInfo) o;
if (!p.getClassName().equals(getClassName()) ||
!p.getDescription().equals(getDescription()))
return false;
return
(Arrays.equals(p.fastGetAttributes(), fastGetAttributes()) &&
Arrays.equals(p.fastGetOperations(), fastGetOperations()) &&
Arrays.equals(p.fastGetConstructors(), fastGetConstructors()) &&
Arrays.equals(p.fastGetNotifications(), fastGetNotifications()));
|
private javax.management.MBeanAttributeInfo[] | fastGetAttributes()
if (immutable)
return nonNullAttributes();
else
return getAttributes();
|
private javax.management.MBeanConstructorInfo[] | fastGetConstructors()
if (immutable)
return nonNullConstructors();
else
return getConstructors();
|
private javax.management.MBeanNotificationInfo[] | fastGetNotifications()
if (immutable)
return nonNullNotifications();
else
return getNotifications();
|
private javax.management.MBeanOperationInfo[] | fastGetOperations()
if (immutable)
return nonNullOperations();
else
return getOperations();
|
public javax.management.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.
MBeanAttributeInfo[] as = nonNullAttributes();
if (as.length == 0)
return as;
else
return (MBeanAttributeInfo[]) as.clone();
|
public java.lang.String | getClassName()Returns the name of the Java class of the MBean described by
this MBeanInfo .
return className;
|
public javax.management.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.
MBeanConstructorInfo[] cs = nonNullConstructors();
if (cs.length == 0)
return cs;
else
return (MBeanConstructorInfo[]) cs.clone();
|
public java.lang.String | getDescription()Returns a human readable description of the MBean.
return description;
|
public javax.management.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.
MBeanNotificationInfo[] ns = nonNullNotifications();
if (ns.length == 0)
return ns;
else
return (MBeanNotificationInfo[]) ns.clone();
|
public javax.management.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.
MBeanOperationInfo[] os = nonNullOperations();
if (os.length == 0)
return os;
else
return (MBeanOperationInfo[]) os.clone();
|
public int | hashCode()
/* Since computing the hashCode is quite expensive, we cache it.
If by some terrible misfortune the computed value is 0, the
caching won't work and we will recompute it every time.
We don't bother synchronizing, because, at worst, n different
threads will compute the same hashCode at the same time. */
if (hashCode != 0)
return hashCode;
hashCode =
getClassName().hashCode() ^
arrayHashCode(fastGetAttributes()) ^
arrayHashCode(fastGetOperations()) ^
arrayHashCode(fastGetConstructors()) ^
arrayHashCode(fastGetNotifications());
return hashCode;
|
static boolean | isImmutableClass(java.lang.Class subclass, java.lang.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" or
"is". This is obviously not an infallible test for immutability,
but it works for the public interfaces of the MBean*Info classes.
if (subclass == immutableClass)
return true;
synchronized (immutability) {
Boolean immutable = (Boolean) immutability.get(subclass);
if (immutable == null) {
try {
PrivilegedAction immutabilityAction =
new ImmutabilityAction(subclass, immutableClass);
immutable = (Boolean)
AccessController.doPrivileged(immutabilityAction);
} catch (Exception e) { // e.g. SecurityException
/* We don't know, so we assume it isn't. */
immutable = Boolean.FALSE;
}
immutability.put(subclass, immutable);
}
return immutable.booleanValue();
}
|
private javax.management.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.
return (attributes == null) ?
MBeanAttributeInfo.NO_ATTRIBUTES : attributes;
|
private javax.management.MBeanConstructorInfo[] | nonNullConstructors()
return (constructors == null) ?
MBeanConstructorInfo.NO_CONSTRUCTORS : constructors;
|
private javax.management.MBeanNotificationInfo[] | nonNullNotifications()
return (notifications == null) ?
MBeanNotificationInfo.NO_NOTIFICATIONS : notifications;
|
private javax.management.MBeanOperationInfo[] | nonNullOperations()
return (operations == null) ?
MBeanOperationInfo.NO_OPERATIONS : operations;
|