Constructors Summary |
---|
public Basic()Construtor, used to expose the management interface
of this MBean through the dynamic MBean metadata
classes.
try {
//
// Build attribute metadata:
// - NumberOfResets
// - TraceOn
// - DebugOn
//
OpenMBeanAttributeInfo[] attributeInfo = new OpenMBeanAttributeInfo[3];
attributeInfo[0] = new OpenMBeanAttributeInfoSupport(
"NumberOfResets",
"The number of times reset() has been called.",
SimpleType.INTEGER,
true,
false, // not writable
false,
new Integer(0),
null
);
attributeInfo[1] = new OpenMBeanAttributeInfoSupport(
"TraceOn",
"Indicates whether or not tracing is on.",
SimpleType.BOOLEAN,
true,
false, // not writable
false,
new Boolean(false),
null
);
attributeInfo[2] = new OpenMBeanAttributeInfoSupport(
"DebugOn",
"Indicates whether or not debugging is on.",
SimpleType.BOOLEAN,
true,
false, // not writable
false,
new Boolean(false),
null
);
//
// Now build Constructor metadata
//
OpenMBeanConstructorInfo[] constructorInfo = new OpenMBeanConstructorInfo[0];
//
// Now build operation metadata:
// - enableTracing
// - disableTracing
// - enableDebugging
// - disableDebugging
// - reset
//
OpenMBeanOperationInfo[] operationInfo = new OpenMBeanOperationInfo[0];
//
// Build Notification Metadata:
// - none
//
MBeanNotificationInfo[] notificationInfo = new MBeanNotificationInfo[0];
//
// Now (finally!) create the MBean info metadata object
//
_MBeanInfo = new OpenMBeanInfoSupport(
this.getClass().getName(),
"Basic MBean instrumented as an open MBean",
attributeInfo,
constructorInfo,
operationInfo,
notificationInfo
);
} catch (Exception e) {
trace(e);
}
|
Methods Summary |
---|
public void | disableDebugging()put your documentation comment here
_debugOn = false;
|
public void | disableTracing()put your documentation comment here
_traceOn = false;
|
public void | enableDebugging()put your documentation comment here
_debugOn = true;
|
public void | enableTracing()
_traceOn = true;
|
public java.lang.Object | getAttribute(java.lang.String attributeName)Obtains the value of a specific attribute of the Dynamic MBean.
Object ret = null;
//
// See if attribute is recognized.
//
if (attributeName.equals("NumberOfResets")) {
ret = new Integer(getNumberOfResets());
}
else if (attributeName.equals("TraceOn")) {
ret = new Boolean(isTraceOn());
}
else if (attributeName.equals("DebugOn")) {
ret = new Boolean(isDebugOn());
}
// If attribute_name has not been recognized throw an AttributeNotFoundException
else
throw new AttributeNotFoundException("Basic.getAttribute(): ERROR: "
+ "Cannot find " + attributeName + " attribute.");
return ret;
|
public javax.management.AttributeList | getAttributes(java.lang.String[] attributeNames)Enables the values of several attributes of the Dynamic MBean.
AttributeList resultList = new AttributeList();
for (int aa = 0; aa < attributeNames.length; aa++) {
try {
Object value = getAttribute((String)attributeNames[aa]);
resultList.add(new Attribute(attributeNames[aa], value));
} catch (Exception e) {
e.printStackTrace();
}
}
return resultList;
|
java.lang.Class | getClassFromString(java.lang.String className)put your documentation comment here
Class ret = null;
if (className.equals(Boolean.TYPE.getName()))
ret = Boolean.TYPE;
else if (className.equals(Character.TYPE.getName()))
ret = Character.TYPE;
else if (className.equals(Byte.TYPE.getName()))
ret = Byte.TYPE;
else if (className.equals(Short.TYPE.getName()))
ret = Short.TYPE;
else if (className.equals(Integer.TYPE.getName()))
ret = Integer.TYPE;
else if (className.equals(Long.TYPE.getName()))
ret = Long.TYPE;
else if (className.equals(Float.TYPE.getName()))
ret = Float.TYPE;
else if (className.equals(Double.TYPE.getName()))
ret = Double.TYPE;
else if (className.equals(Void.TYPE.getName()))
ret = Void.TYPE;
//
// Not a primitive type, just load the class based
/// on the name.
//
else
ret = Class.forName(className);
return ret;
|
public javax.management.MBeanInfo | getMBeanInfo()Provides the exposed attributes and actions of the Dynamic MBean using an MBeanInfo object.
return (_MBeanInfo);
|
public int | getNumberOfResets()put your documentation comment here
return _numberOfResets;
|
protected javax.management.openmbean.OpenMBeanInfo | getOpenMBeanInfo()
return (OpenMBeanInfo)_MBeanInfo;
|
public java.lang.Object | invoke(java.lang.String operationName, java.lang.Object[] params, java.lang.String[] signature)Allows an action to be invoked on the Dynamic MBean.
Object ret = Void.TYPE;
// Check for a recognized operation name and call the corresponding operation
if (operationName.equals("enableTracing")) {
enableTracing();
}
else if (operationName.equals("disableTracing")) {
disableTracing();
}
else if (operationName.equals("enableDebugging")) {
enableDebugging();
}
else if (operationName.equals("disableDebugging")) {
disableDebugging();
}
else if (operationName.equals("reset")) {
reset();
}
else {
// unrecognized operation name:
throw new ReflectionException(new NoSuchMethodException(operationName),
"Basic.invoke(): ERROR: " + "Cannot find the operation "
+ operationName + "!");
}
return ret;
|
public boolean | isDebugOn()put your documentation comment here
return _debugOn;
|
public boolean | isTraceOn()
return _traceOn;
|
public abstract void | reset()put your documentation comment here
|
public void | setAttribute(javax.management.Attribute attribute)Sets the value of a specific attribute of the Dynamic MBean
//
// No writeable attributes on the management interface.
/// Nothing to do.
//
|
public javax.management.AttributeList | setAttributes(javax.management.AttributeList attributes)Sets the values of several attributes of the Dynamic MBean
//
// No writeable attributes on the management interface...
/// Return an empty AttributeList.
//
AttributeList atts = new AttributeList();
return atts;
|
public void | setNumberOfResets(int value)
_numberOfResets = value;
|
private void | trace(java.lang.String message)
if (isTraceOn()) {
System.out.println(message);
}
traceLog(message);
|
private void | trace(java.lang.Throwable t)put your documentation comment here
traceLog(t);
|
private void | traceLog(java.lang.Throwable t)put your documentation comment here
if (isTraceOn()) {
_logger.write(t);
}
|
private void | traceLog(java.lang.String message)put your documentation comment here
if (isTraceOn()) {
_logger.write(message);
}
|