static void addGetterIfAvaliable(Object obj,
String getter,
NamedList info) {
// This is a 1.6 functon, so lets do a little magic to *try* to make it work
try {
String n = Character.toUpperCase( getter.charAt(0) ) + getter.substring( 1 );
Method m = obj.getClass().getMethod( "get" + n );
Object v = m.invoke( obj, (Object[])null );
if( v != null ) {
info.add( getter, v );
}
}
catch( Exception ex ) {} // don't worry, this only works for 1.6
}
Try to run a getter function. This is usefull because java 1.6 has a few extra
usefull functions on the OperatingSystemMXBean
If you are running a sun jvm, there are nice functions in:
UnixOperatingSystemMXBean and com.sun.management.OperatingSystemMXBean
it is package protected so it can be tested... |