Example usage for java.lang.management ManagementFactory getPlatformMBeanServer

List of usage examples for java.lang.management ManagementFactory getPlatformMBeanServer

Introduction

In this page you can find the example usage for java.lang.management ManagementFactory getPlatformMBeanServer.

Prototype

public static synchronized MBeanServer getPlatformMBeanServer() 

Source Link

Document

Returns the platform javax.management.MBeanServer MBeanServer .

Usage

From source file:org.trpr.platform.batch.impl.spring.jmx.JMXJobUtils.java

/**
 * Constructor for this class//from  ww  w.jav a2s. c o m
 */
public JMXJobUtils() {
    this.mbeanServer = ManagementFactory.getPlatformMBeanServer();
    Set<ObjectInstance> mbeans = mbeanServer.queryMBeans(null, null);
    for (ObjectInstance mbean : mbeans) {
        if (mbean.getObjectName().toString().indexOf(JOB_ADMINISTRATOR) > -1) {
            this.jobAdministratorInstance = mbean;
            break;
        }
    }
}

From source file:org.sakaiproject.status.StatusServlet.java

public void init() throws ServletException {
    mbs = ManagementFactory.getPlatformMBeanServer();
}

From source file:org.rifidi.edge.configuration.JMXServiceImpl.java

/**
 * Constructor./*from w ww  .  j  a v a 2 s .c  o m*/
 */
public JMXServiceImpl() {
    // register the MBeans server
    mbs = ManagementFactory.getPlatformMBeanServer();
    persistentServicesToObjectNames = new HashMap<Configuration, ObjectName>();
    logger.debug("JMXServiceImpl created.");
}

From source file:org.codice.ddf.spatial.admin.module.service.Geocoding.java

private void registerMbean() {
    ObjectName objectName = null;
    MBeanServer mBeanServer = null;
    try {/*from   w  w w.j  a  va2s.com*/
        objectName = new ObjectName(Geocoding.class.getName() + ":service=geocoding");
        mBeanServer = ManagementFactory.getPlatformMBeanServer();
    } catch (MalformedObjectNameException e) {
        LOGGER.error("Unable to create Geocoding Configuration MBean.", e);
    }
    if (mBeanServer != null) {
        try {
            try {
                mBeanServer.registerMBean(this, objectName);
                LOGGER.info("Registered Geocoding Configuration MBean under object name: {}",
                        objectName.toString());
            } catch (InstanceAlreadyExistsException e) {
                // Try to remove and re-register
                mBeanServer.unregisterMBean(objectName);
                mBeanServer.registerMBean(this, objectName);
                LOGGER.info("Re-registered Geocoding Configuration MBean");
            }
        } catch (Exception e) {
            LOGGER.error("Could not register MBean [{}].", objectName.toString(), e);
        }
    }
}

From source file:org.atomserver.utils.jmx.MBeanServerLocator.java

public MBeanServer locateMBeanServer() {
    MBeanServer mbeanServer = null;
    if (containerType != null && containerType.equals("Resin")) {
        try {//w  w  w  .j  a  v  a2s.  c o  m
            mbeanServer = (MBeanServer) lookup();
        } catch (Exception ee) {
            log.error("Exception (" + ee.getMessage() + ") while attempting to lookup"
                    + " the Resin JNDI MBeanServer (" + RESIN_JNDI_NAME + ")", ee);
        }
    }
    // Just fallback to the Java 5 Platform MBeanServer, which is always present
    if (mbeanServer == null) {
        mbeanServer = ManagementFactory.getPlatformMBeanServer();
    }
    return mbeanServer;
}

From source file:org.ff4j.jmx.FF4JMBeanTest.java

private void openJmxConnection() throws Exception {
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    // Make a connector server...
    JMXServiceURL jmxUrl = new JMXServiceURL("service:jmx:rmi://");
    jmxConnectionServer = JMXConnectorServerFactory.newJMXConnectorServer(jmxUrl, null, mbs);
    jmxConnectionServer.start();/*  w  ww .ja  va  2 s  .co  m*/
    JMXServiceURL jmxAddress = jmxConnectionServer.getAddress();

    // Now make a connector client using the server's address
    jmxConnectionFactory = JMXConnectorFactory.connect(jmxAddress);
    mbServConn = jmxConnectionFactory.getMBeanServerConnection();
}

From source file:org.apache.hadoop.hive.ql.debug.Utils.java

/**
 * Dumps process heap./*from   w  ww.  j ava  2 s  . com*/
 * @param fileName File name to use.
 * @param live Whether to only dump live objects.
 */
public static void dumpHeap(String fileName, boolean live) {
    if (hotspotMBean == null) {
        try {
            MBeanServer server = ManagementFactory.getPlatformMBeanServer();
            hotspotMBean = ManagementFactory.newPlatformMXBeanProxy(server, HOTSPOT_BEAN_NAME,
                    HOTSPOT_MXBEAN_CLASS);
        } catch (IOException e) {
            LOG.error(e.getMessage());
            throw new RuntimeException(e);
        }
    }
    if (DUMP_HEAP_METHOD != null) {
        try {
            DUMP_HEAP_METHOD.invoke(hotspotMBean, new Object[] { fileName, Boolean.valueOf(live) });
        } catch (RuntimeException re) {
            LOG.error(re.getMessage());
            throw re;
        } catch (Exception exp) {
            LOG.error(exp.getMessage());
            throw new RuntimeException(exp);
        }
    } else {
        LOG.error("Cannot find method dumpHeap() in com.sun.management.HotSpotDiagnosticMXBean.");
    }
}

From source file:com.tomcat.monitor.jmx.obj.bean.MServer.java

/**
 * Zugriff zu dem lokalen Platform Server oder erzeuge neuen.
 *//*from  ww  w.  j  a  va  2 s .c  o  m*/
protected MBeanServer getMBeanServer() {
    MBeanServer server;
    server = ManagementFactory.getPlatformMBeanServer();
    if (server == null)
        server = MBeanServerFactory.createMBeanServer();
    return (server);
}

From source file:com.ngdata.hbaseindexer.supervisor.IndexerRegistry.java

private void registerMBean() {
    try {//from  www  .  j a  v a  2  s. c om
        jmxObjectName = new ObjectName("HBaseIndexer:name=Indexer");
        ManagementFactory.getPlatformMBeanServer().registerMBean(this, jmxObjectName);
    } catch (Exception e) {
        log.warn("Error registering mbean '" + jmxObjectName, e);
    }
}

From source file:org.jboss.fuse.rhaccess.servlet.SupportServlet.java

public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);
    jmxUtil = new JMXUtil(ManagementFactory.getPlatformMBeanServer());
}