switch from Dynamic to Standard MBean
This commit is contained in:
parent
7157234182
commit
074d20d7b6
|
@ -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<info.length; i++) {
|
||||
|
@ -181,7 +159,7 @@ public class SigarRegistry extends AbstractMBean implements MBeanRegistration {
|
|||
registerMBean(mbean);
|
||||
}
|
||||
} catch (SigarException e) {
|
||||
throw unexpectedError("FileSystemList", e);
|
||||
//XXX log
|
||||
}
|
||||
|
||||
//NetInterface beans
|
||||
|
@ -203,7 +181,7 @@ public class SigarRegistry extends AbstractMBean implements MBeanRegistration {
|
|||
registerMBean(mbean);
|
||||
}
|
||||
} catch (SigarException e) {
|
||||
throw unexpectedError("NetInterfaceList", e);
|
||||
//XXX log
|
||||
}
|
||||
|
||||
//network info bean
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (C) [2004-2009], Hyperic, Inc.
|
||||
* This file is part of SIGAR.
|
||||
*
|
||||
* SIGAR is free software; you can redistribute it and/or modify
|
||||
* it under the terms version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation. This program is distributed
|
||||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
package org.hyperic.sigar.jmx;
|
||||
|
||||
public interface SigarRegistryMBean {
|
||||
|
||||
}
|
Loading…
Reference in New Issue