Methods Summary |
---|
private synchronized javax.management.MBeanInfo | buildStandardMBeanInfo()
return meta.buildMBeanInfo(getImplementationClass(),
getMBeanInterface());
|
protected synchronized void | cacheMBeanInfo(javax.management.MBeanInfo info)Customization hook:
cache the MBeanInfo built for this object.
Subclasses may redefine this method in order to implement
their own caching policy. The default implementation stores
info in this instance. A subclass can define
other policies, such as not saving info (so it is
reconstructed every time {@link #getMBeanInfo()} is called) or
sharing a unique {@link MBeanInfo} object when several
StandardMBean instances have equal {@link
MBeanInfo} values.
cachedMBeanInfo = info;
|
private static void | debug(java.lang.String clz, java.lang.String func, java.lang.String info)
Trace.send(Trace.LEVEL_DEBUG, Trace.INFO_MISC, clz, func, info);
|
private static void | debug(java.lang.String func, java.lang.String info)
debug(dbgTag, func, info);
|
private static void | debugX(java.lang.String func, java.lang.Throwable e)
if (isDebugOn()) {
final StringWriter s = new StringWriter();
e.printStackTrace(new PrintWriter(s));
final String stack = s.toString();
debug(dbgTag,func,"Exception caught in "+ func+"(): "+e);
debug(dbgTag,func,stack);
// java.lang.System.err.println("**** Exception caught in "+
// func+"(): "+e);
// java.lang.System.err.println(stack);
}
|
public java.lang.Object | getAttribute(java.lang.String attribute)
return meta.getAttribute(getImplementation(),attribute);
|
public javax.management.AttributeList | getAttributes(java.lang.String[] attributes)
try {
return meta.getAttributes(getImplementation(),attributes);
} catch (ReflectionException x) {
final RuntimeException r =
new UndeclaredThrowableException(x,x.getMessage());
throw new RuntimeOperationsException(r,x.getMessage());
}
|
private javax.management.MBeanAttributeInfo[] | getAttributes(javax.management.MBeanInfo info)
final MBeanAttributeInfo[] atts = info.getAttributes();
final MBeanAttributeInfo[] natts;
if (atts != null) {
final int attlen = atts.length;
natts = new MBeanAttributeInfo[attlen];
for (int i=0; i<attlen; i++) {
final MBeanAttributeInfo a = atts[i];
natts[i] = new MBeanAttributeInfo(a.getName(),
a.getType(),
getDescription(a),
a.isReadable(),
a.isWritable(),
a.isIs());
}
} else {
natts = null;
}
return natts;
|
protected synchronized javax.management.MBeanInfo | getCachedMBeanInfo()Customization hook:
Return the MBeanInfo cached for this object.
Subclasses may redefine this method in order to implement their
own caching policy. The default implementation stores one
{@link MBeanInfo} object per instance.
return cachedMBeanInfo;
|
protected java.lang.String | getClassName(javax.management.MBeanInfo info)Customization hook:
Get the className that will be used in the MBeanInfo returned by
this MBean.
Subclasses may redefine this method in order to supply their
custom class name. The default implementation returns
{@link MBeanInfo#getClassName() info.getClassName()}.
if (info == null) return getImplementationClass().getName();
return info.getClassName();
|
protected javax.management.MBeanConstructorInfo[] | getConstructors(javax.management.MBeanConstructorInfo[] ctors, java.lang.Object impl)Customization hook:
Get the MBeanConstructorInfo[] that will be used in the MBeanInfo
returned by this MBean.
By default, this method returns null if the wrapped
implementation is not this. Indeed, if the wrapped
implementation is not this object itself, it will not be possible
to recreate a wrapped implementation by calling the implementation
constructors through MBeanServer.createMBean(...) .
Otherwise, if the wrapped implementation is this,
ctors is returned.
Subclasses may redefine this method in order to modify this
behavior, if needed.
if (ctors == null) return null;
if (impl != null && impl != this) return null;
return ctors;
|
private javax.management.MBeanConstructorInfo[] | getConstructors(javax.management.MBeanInfo info, java.lang.Object impl)
final MBeanConstructorInfo[] ctors =
getConstructors(info.getConstructors(),impl);
final MBeanConstructorInfo[] nctors;
if (ctors != null) {
final int ctorlen = ctors.length;
nctors = new MBeanConstructorInfo[ctorlen];
for (int i=0; i<ctorlen; i++) {
final MBeanConstructorInfo c = ctors[i];
final MBeanParameterInfo[] params = c.getSignature();
final MBeanParameterInfo[] nps;
if (params != null) {
final int plen = params.length;
nps = new MBeanParameterInfo[plen];
for (int ii=0;ii<plen;ii++) {
MBeanParameterInfo p = params[ii];
final String name = getParameterName(c,p,ii);
final String text = getDescription(c,p,ii);
nps[ii] = new MBeanParameterInfo(name,
p.getType(),
text);
}
} else {
nps = null;
}
nctors[i] = new MBeanConstructorInfo(c.getName(),
getDescription(c),
nps);
}
} else {
nctors = null;
}
return nctors;
|
protected java.lang.String | getDescription(javax.management.MBeanInfo info)Customization hook:
Get the description that will be used in the MBeanInfo returned by
this MBean.
Subclasses may redefine this method in order to supply their
custom MBean description. The default implementation returns
{@link MBeanInfo#getDescription() info.getDescription()}.
if (info == null) return null;
return info.getDescription();
|
protected java.lang.String | getDescription(javax.management.MBeanFeatureInfo info)Customization hook:
Get the description that will be used in the MBeanFeatureInfo
returned by this MBean.
Subclasses may redefine this method in order to supply
their custom description. The default implementation returns
{@link MBeanFeatureInfo#getDescription()
info.getDescription()}.
This method is called by
{@link #getDescription(MBeanAttributeInfo)},
{@link #getDescription(MBeanOperationInfo)},
{@link #getDescription(MBeanConstructorInfo)}.
if (info == null) return null;
return info.getDescription();
|
protected java.lang.String | getDescription(javax.management.MBeanAttributeInfo info)Customization hook:
Get the description that will be used in the MBeanAttributeInfo
returned by this MBean.
Subclasses may redefine this method in order to supply their
custom description. The default implementation returns {@link
#getDescription(MBeanFeatureInfo)
getDescription((MBeanFeatureInfo) info)}.
return getDescription((MBeanFeatureInfo)info);
|
protected java.lang.String | getDescription(javax.management.MBeanConstructorInfo info)Customization hook:
Get the description that will be used in the MBeanConstructorInfo
returned by this MBean.
Subclasses may redefine this method in order to supply their
custom description.
The default implementation returns {@link
#getDescription(MBeanFeatureInfo)
getDescription((MBeanFeatureInfo) info)}.
return getDescription((MBeanFeatureInfo)info);
|
protected java.lang.String | getDescription(javax.management.MBeanConstructorInfo ctor, javax.management.MBeanParameterInfo param, int sequence)Customization hook:
Get the description that will be used for the sequence
MBeanParameterInfo of the MBeanConstructorInfo returned by this MBean.
Subclasses may redefine this method in order to supply their
custom description. The default implementation returns
{@link MBeanParameterInfo#getDescription() param.getDescription()}.
if (param == null) return null;
return param.getDescription();
|
protected java.lang.String | getDescription(javax.management.MBeanOperationInfo info)Customization hook:
Get the description that will be used in the MBeanOperationInfo
returned by this MBean.
Subclasses may redefine this method in order to supply their
custom description. The default implementation returns
{@link #getDescription(MBeanFeatureInfo)
getDescription((MBeanFeatureInfo) info)}.
return getDescription((MBeanFeatureInfo)info);
|
protected java.lang.String | getDescription(javax.management.MBeanOperationInfo op, javax.management.MBeanParameterInfo param, int sequence)Customization hook:
Get the description that will be used for the sequence
MBeanParameterInfo of the MBeanOperationInfo returned by this MBean.
Subclasses may redefine this method in order to supply their
custom description. The default implementation returns
{@link MBeanParameterInfo#getDescription() param.getDescription()}.
if (param == null) return null;
return param.getDescription();
|
protected int | getImpact(javax.management.MBeanOperationInfo info)Customization hook:
Get the impact flag of the operation that will be used in
the MBeanOperationInfo returned by this MBean.
Subclasses may redefine this method in order to supply their
custom impact flag. The default implementation returns
{@link MBeanOperationInfo#getImpact() info.getImpact()}.
if (info == null) return MBeanOperationInfo.UNKNOWN;
return info.getImpact();
|
public synchronized java.lang.Object | getImplementation()Get the implementation of this MBean.
return implementation;
|
public synchronized java.lang.Class | getImplementationClass()Get the class of the implementation of this MBean.
if (implementation == null) return null;
return implementation.getClass();
|
public javax.management.MBeanInfo | getMBeanInfo()Get the {@link MBeanInfo} for this MBean.
This method implements
{@link javax.management.DynamicMBean#getMBeanInfo()
DynamicMBean.getMBeanInfo()}.
This method first calls {@link #getCachedMBeanInfo()} in order to
retrieve the cached MBeanInfo for this MBean, if any. If the
MBeanInfo returned by {@link #getCachedMBeanInfo()} is not null,
then it is returned.
Otherwise, this method builds a default MBeanInfo for this MBean,
using the Management Interface specified for this MBean.
While building the MBeanInfo, this method calls the customization
hooks that make it possible for subclasses to supply their custom
descriptions, parameter names, etc...
Finally, it calls {@link #cacheMBeanInfo(javax.management.MBeanInfo)
cacheMBeanInfo()} in order to cache the new MBeanInfo.
try {
final MBeanInfo cached = getCachedMBeanInfo();
if (cached != null) return (MBeanInfo)cached;
} catch (RuntimeException x) {
debug("getMBeanInfo","failed to get cached MBeanInfo: "+x);
debugX("getMBeanInfo",x);
}
if (isTraceOn()) {
trace("getMBeanInfo", "Building MBeanInfo for "+
getImplementationClass().getName());
}
final MBeanInfo bi;
final Object impl;
try {
synchronized (this) {
impl = getImplementation();
bi = buildStandardMBeanInfo();
}
} catch (NotCompliantMBeanException x) {
final RuntimeException r =
new UndeclaredThrowableException(x,x.getMessage());
throw new RuntimeOperationsException(r,x.getMessage());
}
final String cname = getClassName(bi);
final String text = getDescription(bi);
final MBeanConstructorInfo[] ctors = getConstructors(bi,impl);
final MBeanAttributeInfo[] attrs = getAttributes(bi);
final MBeanOperationInfo[] ops = getOperations(bi);
final MBeanNotificationInfo[] ntfs = getNotifications(bi);
final MBeanInfo nmbi =
new MBeanInfo(cname,text,attrs,ctors,ops,ntfs);
try { cacheMBeanInfo(nmbi); } catch (RuntimeException x) {
debug("cacheMBeanInfo","failed to cache MBeanInfo: "+x);
debugX("cacheMBeanInfo",x);
}
return nmbi;
|
public final synchronized java.lang.Class | getMBeanInterface()Get the Management Interface of this MBean.
return mbeanInterface;
|
private javax.management.MBeanNotificationInfo[] | getNotifications(javax.management.MBeanInfo info)Customization hook:
Get the MBeanNotificationInfo[] that will be used in the MBeanInfo
returned by this MBean.
Subclasses may redefine this method in order to supply their
custom notifications.
if (info == null) return null;
return info.getNotifications();
|
private javax.management.MBeanOperationInfo[] | getOperations(javax.management.MBeanInfo info)
final MBeanOperationInfo[] ops = info.getOperations();
final MBeanOperationInfo[] nops;
if (ops != null) {
final int oplen = ops.length;
nops = new MBeanOperationInfo[oplen];
for (int i=0; i<oplen; i++) {
final MBeanOperationInfo o = ops[i];
final MBeanParameterInfo[] params = o.getSignature();
final MBeanParameterInfo[] nps;
if (params != null) {
final int plen = params.length;
nps = new MBeanParameterInfo[plen];
for (int ii=0;ii<plen;ii++) {
MBeanParameterInfo p = params[ii];
final String name = getParameterName(o,p,ii);
final String text = getDescription(o,p,ii);
nps[ii] = new MBeanParameterInfo(name,
p.getType(),
text);
}
} else {
nps = null;
}
nops[i] = new MBeanOperationInfo(o.getName(),
getDescription(o),
nps,
o.getReturnType(),
getImpact(o));
}
} else {
nops = null;
}
return nops;
|
protected java.lang.String | getParameterName(javax.management.MBeanConstructorInfo ctor, javax.management.MBeanParameterInfo param, int sequence)Customization hook:
Get the name that will be used for the sequence
MBeanParameterInfo of the MBeanConstructorInfo returned by this MBean.
Subclasses may redefine this method in order to supply their
custom parameter name. The default implementation returns
{@link MBeanParameterInfo#getName() param.getName()}.
if (param == null) return null;
return param.getName();
|
protected java.lang.String | getParameterName(javax.management.MBeanOperationInfo op, javax.management.MBeanParameterInfo param, int sequence)Customization hook:
Get the name that will be used for the sequence
MBeanParameterInfo of the MBeanOperationInfo returned by this MBean.
Subclasses may redefine this method in order to supply their
custom parameter name. The default implementation returns
{@link MBeanParameterInfo#getName() param.getName()}.
if (param == null) return null;
return param.getName();
|
public java.lang.Object | invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
return meta.invoke(getImplementation(),actionName,params,signature);
|
private static boolean | isDebugOn()
return Trace.isSelected(Trace.LEVEL_DEBUG, Trace.INFO_MISC);
|
private static boolean | isTraceOn()
return Trace.isSelected(Trace.LEVEL_TRACE, Trace.INFO_MISC);
|
public void | setAttribute(javax.management.Attribute attribute)
meta.setAttribute(getImplementation(),attribute);
|
public javax.management.AttributeList | setAttributes(javax.management.AttributeList attributes)
try {
return meta.setAttributes(getImplementation(),attributes);
} catch (ReflectionException x) {
final RuntimeException r =
new UndeclaredThrowableException(x,x.getMessage());
throw new RuntimeOperationsException(r,x.getMessage());
}
|
public synchronized void | setImplementation(java.lang.Object implementation)Replace the implementation object wrapped in this
object.
setImplementation(implementation, getMBeanInterface());
|
private synchronized void | setImplementation(java.lang.Object implementation, java.lang.Class mbeanInterface)Replace the implementation and management interface wrapped in
this object.
if (implementation == null)
throw new IllegalArgumentException("implementation is null");
// test compliance
this.meta.testCompliance(implementation.getClass(),mbeanInterface);
// flush the cache...
cacheMBeanInfo(null);
this.implementation = implementation;
this.mbeanInterface = mbeanInterface;
if (this.mbeanInterface == null)
this.mbeanInterface =
meta.getStandardMBeanInterface(implementation.getClass());
|
private static void | trace(java.lang.String clz, java.lang.String func, java.lang.String info)
Trace.send(Trace.LEVEL_TRACE, Trace.INFO_MISC, clz, func, info);
|
private static void | trace(java.lang.String func, java.lang.String info)
trace(dbgTag, func, info);
|