Created
May 19, 2020 04:25
-
-
Save cleantutorials/325e1d8bd4ed5e58fd256e8ea64d023a to your computer and use it in GitHub Desktop.
RegisterMyMBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cleantutorials.jconsole.jmx; | |
import java.lang.management.ManagementFactory; | |
import javax.management.InstanceAlreadyExistsException; | |
import javax.management.MBeanRegistrationException; | |
import javax.management.MBeanServer; | |
import javax.management.MalformedObjectNameException; | |
import javax.management.NotCompliantMBeanException; | |
import javax.management.ObjectName; | |
public class RegisterMyMBean { | |
public static void main(String[] args) throws MalformedObjectNameException, | |
InstanceAlreadyExistsException, MBeanRegistrationException, | |
NotCompliantMBeanException { | |
MBeanServer server = ManagementFactory.getPlatformMBeanServer(); // Get the MBean Server instance. | |
ObjectName name = new ObjectName("JMXTutorialMBean:type=JMXTutorial"); // Create a unique Object Name. | |
JMXTutorial tutorial = new JMXTutorial(); | |
server.registerMBean(tutorial, name); // Register the MBean with the MBean Server. | |
try { | |
Thread.sleep(360000); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment