At least in GlassFish, it is most common use case is to do a .getService (or Injection) specifying a contract name (that is either an interface or an abstract class annotated with @Contract). The implementing (@Service) class is usually not known at runtime.
Its an interesting idea, but can’t replace the inhabitant generator in the general case.
On Dec 5, 2013, at 1:09 PM, cowwoc <cowwoc_at_bbs.darktech.org> wrote:
> I just had a thought: why do we need hk2-inhabitant-generator at all? When someone tries to inject a class and a binding is not found, couldn't HK2 automatically add a binding and retry the operation if the class is annotated with @Service? Meaning, what prevents you from adding the binding on-the-fly at runtime?