The example below shows the definition of an interface for an MBean that returns some statistics in a tabular format and supports the reset of its statistics. It is not compulsory to declare the reset method. Declare it only if the MBean can or is allowed to reset its statistics.When an administrative request is made to reset all JMX statistics the JMX infrastructure inspects the MBean definition and if it finds the reset operation it invokes it.
import javax.management.openmbean.OpenDataException; import javax.management.openmbean.TabularData; public interface MyStatsMBean { /** * MBean attribute holding the statistics. */ TabularData getStats() throws OpenDataException; /** * This method is invoked by the JMX infrastructure when * a request is made to reset the JMX statistics. */ void reset(); }