1. Start Using Quickly
To use SimpleJMX you need to do the following steps. For more information, see section Using SimpleJMX.
- Download SimpleJMX from the SimpleJMX release page. See section Downloading Jar.
- Add
@JmxResource
annotation to the top of each class you want to publish via JMX. See section Naming Objects.
| @JmxResource(domainName = "your.domain", description = "Runtime counter")
public class RuntimeCounter {
|
- Add
@JmxAttributeField
annotation to each of the attribute fields that you want to expose via reflection over JMX.
See section Exposing Fields and Methods.
| @JmxAttributeField(description = "Start time in millis",
isWritable = true)
private long startTimeMillis;
|
If you want to annotate the get/set/is attribute methods instead then use the @JmxAttributeMethod
annotation on those
methods. See section @JmxAttributeMethod Annotation.
| @JmxAttributeMethod(description = "Run time in seconds or milliseconds")
public long getRunTime() {
|
- Add
@JmxOperation
annotation to each of operation methods that you want to make accessable over JMX.
See section @JmxOperation Annotation.
| @JmxOperation(description = "clear the cache")
public void clearCache() {
|
- Start your JMX server. See section Starting a JMX Server.
| // create a new JMX server listening on a port
JmxServer jmxServer = new JmxServer(8000);
jmxServer.start();
|
- Register the objects you want to publish via JMX. See section Register Objects.
| jmxServer.register(someObject);
jmxServer.register(someOtherObject);
|
For more extensive instructions, see section Using SimpleJMX.
This document was generated by Gray Watson on February 8, 2014 using texi2html 1.82.