Methods Summary |
---|
private javax.management.MBeanOperationInfo[] | addMoreMBeanOperations(javax.management.MBeanOperationInfo[] operInfo)Add any operations defined in the MBean other than ones pertaining
directly to Stats or Statistic operations. example: listAtrributes()
MBeanOperationInfo oper = new MBeanOperationInfo("listAttributes",//Name
"Method listAttributes",//Description
null,//MBeanParameterInfo
String.class.getName(), //Return Type in String
MBeanOperationInfo.INFO // Action representing read-only operation
);
MBeanOperationInfo[] opers = new MBeanOperationInfo[operInfo.length+1];
opers = operInfo;
opers[opers.length-1] = oper;
return operInfo;
|
javax.management.MBeanOperationInfo | createOperationInfo(java.lang.reflect.Method oper)returns an OperationInfo Object given a Method object
return new MBeanOperationInfo(oper.getName(),//Name
"Method "+oper.getName(),//Description
getParameterInfo(oper.getParameterTypes()),//MBeanParameterInfo
oper.getReturnType().getName(), //Return Type in String
MBeanOperationInfo.INFO // Action representing read-only operation
);
|
java.lang.Object[] | deriveUnderlyingAttributes(Stats stats)From the passed in Stats object, this method determines the underlying
Statistic type and derives from it, attributes that return primitive values.
String[] attrs = stats.getStatisticNames();
for(int i=0; i< attrs.length; i++){
introspectEachStatistic((stats.getStatistic(attrs[i])).getClass(), attrs[i]);
}
String[] a = new String[attributes.size()];
return attributes.toArray(a);
|
javax.management.MBeanAttributeInfo[] | getAttributeInfo(Stats stats)Creates array of MBeanAttributeInfo objects for attributes
standing for Statistic objects derived from the managed resource's
getStatisticNames() method
MBeanAttributeInfo[] attrInfo=null;
if(stats != null){
Object[] attrs = deriveUnderlyingAttributes(stats);
attrInfo = new MBeanAttributeInfo[attrs.length];
for(int i= 0; i < attrs.length; i++){
attrInfo[i] = new MBeanAttributeInfo((String)attrs[i],Statistic.class.getName(),
"Attribute"+attrs[i], READABLE, !WRITABLE, !ISGETTER);
}
}
return attrInfo;
|
javax.management.MBeanOperationInfo[] | getOperationInfo(Stats stats)creates array of MBeanOperationInfo objects to determine operations
to be exposed. Excludes the underlying managed resource's methods
pertaining to
Method[] opers = stats.getClass().getMethods();
MBeanOperationInfo[] operInfo = new MBeanOperationInfo[opers.length];
for(int i= 0; i < opers.length; i++){
if(!isAttrGetterOrSetter(opers[i])){
operInfo[i]= createOperationInfo(opers[i]);
}
}
operInfo = addMoreMBeanOperations(operInfo);
return operInfo;
|
javax.management.MBeanParameterInfo[] | getParameterInfo(java.lang.Class[] paramTypes)creates an array of MBeanParameterInfo objects that represent
parameters and their signatures for a given operation
MBeanParameterInfo[] params=null;
if(paramTypes != null){
params = new MBeanParameterInfo[paramTypes.length];
for(int i=0; i<paramTypes.length;i++){
try{
params[i] = new MBeanParameterInfo("param"+i,
paramTypes[i].getName(),
paramTypes[i].getName());
}
catch(java.lang.IllegalArgumentException e){
logger.log(Level.INFO, e.toString());
}
}
}
return params;
|
javax.management.MBeanInfo | introspect(Stats stats)
return new MBeanInfo(
mbean.getClass().getName(),//className
"Managed Object for "+stats.getClass().getName()+ " managed resource",//description
getAttributeInfo(stats), //AttributeInfo
null, //constructorInfo
getOperationInfo(stats), //operationInfo
null //notifications
);
|
void | introspectEachStatistic(java.lang.Class statistic, java.lang.String statName)
Set a = new HashSet(Arrays.asList(statistic.getMethods()));
Iterator it = a.iterator();
while(it.hasNext()){
String s = (String)((Method) it.next()).getName();
if(s.startsWith("get")&& !s.equals("getClass")){
s = s.replaceFirst("get","");
attributes.add(AttributeStringHelper.joinAttributes(statName,s));
}
}
|
boolean | isAttrGetterOrSetter(java.lang.reflect.Method operation)returns true for an operation if it meets the JMX equivalent spec
of distinguishing an get(set)Attribute() or get(set)Attributes() from a
non getter/setter operation.
if(operation.getName().startsWith("get")
|| operation.getName().startsWith("set")){
return true;
}
return false;
|