From 074d20d7b64a988f43f15c2e8ac24b7298fe3e51 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 29 Apr 2009 17:41:46 -0700 Subject: [PATCH] switch from Dynamic to Standard MBean --- .../org/hyperic/sigar/jmx/SigarRegistry.java | 42 +++++-------------- .../hyperic/sigar/jmx/SigarRegistryMBean.java | 23 ++++++++++ 2 files changed, 33 insertions(+), 32 deletions(-) create mode 100644 bindings/java/src/org/hyperic/sigar/jmx/SigarRegistryMBean.java diff --git a/bindings/java/src/org/hyperic/sigar/jmx/SigarRegistry.java b/bindings/java/src/org/hyperic/sigar/jmx/SigarRegistry.java index e93927d9..156aec0c 100644 --- a/bindings/java/src/org/hyperic/sigar/jmx/SigarRegistry.java +++ b/bindings/java/src/org/hyperic/sigar/jmx/SigarRegistry.java @@ -20,8 +20,6 @@ package org.hyperic.sigar.jmx; import java.util.ArrayList; -import javax.management.AttributeNotFoundException; -import javax.management.MBeanInfo; import javax.management.MBeanRegistration; import javax.management.MBeanServer; import javax.management.ObjectInstance; @@ -58,34 +56,22 @@ import org.hyperic.sigar.SigarProxy; * @author Bjoern Martin * @since 1.5 */ -public class SigarRegistry extends AbstractMBean implements MBeanRegistration { +public class SigarRegistry implements MBeanRegistration, SigarRegistryMBean { + public static final String MBEAN_DOMAIN = SigarInvokerJMX.DOMAIN_NAME; + public static final String MBEAN_ATTR_TYPE = SigarInvokerJMX.PROP_TYPE; private static final String MBEAN_TYPE = "SigarRegistry"; - private static final MBeanInfo MBEAN_INFO; - - static { - MBEAN_INFO = new MBeanInfo( - SigarRegistry.class.getName(), - "Sigar MBean registry. Provides a central point for creation " - + "and destruction of Sigar MBeans. Any Sigar MBean created via " - + "this instance will automatically be cleaned up when this " - + "instance is deregistered from the MBean server.", - null /*new MBeanAttributeInfo[0] */, - null /*new MBeanConstructorInfo[0]*/, - null /*new MBeanOperationInfo[0] */, - null /*new MBeanNotificationInfo[0]*/); - } - + private SigarProxy sigar; private final String objectName; private final ArrayList managedBeans; private MBeanServer mbeanServer; public SigarRegistry(SigarProxy sigar) { - super(sigar); - this.objectName = MBEAN_DOMAIN + ":" + MBEAN_ATTR_TYPE - + "=" + MBEAN_TYPE; + this.sigar = sigar; + this.objectName = + MBEAN_DOMAIN + ":" + MBEAN_ATTR_TYPE + "=" + MBEAN_TYPE; this.managedBeans = new ArrayList(); } @@ -93,14 +79,6 @@ public class SigarRegistry extends AbstractMBean implements MBeanRegistration { return this.objectName; } - public Object getAttribute(String attr) throws AttributeNotFoundException { - throw new AttributeNotFoundException(attr); - } - - public MBeanInfo getMBeanInfo() { - return MBEAN_INFO; - } - private void registerMBean(AbstractMBean mbean) { try { ObjectName name = @@ -142,7 +120,7 @@ public class SigarRegistry extends AbstractMBean implements MBeanRegistration { try { info = sigar.getCpuInfoList(); } catch (SigarException e) { - throw unexpectedError("CpuInfoList", e); + info = new CpuInfo[0]; //XXX log } for (int i=0; i