Represent each statistic as the property of a JavaBeansTM specification getter method of your listener class. Methods in the listener class for processing events can then access the property through the getter method. For more information, see Subscribing to Events From Event Provider Classes.
To enable AMX to expose the statistic to client applications, annotate the declaration of the getter method with the org.glassfish.gmbal.ManagedAttribute annotation. Set the id element of the @ManagedAttribute annotation to the property name all in lowercase.
The data type of the property that represents a statistic must be a class that provides methods for computing the statistic from event data.
The org.glassfish.external.statistics.impl package provides the following classes to gather and compute statistics data:
Provides standard measurements of the lowest and highest values that an attribute has held and the current value of the attribute.
Provides standard measurements of the upper and lower limits of the value of an attribute.
Aggregates the attributes of RangeStatisticImpl and BoundaryStatisticImpl and provides standard measurements of a range that has fixed limits.
Provides standard count measurements.
Provides standard measurements of the lowest and highest values that an attribute has held and the current value of the attribute.
Provides performance data.
Provides a string equivalent of a counter statistic.
Provides standard timing measurements.
This example shows the code for representing the txcount statistic in the TxListener class.
... import org.glassfish.external.statistics.CountStatistic; import org.glassfish.external.statistics.impl.CountStatisticImpl; ... import org.glassfish.gmbal.ManagedAttribute; import org.glassfish.gmbal.ManagedObject; ... @ManagedObject public class TxListener { private CountStatisticImpl txCount = new CountStatisticImpl("TxCount", "count", "Number of completed transactions"); ... @ManagedAttribute(id="txcount") public CountStatistic getTxCount(){ return txCount; } }