Open GoogleCodeExporter opened 9 years ago
Hi,
Found the problem. The issue can be closed.
It lies in the injection part of the CheckedProvider.
public class GrapeImplProvider implements FruitProvider<Grape> {
@Override
public Grape get() throws GrapeException {
return new GrapeImpl();
}
}
Originally, I inject the implementation class:
-----------------------------------------------
private final GrapeImplProvider grapeProvider;
@Inject
public GBox(GrapeImplProvider grapeProvider) {
this.grapeProvider = grapeProvider;
}
-------------------------------------------------
The correct way: should inject the interface:
-------------------------------------------------
private final FruitProvider<Grape> grapeProvider;
@Inject
public GBox(FruitProvider<Grape> grapeProvider) {
this.grapeProvider = grapeProvider;
}
If injecting interface, the scope requirement works well.
Original comment by laola...@gmail.com
on 29 Jul 2011 at 9:21
I recommend using the @CheckedProvides annotation on a method in the Module,
which will make writing checked providers a lot simpler (no need for the
GrapeImplProvider class).
Original comment by sberlin
on 29 Jul 2011 at 2:16
Thanks for the help. Changed to CheckedProvides
Original comment by laola...@gmail.com
on 29 Jul 2011 at 3:10
Original issue reported on code.google.com by
laola...@gmail.com
on 29 Jul 2011 at 3:17Attachments: