Comment #1 on issue 645 by [email protected]: Scoping issue when using
CheckedProvider
http://code.google.com/p/google-guice/issues/detail?id=645
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.
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice-dev?hl=en.