Counters are beans that can be used by an application to keep track of numeric values, including increase and total. Counter is the class that supports and manages counters, it consists of three elements: Increase, Total, and increaseTimes.
▪ Increase
It stores the last value provided to the counter.
▪ Total
It stores the total amount. Its value can be updated either by the application using setTotal() method or by the counter itself (every time the increase value is changed). You can initialize Total through an XML initial attribute at instantiation time, or dynamically at runtime.
▪ increaseTimes
It records the number of increments done.
All the three elements have a name, a value, and two properties, one for the maximum allowed amount and one for the minimum allowed amount. All these properties’ value can not be negative. The value must be between the minimum and the maximum, otherwise, an exception will be thrown. Its value can be persistent with the transaction data through the Journal service. Journal service and the relational database together ensure data integrity and provide the use of browsing utilities to view the counter values. In case of the system failure, the last committed values can be easily recovered by the application through the Electronic Journal application programming interface, which loads the selected counters with their last valid values.