Greg meant http://github.com/google/auto

It's available in source, but not released to maven.

Christian.

On 21 Oct 2013, at 9:25, Gregory Kick wrote:

To clarify about @AutoFactory:
1) It is available now.  It hasn't been "released" due to a buggy
interaction with Dagger, but you can find it in 3p/java_src/auto right now. 2) Supplier is a ways off just due to the generics, but you should be able
to hack around it with something like the following:

interface FooSupplier extends Supplier<Foo>

That's obviously not idea, but inferring proper generics for things like
Supplier is a bit tricky.


On Mon, Oct 21, 2013 at 11:19 AM, Christian Gruber <[email protected]>wrote:

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.

On 21 Oct 2013, at 5:32, Romain Gilles wrote:

Hi all,
I would like to know how can I had the same type of feature of automatic bindings of Providers (guice or javax-inject) for Suppliers (guave or java
8)?

I would like to do something like that:

public class MyModule extends AbstractModule {
@Override
protected void configure() {
  bind(MyInterface.class).to(**MyImpl.class);
}
}

And then be able to indefferently inject it in the following use cases
without extra work:

class MyClient {
private final Provider<MyInterface> myInterfaceProvider;
private final Supplier<MyInterface> myInterfaceSupplier;
@Inject
MyClient(Provider<MyInterface> myInterfaceProvider,
Supplier<MyInterface> myInterfaceSupplier) {
  ...
}
...
}

Thanks,

Romain.

--
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+unsubscribe@**googlegroups.com<google-guice%[email protected]>
.
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/**group/google-guice<http://groups.google.com/group/google-guice>
.
For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
.



Christian Gruber :: Google, Inc. :: Java Core Libraries :: Dependency
Injection
email: [email protected] :::: mobile: +1 (646) 807-9839




--
Greg Kick
Java Core Libraries Team


Christian Gruber :: Google, Inc. :: Java Core Libraries :: Dependency Injection
email: [email protected] :::: mobile: +1 (646) 807-9839

--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to