The implementation of the immediate context. This should NOT be added automatically, and hence is not annotated with {@link org.jvnet.hk2.annotations.Service}
This implementation uses a lot of facilities of hk2, so lets explain each one.
The thing that makes Immediate services immediate is that they are started as soon as they are noticed. This is done by implementing the DynamicConfigurationListener, as it will get notified when a configuration has changed. However, since the creation of user services can take an arbitrarily long time it is better to do that work on a separate thread, which is why we implement Runnable. The run method is the method that will pull from the queue of work and instantiate (and destroy) the immediate services.
However, there is also a desire to be highly efficient. This means we should not be creating this thread if there is no work for the thread to do. For this to work we need to know which configuration changes have added or removed an Immediate service. To know this we have implemented the Validation service and Validator. The validation service records the thread id of a configuration operation that is adding or removing services. This thread id goes into a map. But we have to be sure that the map does not grow without bound. To do this we clear the map both when the configuration service has succeeded (in the DynamicConfigurationListener) and when the configuration service has failed (in the ErrorService). This is why we have implemented the ErrorService.
@author jwells