As defined in the PicoContainer docs that no longer exist, "contextualized lookup IoC design" is the Type-0 variant of dependency injection containers, even if lately people call it a service locator.
However this also means that as Backstack in an activity is technically "global context", it is possible to use lookupService on @Inject annotated fields via reflection from outside! Then it stops being a service locator.
So the list to comply to JSR-330 is as follows:
@Inject support over fields
@Inject support over setters
@Inject support over constructor (can I really make that work...? I need to support Provider<T> for that first. Currently you must manually invoke the constructor and create an instance before registering it to the backstack at a given scope. It is only possible to constructor-inject something that is registered as a Provider<T> and not as an instance.)
Injection of Provider<T> (is there a sane API for that using lookupService(), or is that lookupFactory()? is this really worth it? Not exactly sure if this is worth it. Honestly it's probably not worth it.)
@Named@Inject (should be easy, service tags are already strings)
Question becomes:
what of inherited @Inject annotated fields?
is it enough to support field injection, but not constructor injection + Provider<T>? (did Avalon even support constructor injection + providers? is that even possible with Type-0 DI? it probably didn't, that's why they created PicoContainer in the first place)
https://web.archive.org/web/20110613022418/http://picocontainer.org/inversion-of-control.html
As defined in the PicoContainer docs that no longer exist, "contextualized lookup IoC design" is the Type-0 variant of dependency injection containers, even if lately people call it a service locator.
However this also means that as
Backstack
in an activity is technically "global context", it is possible to uselookupService
on@Inject
annotated fields via reflection from outside! Then it stops being a service locator.So the list to comply to JSR-330 is as follows:
@Inject
support over fields@Inject
support over setters@Inject
support over constructor (can I really make that work...? I need to supportProvider<T>
for that first. Currently you must manually invoke the constructor and create an instance before registering it to the backstack at a given scope. It is only possible to constructor-inject something that is registered as aProvider<T>
and not as an instance.)Injection of
Provider<T>
(is there a sane API for that usinglookupService()
, or is thatlookupFactory()
? is this really worth it? Not exactly sure if this is worth it. Honestly it's probably not worth it.)@Named
@Inject
(should be easy, service tags are already strings)Question becomes:
what of inherited
@Inject
annotated fields?is it enough to support
field injection
, but notconstructor injection
+Provider<T>
? (did Avalon even support constructor injection + providers? is that even possible with Type-0 DI? it probably didn't, that's why they created PicoContainer in the first place)is this worth the effort?
Edge case:
The idea is cool, though.