Skip to content

Feature Request: Expose List of Provider<T> #427

@LeDominik

Description

@LeDominik

Caveat: I have no idea how much work this is 😄

I'd like to propose to provide some facility to get all the (currently private Provider<T>) providers that a component has via some sort of API / Set-Injection / whatever is idiomatic... The background is that while I ❤️ how Dagger 2 operates, it's a bit hard to bridge into dynamic frameworks.

Case in point: Jersey 2 (in Dropwizard) with Dagger 2:

  • Dropwizard doesn't prescribe any DI, so Dagger 2 is just perfect, however there's JAX-RS (implemented by Jersey) from which you typically want to reach out into your own Dagger powered (business) logic
  • Jersey 2 uses HK2: Now that leads JAX-RS resource-classes being treated by HK2/Jersey (which knows about awesome (dynamic runtime) things like HTTP-Headers with @Context) but of course not about Dagger-managed stuff
  • If combined nicely then one sticks to constructor injection via Dagger and the rest (which is then basically just boilerplate and no logic) of the JAX-RS resource is owned by HK2 -- see e.g. @HunterSherms comment at Dependency Injection frameworks dropwizard/dropwizard#1626 (comment)
  • However it would be pretty easy to give HK2 knowledge about Dagger 2 Providers via e.g. Jersey's AbstractBinder as demonstrated in this Gist

I think that #413 is really about a similar thing (I'm not a Guice guy). My Spring is not 100% up-to-date but programmatically getting this into the ApplicationContext isn't difficult either.

But we'd need programmatic access to the Provider's somehow -- and they are all in (or reachable through) the Component implementations (at least as far as I can observe in my generated code). And I honestly believe this should not require another separately versioned generator like Bullet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions