I'm not sure if this is a bug, or is a constraint of the specification, but what I am trying to do is this...
I have an MBean with an "Amount" field of type java.math.BigDecimal. java.math.BigDecimal extends java.lang.Number.
I then want to use a GaugeMonitor to watch high/low thresholds for this attribute.
On GaugeMonitor, there is a method setThresholds( Number high, Number, low ), so presumably it is OK to use BigDecimal for these threshold values.
When I run my code, I get this warning in the trace output:
"Monitor GaugeMonitor on MyServer:type=AmountManager attribute Amount attribute, threshold, offset and modules types don't match"
This happens because in GaugeMonitor the "determineType" method checks "targetClass" explicitly for INT, LONG, BYTE, SHORT, FLOAT and DOUBLE and returns "false" if the targetClass is not one of those types.
i.e., the determineType method does not check for BigDecimal (presumably BigInteger should work as well).
Similar code exists in CounterMonitor where BigInteger should (?) work.
So, is this a bug? Or is the use of BigDecimal and BigInteger not allowed?
Logged In: YES
user_id=234750
Neither BigInteger nor BigDecimal are listed in the types for
monitors in the JMX 1.2 specification. However, i'm not
convinced that this wasn't just an oversight in the spec,
where they maybe really meant all subclasses of
java.lang.Number. I'll see how Sun's Reference
Implementation reacts to BigDecimals/Integers - unless you
have already. Certainly if the RI supports them, MX4J should.
Logged In: YES
user_id=234750
I set up a TestCase against Sun's reference implementation,
and it indicates an error condition when I try to monitor a
BigDecimal attribute. The error handling puzzles me a little
bit, because the GaugeMonitor thread keeps polling the
monitored attribute. However, the first notification received
by the listener yields a notification of
type "jmx.monitor.error.type" with the message
"The observed attribute type must be an integer type or a
floating-point type"
That listener receives no more notifications after the first
one. I take this to mean that the RI does not recognize
BigDecimal or BigInteger as monitorable types. Until they do,
I expect that we won't. For now, I am marking this bug as
invalid.