Skip to content

Commit 21b3662

Browse files
authored
Update airframe-jmx doc to describe name attribute of JMX annotation (#2506)
1 parent c6a3dc8 commit 21b3662

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

airframe-jmx/src/test/scala/wvlet/airframe/jmx/JMXRegistryTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ case class FieldMBean(@JMX a: Int, @JMX b: String)
4141
class NestedMBean {
4242
@JMX(description = "nested stat")
4343
def stat: Stat = {
44-
new Stat(Random.nextInt(10), "nested JMX bean")
44+
Stat(Random.nextInt(10), "nested JMX bean")
4545
}
4646
}
4747

docs/airframe-jmx.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ To report nested parameters, add `@JMX` to parameters as well:
5151
class NestedMBean {
5252
@JMX(description = "nested stat")
5353
def stat: Stat = {
54-
new Stat(Random.nextInt(10), "nested JMX bean")
54+
Stat(Random.nextInt(10), "nested JMX bean")
5555
}
5656
}
5757

@@ -60,6 +60,19 @@ case class Stat(@JMX count: Int, @JMX state: String)
6060
In this example, `stat.count` and `stat.state` will be reported.
6161

6262

63+
## Specify parameter names explicitly
64+
65+
Parameter names are automatically generated but also can be specified explicitly.
66+
```scala
67+
@JMX(description = "A example MBean object")
68+
class NamedMBean {
69+
@JMX(name = "memory.free", description = "free memory size")
70+
def freeMemory: Long = {
71+
Runtime.getRuntime.freeMemory()
72+
}
73+
}
74+
```
75+
6376
## Launching JMX Registry
6477

6578
You can launch JMXRegistry (e.g., on port 7199) by setting these JVM parameters:

0 commit comments

Comments
 (0)