Kevin Pollet wrote:
The OSGi Blueprint Specification deals with a similar problem using something called 'the Grace Period' (OSGi 4.2 Enterprise spec section 121.3.7). Essentially this is a period of time during which the system gives all the components a chance to initialize and injection to happen. If after the grace period has expired there are still missing dependencies, the deployment will fail. This might also work for CDI.
Re Ales, suggestion of taking the CDI deployment away when a mandatory dependency goes away. This is what OSGi Declarative Services (DS) do as well.
Essentially one of the main differences between Blueprint and DS is how they react to changes in dependencies. Blueprint keeps the dependent component alive in the hope that a replacement service will be made available at some point where DS takes the dependent away and potentially instantiates a new one when a replacement service arrives. So the Blueprint model has a dampening effect on the liveness of OSGi services whereas DS follows it directly.
I think both have their uses and ideally this kind of behaviour would be configurable for OSGi/CDI - but I guess it would be fine to pick either of the two as an initial model...