use SigarVersion bean

This commit is contained in:
Doug MacEachern 2009-04-29 10:53:07 -07:00
parent 96ca3970e1
commit 0a1a3de69f
1 changed files with 3 additions and 31 deletions

View File

@ -19,12 +19,10 @@
package org.hyperic.sigar.jmx; package org.hyperic.sigar.jmx;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import javax.management.AttributeNotFoundException; import javax.management.AttributeNotFoundException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanConstructorInfo; import javax.management.MBeanConstructorInfo;
import javax.management.MBeanInfo; import javax.management.MBeanInfo;
import javax.management.MBeanParameterInfo; import javax.management.MBeanParameterInfo;
@ -37,7 +35,6 @@ import org.hyperic.sigar.FileSystem;
import org.hyperic.sigar.NetInterfaceConfig; import org.hyperic.sigar.NetInterfaceConfig;
import org.hyperic.sigar.Sigar; import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException; import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.SigarLoader;
/** /**
* <p>Registry of all Sigar MBeans. Can be used as a convenient way to invoke * <p>Registry of all Sigar MBeans. Can be used as a convenient way to invoke
@ -87,7 +84,7 @@ public class SigarRegistry extends AbstractMBean {
+ "and destruction of Sigar MBeans. Any Sigar MBean created via " + "and destruction of Sigar MBeans. Any Sigar MBean created via "
+ "this instance will automatically be cleaned up when this " + "this instance will automatically be cleaned up when this "
+ "instance is deregistered from the MBean server.", + "instance is deregistered from the MBean server.",
getAttributeInfo(), null /*new MBeanAttributeInfo[0] */,
new MBeanConstructorInfo[] { MBEAN_CONSTR_DEFAULT }, new MBeanConstructorInfo[] { MBEAN_CONSTR_DEFAULT },
null /*new MBeanOperationInfo[0] */, null /*new MBeanOperationInfo[0] */,
null /*new MBeanNotificationInfo[0]*/); null /*new MBeanNotificationInfo[0]*/);
@ -97,33 +94,6 @@ public class SigarRegistry extends AbstractMBean {
private final ArrayList managedBeans; private final ArrayList managedBeans;
private static MBeanAttributeInfo[] getAttributeInfo() {
VERSION_ATTRS.put("JarVersion", Sigar.VERSION_STRING);
VERSION_ATTRS.put("NativeVersion", Sigar.NATIVE_VERSION_STRING);
VERSION_ATTRS.put("JarBuildDate", Sigar.BUILD_DATE);
VERSION_ATTRS.put("NativeBuildDate", Sigar.NATIVE_BUILD_DATE);
VERSION_ATTRS.put("JarSourceRevision", Sigar.SCM_REVISION);
VERSION_ATTRS.put("NativeSourceRevision", Sigar.NATIVE_SCM_REVISION);
VERSION_ATTRS.put("NativeLibraryName", SigarLoader.getNativeLibraryName());
MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[VERSION_ATTRS.size()];
int i=0;
for (Iterator it=VERSION_ATTRS.entrySet().iterator();
it.hasNext();)
{
Map.Entry entry = (Map.Entry)it.next();
String name = (String)entry.getKey();
attrs[i++] =
new MBeanAttributeInfo(name,
entry.getValue().getClass().getName(),
name,
true, // isReadable
false, // isWritable
false); // isIs
}
return attrs;
}
/** /**
* Creates a new instance of this class. Will create the Sigar instance this * Creates a new instance of this class. Will create the Sigar instance this
* class uses when constructing other MBeans. * class uses when constructing other MBeans.
@ -277,6 +247,8 @@ public class SigarRegistry extends AbstractMBean {
registerMBean(new SigarLoadAverage(sigarImpl)); registerMBean(new SigarLoadAverage(sigarImpl));
//global process stats //global process stats
registerMBean(new ReflectedMBean(sigarImpl, "ProcStat")); registerMBean(new ReflectedMBean(sigarImpl, "ProcStat"));
//sigar version
registerMBean(new ReflectedMBean(sigarImpl, "SigarVersion"));
} }
/** /**