use of javax.management.StandardMBean in project sonarqube by SonarSource.
the class Jmx method register.
/**
* Register a MBean to JMX server
*/
public static void register(String name, Object instance) {
try {
Class<Object> mbeanInterface = guessMBeanInterface(instance);
ManagementFactory.getPlatformMBeanServer().registerMBean(new StandardMBean(instance, mbeanInterface), new ObjectName(name));
} catch (MalformedObjectNameException | NotCompliantMBeanException | InstanceAlreadyExistsException | MBeanRegistrationException e) {
throw new IllegalStateException("Can not register MBean [" + name + "]", e);
}
}
use of javax.management.StandardMBean in project scheduling by ow2-proactive.
the class RMJMXHelper method registerMBeans.
/**
* {@inheritDoc}
*/
@Override
public void registerMBeans(final MBeanServer mbs) {
// Register all mbeans into the server
try {
final RuntimeDataMBean anonymMBean = new RuntimeDataMBeanImpl(RMMonitoringImpl.rmStatistics);
// Uniquely identify the MBean and register it to the MBeanServer
final ObjectName name = new ObjectName(RMJMXBeans.RUNTIMEDATA_MBEAN_NAME);
mbs.registerMBean(anonymMBean, name);
String dataBaseName = PAResourceManagerProperties.getAbsolutePath(PAResourceManagerProperties.RM_RRD_DATABASE_NAME.getValueAsString());
FileUtils.forceMkdir(new File(dataBaseName).getParentFile());
setDataStore(new RRDDataStore((StandardMBean) anonymMBean, dataBaseName, PAResourceManagerProperties.RM_RRD_STEP.getValueAsInt(), Logger.getLogger(RMJMXHelper.class)));
} catch (Exception e) {
LOGGER.error("Unable to register the ResourceManagerRuntimeMBean", e);
}
// Register the MyAccount MBean into the MBean server
try {
final MyAccountMBeanImpl myAccountMBean = new MyAccountMBeanImpl(this.accountsManager);
final ObjectName name = new ObjectName(RMJMXBeans.MYACCOUNT_MBEAN_NAME);
mbs.registerMBean(myAccountMBean, name);
} catch (Exception e) {
LOGGER.error("Unable to register the MyAccountMBean", e);
}
// Register the ViewAccount MBean into the MBean server
try {
final AllAccountsMBeanImpl viewAccountMBean = new AllAccountsMBeanImpl(this.accountsManager);
final ObjectName name = new ObjectName(RMJMXBeans.ALLACCOUNTS_MBEAN_NAME);
mbs.registerMBean(viewAccountMBean, name);
} catch (Exception e) {
LOGGER.error("Unable to register the AllAccountsMBean", e);
}
// Register the Management MBean into the MBean server
try {
final ManagementMBeanImpl managementMBean = new ManagementMBeanImpl(this.accountsManager);
final ObjectName name = new ObjectName(RMJMXBeans.MANAGEMENT_MBEAN_NAME);
mbs.registerMBean(managementMBean, name);
} catch (Exception e) {
LOGGER.error("Unable to register the ManagementMBean", e);
}
}
use of javax.management.StandardMBean in project spring-framework by spring-projects.
the class JmxUtilsTests method testIsMBeanWithStandardMBeanInherited.
@Test
public void testIsMBeanWithStandardMBeanInherited() throws Exception {
StandardMBean mbean = new StandardMBeanImpl();
assertTrue("Standard MBean not detected correctly", JmxUtils.isMBean(mbean.getClass()));
}
use of javax.management.StandardMBean in project spring-framework by spring-projects.
the class JmxUtilsTests method testIsMBeanWithStandardMBeanWrapper.
@Test
public void testIsMBeanWithStandardMBeanWrapper() throws Exception {
StandardMBean mbean = new StandardMBean(new JmxTestBean(), IJmxTestBean.class);
assertTrue("Standard MBean not detected correctly", JmxUtils.isMBean(mbean.getClass()));
}
use of javax.management.StandardMBean in project archaius by Netflix.
the class ConfigJMXManager method registerConfigMbean.
public static ConfigMBean registerConfigMbean(AbstractConfiguration config) {
StandardMBean mbean = null;
ConfigMBean bean = null;
try {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
bean = new BaseConfigMBean(config);
mbean = new StandardMBean(bean, ConfigMBean.class);
mbs.registerMBean(mbean, getJMXObjectName(config, bean));
} catch (NotCompliantMBeanException e) {
throw new RuntimeException("NotCompliantMBeanException", e);
} catch (InstanceAlreadyExistsException e) {
throw new RuntimeException("InstanceAlreadyExistsException", e);
} catch (MBeanRegistrationException e) {
throw new RuntimeException("MBeanRegistrationException", e);
} catch (Exception e) {
throw new RuntimeException("registerConfigMbeanException", e);
}
return bean;
}
Aggregations