Are you asking if you can somehow have an automatic injection of
Supplier<Foo> the way we special-case injecting Provider<Foo>?
At present, that isn't an automatic thing, the way it is with Provider.
Provider is a core part of dependency injection infrastructure for
Guice, and one is always implicitly there for every binding. That is
not true of Supplier.
However, what you might be looking for is, effectively Assisted Inject,
which is similar, but it won't inherently implement Supplier. You can
make a provides binding that simply binds a Supplier<Foo> to an
anonymous inner implementation assisted-inject factory.. But that's
somewhat manual.
If you are willing to wait a bit, Google is going to release
AutoFactory, which is a very similar system to Assisted-Inject in
concept, but using code-generation. It has a feature slated that would
allow someone to specify an interface like Supplier and it will generate
a factory method (with no parameters) on the generated factory for that
Supplier's only method. I suspect this might meet your needs.
Christian.
> --
> You received this message because you are subscribed to the Google
> Groups "google-guice" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
google-guice...@googlegroups.com.
> To post to this group, send email to
google...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/google-guice.
> For more options, visit
https://groups.google.com/groups/opt_out.
Christian Gruber :: Google, Inc. :: Java Core Libraries :: Dependency
Injection
email:
cgr...@google.com :::: mobile:
+1 (646) 807-9839