Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate JSR-330 compliance of backstack.lookupService() #223

Closed
Zhuinden opened this issue May 5, 2020 · 1 comment
Closed

Investigate JSR-330 compliance of backstack.lookupService() #223

Zhuinden opened this issue May 5, 2020 · 1 comment

Comments

@Zhuinden
Copy link
Owner

Zhuinden commented May 5, 2020

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 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)

  • is this worth the effort?

Edge case:

  • would I conflict with Dagger?

The idea is cool, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant