Methods Summary |
---|
public java.lang.Object | getAttribute(java.lang.String str)Implementation of DynamicMBean interface's method. Parses the passed in
attribute into two portions.
One portion invokes the corresponding method in the Stats object and
the second portion is used to invoke the underlying method in the
Statistic object returned by the Stats object in the first invocation.
Example of an attribute pattern: For JVMStats, HeapSize_UpperBound would
translate into JVMStats.getHeapSize() which returns a BoundedRangeStatistic
object. The BoundedRangeStatistic.getUpperBound() method is invoked
to return the value of the attribute to the client.
if(str == null){
throw new NullPointerException("An attribute needs to be specified to get value");
}
introspect();
if(!isValidAttribute(str)){
throw new AttributeNotFoundException("The requested attribute is not recognized");
}
Statistic a = null;
Object retval=null;
String[] attrParts = AttributeStringHelper.splitAttribute(str);
logger.log(Level.INFO,"accessing the Stats object with attr="+attrParts[0]);
a = (Statistic)resourceInstance.getStatistic(attrParts[0]);
if(a == null){
try{
a = (Statistic)resourceInstance.getClass().
getMethod("get"+str).
invoke(resourceInstance);
}
catch(Exception e){
logger.log(Level.INFO,e.getLocalizedMessage());
}
}
//note: do not change this to an "else{ }" block
if(a != null){
try{
retval = a.getClass().getMethod("get"+attrParts[1]).invoke(a);
}
catch(Exception e){
logger.log(Level.INFO,e.getLocalizedMessage());
logger.log(Level.FINE,e.getStackTrace().toString());
}
}
return retval;
|
public javax.management.AttributeList | getAttributes(java.lang.String[] str)Implementation of DynamicMBean interface's method. Loops through the
passed in String[] and calls getAttribute(str) for each element.
introspect();
AttributeList list = new AttributeList();
try{
for(int i=0; i<str.length;i++){
list.add(i, new Attribute(str[i],getAttribute(str[i])));
}
}
catch(Exception e){
logger.log(Level.INFO,e.getMessage()+"\n"+e.getCause().toString());
}
return list;
|
public javax.management.MBeanInfo | getMBeanInfo()Implementation of DynamicMBean interface's method. Returns the MBeanInfo
object that was generated during introspection of the underlying Stats
resource.
introspect();
return mbeanInfo;
|
final javax.management.MBeanInfo | introspect()introspects the underlying Stats resource and generates an MBeanInfo object
and populates attributes internally for later use culled from the
Statistic objects returned by the Stats object.
// !!! 'mbeanInfo' must be 'volatile' !!!
// this is thread-safe, not the double-null-check idiom so long as
// 'mbeanInfo' is 'volatile'
if ( mbeanInfo != null ) {
return mbeanInfo;
}
synchronized( this ) {
if ( mbeanInfo == null ) {
ManagedResourceIntrospector mri = new ManagedResourceIntrospector(this);
mbeanInfo = mri.introspect(this.resourceInstance);
setUpAttributeSet();
}
}
return mbeanInfo;
|
public java.lang.Object | invoke(java.lang.String str, java.lang.Object[] obj, java.lang.String[] str2)
introspect();
Object a =null;
Class[] c = new Class[]{};
for(int i=0; i<str2.length;i++){
c[i] = str2[i].getClass();
}
try{
a = (Object) resourceInstance.getClass().getMethod(str, c).invoke(resourceInstance, obj);
}
catch(Exception e){
logger.log(Level.INFO,e.getLocalizedMessage());
logger.log(Level.FINE,e.getStackTrace().toString());
}
return a;
|
private boolean | isValidAttribute(java.lang.String str)checks if the passed in string is a recognized attribute
if(attributeSet.contains(str))
return true;
return false;
|
public java.lang.String[] | listAttributes()Returns String[] of attribute names.
String[] array = new String[attributeSet.size()];
attributeSet.toArray(array);
return array;
|
public void | setAttribute(javax.management.Attribute attribute)Implementation of DynamicMBean interface's method - NO-OP.
|
public javax.management.AttributeList | setAttributes(javax.management.AttributeList attributeList)Implementation of DynamicMBean interface's method. Sets a list of attributes.
Iterates through the list and calls setAttribute() for each element.
return new AttributeList();
|
private void | setUpAttributeSet()sets up the internal data structure to hold attributes derived from
Statistic objects returned by the Stats object.
MBeanAttributeInfo[] attrInfo = mbeanInfo.getAttributes();
String attr =null;
for(int i=0;i<attrInfo.length;i++){
attr = attrInfo[i].getName();
attributeSet.add(attr);
}
|