Skip to content

Instantly share code, notes, and snippets.

@martin-cowie
Created April 21, 2017 13:45
Show Gist options
  • Save martin-cowie/bed620e20c2f3926df5257f4b0fe61fb to your computer and use it in GitHub Desktop.
Save martin-cowie/bed620e20c2f3926df5257f4b0fe61fb to your computer and use it in GitHub Desktop.
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
Diskspace mbean = new Diskspace(root);
try {
ObjectName objectName = new ObjectName( "com.acme.diskspace:name=foo" );
mbs.registerMBean( mbean, objectName );
} catch ( Exception ex ) {
throw new Error( String.format( "Cannot registry MBean at "%s"", mbean.getObjectName() ), ex );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment