Methods Summary |
---|
abstract void | checkMethod(M m)Check that this method is valid. For example, a method in an
MXBean interface is not valid if one of its parameters cannot be
mapped to an Open Type.
|
final boolean | consistent(M getter, M setter)True if the given getter and setter are consistent.
return (getter == null || setter == null ||
getGenericReturnType(getter).equals(getGenericParameterTypes(setter)[0]));
|
private static javax.management.MBeanConstructorInfo[] | findConstructors(java.lang.Class c)
Constructor[] cons = c.getConstructors();
MBeanConstructorInfo[] mbc = new MBeanConstructorInfo[cons.length];
for (int i = 0; i < cons.length; i++) {
final String descr = "Public constructor of the MBean";
mbc[i] = new MBeanConstructorInfo(descr, cons[i]);
}
return mbc;
|
static javax.management.MBeanNotificationInfo[] | findNotifications(java.lang.Object moi)
if (!(moi instanceof NotificationBroadcaster))
return null;
MBeanNotificationInfo[] mbn =
((NotificationBroadcaster) moi).getNotificationInfo();
if (mbn == null)
return null;
MBeanNotificationInfo[] result =
new MBeanNotificationInfo[mbn.length];
for (int i = 0; i < mbn.length; i++) {
MBeanNotificationInfo ni = mbn[i];
if (ni.getClass() != MBeanNotificationInfo.class)
ni = (MBeanNotificationInfo) ni.clone();
result[i] = ni;
}
return result;
|
abstract com.sun.jmx.mbeanserver.MBeanAnalyzer | getAnalyzer(java.lang.Class mbeanInterface)Make an interface analyzer for this type of MBean.
|
abstract javax.management.Descriptor | getBasicMBeanDescriptor()Get a Descriptor containing fields that MBeans of this kind will
always have. For example, MXBeans will always have "mxbean=true".
|
final javax.management.MBeanInfo | getClassMBeanInfo(java.lang.Class resourceClass, com.sun.jmx.mbeanserver.PerInterface perInterface)Return the basic MBeanInfo for resources of the given class and
per-interface data. This MBeanInfo might not be the final MBeanInfo
for instances of the class, because if the class is a
NotificationBroadcaster then each instance gets to decide what
MBeanNotificationInfo[] to put in its own MBeanInfo.
MBeanInfoMap map = getMBeanInfoMap();
synchronized (map) {
WeakHashMap<Class<?>, MBeanInfo> intfMap = map.get(resourceClass);
if (intfMap == null) {
intfMap = new WeakHashMap<Class<?>, MBeanInfo>();
map.put(resourceClass, intfMap);
}
Class<?> intfClass = perInterface.getMBeanInterface();
MBeanInfo mbi = intfMap.get(intfClass);
if (mbi == null) {
MBeanInfo imbi = perInterface.getMBeanInfo();
Descriptor descriptor =
ImmutableDescriptor.union(imbi.getDescriptor(),
getMBeanDescriptor(resourceClass));
mbi = new MBeanInfo(resourceClass.getName(),
imbi.getDescription(),
imbi.getAttributes(),
findConstructors(resourceClass),
imbi.getOperations(),
(MBeanNotificationInfo[]) null,
descriptor);
intfMap.put(intfClass, mbi);
}
return mbi;
}
|
abstract java.lang.reflect.Type[] | getGenericParameterTypes(M m)Get the parameter types of this method in the Java interface
it came from.
|
abstract java.lang.reflect.Type | getGenericReturnType(M m)Get the return type of this method. This is the return type
of a method in a Java interface, so for MXBeans it is the
declared Java type, not the mapped Open Type.
|
abstract javax.management.MBeanAttributeInfo | getMBeanAttributeInfo(java.lang.String attributeName, M getter, M setter)Construct an MBeanAttributeInfo for the given attribute based on the
given getter and setter. One but not both of the getter and setter
may be null.
|
abstract javax.management.Descriptor | getMBeanDescriptor(java.lang.Class resourceClass)Get a Descriptor containing additional fields beyond the ones
from getBasicMBeanDescriptor that MBeans whose concrete class
is resourceClass will always have.
|
final javax.management.MBeanInfo | getMBeanInfo(java.lang.Object resource, com.sun.jmx.mbeanserver.PerInterface perInterface)Return the MBeanInfo for the given resource, based on the given
per-interface data.
/*
* Looking up the MBeanInfo for a given base class (implementation class)
* is complicated by the fact that we may use the same base class with
* several different explicit MBean interfaces via the
* javax.management.StandardMBean class. It is further complicated
* by the fact that we have to be careful not to retain a strong reference
* to any Class object for fear we would prevent a ClassLoader from being
* garbage-collected. So we have a first lookup from the base class
* to a map for each interface that base class might specify giving
* the MBeanInfo constructed for that base class and interface.
*/
MBeanInfo mbi =
getClassMBeanInfo(resource.getClass(), perInterface);
MBeanNotificationInfo[] notifs = findNotifications(resource);
if (notifs == null || notifs.length == 0)
return mbi;
else {
return new MBeanInfo(mbi.getClassName(),
mbi.getDescription(),
mbi.getAttributes(),
mbi.getConstructors(),
mbi.getOperations(),
notifs,
mbi.getDescriptor());
}
|
abstract com.sun.jmx.mbeanserver.MBeanIntrospector$MBeanInfoMap | getMBeanInfoMap()The map from concrete implementation class and interface to
MBeanInfo for this type of MBean.
|
abstract javax.management.MBeanOperationInfo | getMBeanOperationInfo(java.lang.String operationName, M operation)Construct an MBeanOperationInfo for the given operation based on
the M it was derived from.
|
abstract java.lang.String | getName(M m)Get the name of this method.
|
final com.sun.jmx.mbeanserver.PerInterface | getPerInterface(java.lang.Class mbeanInterface)
PerInterfaceMap<M> map = getPerInterfaceMap();
synchronized (map) {
WeakReference<PerInterface<M>> wr = map.get(mbeanInterface);
PerInterface<M> pi = (wr == null) ? null : wr.get();
if (pi == null) {
try {
MBeanAnalyzer<M> analyzer = getAnalyzer(mbeanInterface);
MBeanInfo mbeanInfo =
makeInterfaceMBeanInfo(mbeanInterface, analyzer);
pi = new PerInterface<M>(mbeanInterface, this, analyzer,
mbeanInfo);
wr = new WeakReference<PerInterface<M>>(pi);
map.put(mbeanInterface, wr);
} catch (Exception x) {
throw Introspector.throwException(mbeanInterface,x);
}
}
return pi;
}
|
abstract com.sun.jmx.mbeanserver.MBeanIntrospector$PerInterfaceMap | getPerInterfaceMap()The map from interface to PerInterface for this type of MBean.
|
abstract java.lang.String[] | getSignature(M m)Get the signature of this method as a caller would have to supply
it in MBeanServer.invoke. For MXBeans, the named types will be
the mapped Open Types for the parameters.
|
final java.lang.Object | invokeM(M m, java.lang.Object target, java.lang.Object[] args, java.lang.Object cookie)Invoke the given M on the given target with the given args and cookie.
Wrap exceptions appropriately.
try {
return invokeM2(m, target, args, cookie);
} catch (InvocationTargetException e) {
unwrapInvocationTargetException(e);
throw new RuntimeException(e); // not reached
} catch (IllegalAccessException e) {
throw new ReflectionException(e, e.toString());
}
/* We do not catch and wrap RuntimeException or Error,
* because we're in a DynamicMBean, so the logic for DynamicMBeans
* will do the wrapping.
*/
|
abstract java.lang.Object | invokeM2(M m, java.lang.Object target, java.lang.Object[] args, java.lang.Object cookie)Invoke the method with the given target and arguments.
|
final void | invokeSetter(java.lang.String name, M setter, java.lang.Object target, java.lang.Object arg, java.lang.Object cookie)Invoke the given setter on the given target with the given argument
and cookie. Wrap exceptions appropriately.
try {
invokeM2(setter, target, new Object[] {arg}, cookie);
} catch (IllegalAccessException e) {
throw new ReflectionException(e, e.toString());
} catch (RuntimeException e) {
maybeInvalidParameter(name, setter, arg, cookie);
throw e;
} catch (InvocationTargetException e) {
maybeInvalidParameter(name, setter, arg, cookie);
unwrapInvocationTargetException(e);
}
|
abstract boolean | isMXBean()True if MBeans with this kind of introspector are MXBeans.
|
static boolean | isValidParameter(java.lang.reflect.Method m, java.lang.Object value, int paramNo)
Class<?> c = m.getParameterTypes()[paramNo];
try {
// Following is expensive but we only call this method to determine
// if an exception is due to an incompatible parameter type.
// Plain old c.isInstance doesn't work for primitive types.
Object a = Array.newInstance(c, 1);
Array.set(a, 0, value);
return true;
} catch (IllegalArgumentException e) {
return false;
}
|
abstract M | mFrom(java.lang.reflect.Method m)Find the M corresponding to the given Method.
|
private javax.management.MBeanInfo | makeInterfaceMBeanInfo(java.lang.Class mbeanInterface, com.sun.jmx.mbeanserver.MBeanAnalyzer analyzer)Make the MBeanInfo skeleton for the given MBean interface using
the given analyzer. This will never be the MBeanInfo of any real
MBean (because the getClassName() must be a concrete class), but
its MBeanAttributeInfo[] and MBeanOperationInfo[] can be inserted
into such an MBeanInfo, and its Descriptor can be the basis for
the MBeanInfo's Descriptor.
final MBeanInfoMaker maker = new MBeanInfoMaker();
analyzer.visit(maker);
final String description =
"Information on the management interface of the MBean";
return maker.makeMBeanInfo(mbeanInterface, description);
|
private void | maybeInvalidParameter(java.lang.String name, M setter, java.lang.Object arg, java.lang.Object cookie)
if (!validParameter(setter, arg, 0, cookie)) {
final String msg =
"Invalid value for attribute " + name + ": " + arg;
throw new InvalidAttributeValueException(msg);
}
|
private static void | unwrapInvocationTargetException(java.lang.reflect.InvocationTargetException e)
Throwable t = e.getCause();
if (t instanceof RuntimeException)
throw (RuntimeException) t;
else if (t instanceof Error)
throw (Error) t;
else
throw new MBeanException((Exception) t,
(t == null ? null : t.toString()));
|
abstract boolean | validParameter(M m, java.lang.Object value, int paramNo, java.lang.Object cookie)Test whether the given value is valid for the given parameter of this
M.
|