Example usage for javax.management StandardMBean StandardMBean

List of usage examples for javax.management StandardMBean StandardMBean

Introduction

In this page you can find the example usage for javax.management StandardMBean StandardMBean.

Prototype

protected StandardMBean(Class<?> mbeanInterface, boolean isMXBean) 

Source Link

Document

Make a DynamicMBean out of this, using the specified mbeanInterface class, and choosing whether the resulting MBean is an MXBean.

Usage

From source file:hivemall.mix.metrics.MetricsRegistry.java

public static void registerMBeans(@Nonnull MixServerMetrics metrics, int port) {
    final StandardMBean mbean;
    try {//from   w w w  .j  a v  a2s .c  om
        mbean = new StandardMBean(metrics, MixServerMetricsMBean.class);
    } catch (NotCompliantMBeanException e) {
        logger.error("Unexpected as GridNodeMetricsMBean: " + metrics.getClass().getName(), e);
        return;
    }
    final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    final ObjectName name = makeMBeanName("hivemall", MixServerMetricsMBean.class.getSimpleName(),
            "port=" + port);
    try {
        server.registerMBean(mbean, name);
        logger.info("Registered MBean: " + name);
    } catch (Exception e) {
        logger.error("Failed registering mbean: " + name, e);
    }
}

From source file:com.netflix.config.jmx.ConfigJMXManager.java

public static ConfigMBean registerConfigMbean(AbstractConfiguration config) {
    StandardMBean mbean = null;/*w  w w . ja  v  a  2s  .co  m*/
    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;
}

From source file:Main.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public static ObjectName registerMBean(Object mBean, Class mBeanInterface, String type, String name) {
    try {/*from w w  w .j ava2 s.c o m*/
        StandardMBean standardMBean = new StandardMBean(mBean, mBeanInterface);
        return registerMBean(standardMBean, type, name, null);
    } catch (NotCompliantMBeanException e) {
        LOGGER.error("noncompliant mbean", e);
    }

    return null;
}

From source file:org.apache.hadoop.yarn.server.resourcemanager.RMNMInfo.java

/**
 * Constructor for RMNMInfo registers the bean with JMX.
 * //from w w  w  .j a  v  a2  s. c o m
 * @param rmc resource manager's context object
 * @param sched resource manager's scheduler object
 */
public RMNMInfo(RMContext rmc, ResourceScheduler sched) {
    this.rmContext = rmc;
    this.scheduler = sched;

    StandardMBean bean;
    try {
        bean = new StandardMBean(this, RMNMInfoBeans.class);
        MBeans.register("ResourceManager", "RMNMInfo", bean);
    } catch (NotCompliantMBeanException e) {
        LOG.warn("Error registering RMNMInfo MBean", e);
    }
    LOG.info("Registered RMNMInfo MBean");
}

From source file:org.red5.server.jmx.JMXAgent.java

public static boolean registerMBean(Object instance, String className, Class interfaceClass) {
    boolean status = false;
    try {/*from   w  w  w. j  ava 2s . c o m*/
        String cName = className;
        if (cName.indexOf('.') != -1) {
            cName = cName.substring(cName.lastIndexOf('.')).replaceFirst("[\\.]", "");
        }
        log.debug("Register name: {}", cName);
        mbs.registerMBean(new StandardMBean(instance, interfaceClass),
                new ObjectName(JMXFactory.getDefaultDomain() + ":type=" + cName));
        status = true;
    } catch (InstanceAlreadyExistsException iaee) {
        log.debug("Already registered: {}", className);
    } catch (Exception e) {
        log.error("Could not register the {} MBean. {}", className, e);
    }
    return status;
}

From source file:gridool.metrics.GridNodeMetricsProvider.java

private static void registerMBeans(GridLocalNodeMetrics metrics) {
    final StandardMBean mbean;
    try {/*from  w  w  w .j  a va2s  . co m*/
        mbean = new StandardMBean(metrics, GridNodeMetricsMBean.class);
    } catch (NotCompliantMBeanException e) {
        LOG.error("Unexpected as GridNodeMetricsMBean: " + metrics.getClass().getName(), e);
        return;
    }
    final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    final ObjectName name = GridUtils.makeMBeanName("gridool", "GridService", "GridLocalNodeMetrics");
    try {
        server.registerMBean(mbean, name);
    } catch (Exception e) {
        LOG.error("Failed registering mbean: " + name, e);
    }
}

From source file:com.ricston.connectors.dataanalysis.DataAnalysisConnector.java

/**
 * Start the module by registering to the platform Mbean server, and starting the Map DB
 * /*from ww w  .  ja va2  s.c om*/
 * @throws MalformedObjectNameException
 * @throws NotCompliantMBeanException
 * @throws InstanceAlreadyExistsException
 * @throws MBeanRegistrationException
 * @throws IOException 
 */
@Start
public void startModule() throws MalformedObjectNameException, NotCompliantMBeanException,
        InstanceAlreadyExistsException, MBeanRegistrationException, IOException {
    application = muleContext.getConfiguration().getId();

    logger.info("**********************************");
    logger.info("*Starting Data Analysis Connector*");
    logger.info("**********************************");

    startMapDb();

    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    ObjectName id = new ObjectName(String.format(MBEAN_NAME, application));
    StandardMBean mbean = new StandardMBean(this, DataAnalysisMBean.class);
    server.registerMBean(mbean, id);

    logger.info("Registered mbean using name: " + String.format(MBEAN_NAME, application));
}

From source file:org.red5.server.jmx.JMXAgent.java

public static boolean registerMBean(Object instance, String className, Class interfaceClass, ObjectName name) {
    boolean status = false;
    try {/*ww w  . j av  a2s . c  o m*/
        String cName = className;
        if (cName.indexOf('.') != -1) {
            cName = cName.substring(cName.lastIndexOf('.')).replaceFirst("[\\.]", "");
        }
        log.debug("Register name: {}", cName);
        mbs.registerMBean(new StandardMBean(instance, interfaceClass), name);
        status = true;
    } catch (InstanceAlreadyExistsException iaee) {
        log.debug("Already registered: {}", className);
    } catch (Exception e) {
        log.error("Could not register the {} MBean. {}", className, e);
    }
    return status;
}

From source file:org.red5.server.jmx.JMXAgent.java

public static boolean registerMBean(Object instance, String className, Class interfaceClass, String name) {
    boolean status = false;
    try {/*ww w .j  a  v  a2 s.  com*/
        String cName = className;
        if (cName.indexOf('.') != -1) {
            cName = cName.substring(cName.lastIndexOf('.')).replaceFirst("[\\.]", "");
        }
        log.debug("Register name: {}", cName);
        mbs.registerMBean(new StandardMBean(instance, interfaceClass),
                new ObjectName(JMXFactory.getDefaultDomain() + ":type=" + cName + ",name=" + name));
        status = true;
    } catch (InstanceAlreadyExistsException iaee) {
        log.debug("Already registered: {}", className);
    } catch (Exception e) {
        log.error("Could not register the {} MBean. {}", className, e);
    }
    return status;
}

From source file:io.fabric8.core.jmx.FabricManager.java

public void registerMBeanServer(ShutdownTracker shutdownTracker, MBeanServer mbeanServer) {
    try {/* w  ww .j  ava2 s  .c  o m*/
        ObjectName name = getObjectName();
        if (!mbeanServer.isRegistered(name)) {
            StandardMBean mbean = new StandardMBean(this, FabricManagerMBean.class);
            mbeanServer.registerMBean(mbean, name);
        }
    } catch (Exception e) {
        LOG.warn("An error occured during mbean server registration: " + e, e);
    }
}