users@hk2.java.net

Piecemeal ServiceLocator construction

From: buko <buko_at_chiubarobot.com>
Date: Tue, 24 Jun 2014 22:42:32 -0400

Trying to implement a system where ServiceLocator is built piece-meal.
During an initial bootstrap phase some core modules are added, then during
a configure phase more binders are added (using
ServiceLocatorUtilities.bind(serviceLocator, binder...), and finally during
an interactive phase yet more modules are bounded.

Was surprised to discover that hk2 doesn't really support this... it seems
when new configuration is added, ServiceLocator.reup() will invoke
ServiceLocator.reupInjectionResolvers(), which will actually instantiate
InjectionResolvers and put them in a map. Of course once injection
resolvers are created that can trigger the creation of all sorts of other
objects.

I'm wondering if this is really desirable behavior? Would it make sense to
instantiate injection resolvers lazily until the system is actually called
upon to resolve dependencies for a given injection point?

If so I'll toss a feature request into the backlog...