Provides for implementations of various Stats interfaces. These Stats interfaces are based on those defined by JSR 77. Besides this, implementations of various Statistic interfaces are also provided here. A new Statistic is introduced named StringStatistic .

When we analyze the Statistic interfaces that are defined by the J2EE Management Standard, it is evident that they are view-only data structures providing the accessors for various statistical data, e.g. CountStatistic. Every instance of CountStatistic is allowed to have only a getCount method (in addition to other meta data accessors), that returns a long. This limits the usability of these Statistic interfaces by the actual components that gather the data, because new instances of these interfaces have to be constructed as and when a query or measurement of that statistic is made. On the other hand, it is much more flexible to have mutators within implementations of these Statistic interfaces. But then, there is a possibility that the client who receives instances of these interfaces inadvertantly changes a particular statistic.

To solve this problem, this package makes the following provision:

It defines Statistic classes that have a State. A component that gathers data has to do the following:

- Implement the specific Stats interface. e.g. EJBCacheStats. This interface has a method which returns number of beans in cache as an instance of BoundedRangeStatistic.
- Initialize an instance of MutableBoundedRangeStatistic with an initial state. This interface exposes all the necessary methods that are required to reflect the change in state.
- Since MutableBoundedRangeStatistic provides a method that returns an unmodifiable view of itself, calls the MutableBoundedRangeStatistic.unmodifiableView() which returns BoundedRangeStatistic. This returned value can safely be sent to the caller to which everything is transparent.

Note that these Mutable* interfaces/classes are not exposed to clients. Clients will only receive instances of Statistics that are part of the J2EE Management Standard.

## Package Specification

Following Stats interfaces are part of this package. All of these extend the javax.management.j2ee.statistics.Stats interface.

- EJBCacheStats
- EJBMethodStats
- EJBPoolStats
- OrbConnectionManagerStats
- OrbThreadPoolStats
- SunOneJVMStats

Following new Statistic interfaces are defined by this package. They extend the javax.management.j2ee.statistics.Statististic interface.

- StringStatistic - A String equivalent of CountStatistic.
- MutableStatistic - A Statistic that has some mutators. It is expected to be handled with care.
- MutableCountStatistic - A CountStatistic/BoundedRangeStatistic that is mutable.
- MutableTimeStatistic - A TimeStatistic that is mutable.

Following are the implementations of various Statistic interfaces in javax.management.j2ee.statistics package.

Interface | Immutable Implementation (read-only -- for clients) | Mutable Implementation (read-write -- for core components)
CountStatistic | CountStatisticImpl | MutableCountStatisticImpl It implements MutableCountStatistic.
BoundedRangeStatistic | BoundedRangeStatisticImpl | MutableBoundedRangeStatisticImpl It implements MutableCountStatistic.
TimeStatistic | TimeStatisticImpl | MutableTimeStatisticImpl It implements MutableTimeStatistic.

Following is a helper implementation done in this package: GenericStatsImpl.

This class is designed to facilitate the general implementation of {@link Stats} interface and all the classes that implement this interface can leverage this class. The main idea is that this class implements:

- getStatistic(String)
- getStatistics()
- getStatisticNames()

in a reflective manner. Thus, e.g. a specific implementation of EJBPoolStats like EJBPoolStatsImpl can make use of this class to implement above methods in a generic manner.

## Related Documentation

{@link javax.management.j2ee.statistics}
{@link java.util.Collections#unmodifiableMap}
{@link java.util.Collections#unmodifiableSet}

@since S1AS8.0