Last active
August 29, 2015 14:19
-
-
Save rangalo/ee934ee3b0c2b906c8a9 to your computer and use it in GitHub Desktop.
Registering jmx
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
@PostConstruct | |
public void registerInJMX() { | |
try { | |
objectName = new ObjectName("Scope1:type=" + this.getClass().getName()); | |
platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); | |
platformMBeanServer.registerMBean(sc.getBusinessObject(HealthMonitor.class), objectName); | |
} catch (IllegalStateException | InstanceAlreadyExistsException | MBeanRegistrationException | MalformedObjectNameException | NotCompliantMBeanException e) { | |
throw new IllegalStateException("Problem during registration of Monitoring into JMX:" + e); | |
} | |
} | |
@PreDestroy | |
public void unregisterFromJMX() { | |
try { | |
platformMBeanServer.unregisterMBean(this.objectName); | |
} catch (InstanceNotFoundException | MBeanRegistrationException e) { | |
throw new IllegalStateException("Problem during unregistration of Monitoring into JMX:" + e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment