Tracks services deployed in a given {@link AxisConfiguration}. The tracker is configured with references to three objects:
- An {@link AxisConfiguration} to watch.
- An {@link AxisServiceFilter} restricting the services to track.
- An {@link AxisServiceTrackerListener} receiving tracking events.
An instance of this class maintains an up-to-date list of services satisfying all of the following criteria:
- The service is deployed in the given {@link AxisConfiguration}.
- The service is started, i.e. {@link AxisService#isActive()} returns true.
- The service matches the criteria specified by the given {@link AxisServiceFilter} instance.
Whenever a service appears on the list, the tracker will call {@link AxisServiceTrackerListener#serviceAdded(AxisService)}. When a service disappears, it will call {@link AxisServiceTrackerListener#serviceRemoved(AxisService)}.
When the tracker is created, it is initially in the stopped state. In this state no events will be sent to the listener. It can be started using {@link #start()} and stopped againusing {@link #stop()}. The tracker list is defined to be empty when the tracker is in the stopped state. This implies that a call to {@link #start()} will generate{@link AxisServiceTrackerListener#serviceAdded(AxisService)} events for all services that meetthe above criteria at that point in time. In the same way, {@link #stop()} will generate{@link AxisServiceTrackerListener#serviceRemoved(AxisService)} events for the current entriesin the list.
As a corollary the tracker guarantees that during a complete lifecycle (start-stop), there will be exactly one {@link AxisServiceTrackerListener#serviceRemoved(AxisService)} eventfor every {@link AxisServiceTrackerListener#serviceAdded(AxisService)} event and vice-versa.This property is important when the tracker is used to allocate resources for a dynamic set of services.
Limitations
The tracker is not able to detect property changes on services. E.g. if a service initially matches the filter criteria, but later changes so that it doesn't match the criteria any more, the tracker will not be able to detect this and the service will not be removed from the tracker list.