Thank You very much for your always insightful comments.
On Jan 9, 3:12 am, Thomas Broyer <[email protected]> wrote:
> On Sunday, January 9, 2011 2:28:07 AM UTC+1, zixzigma wrote:
> The whole idea of Provider is that Guice/GIN implement them!
> You only have to "ask" for it and GIN will provide it, e.g.
> @Inject
> MyObject(SomeObject thisWillBeAnInitializedInstance, Provider<SomeObject>
> thisWillBeAProvider) {
> ...
>
> }
>
> If you don't need to pass arguments, then just inject Provider<MyActivity>
> instead of Activity and you have a "factory" of the activity type (that will
> defer instantiation) instead of an early-instantiated Activity instance.
>
"then just inject Provider<MyActivity> instead of Activity and you
have a "factory" of the activity type"
I want to emphasize the "activity TYPE" in your comment:
so in the code below, we have MyActivity1, MyActivity2 ..
MyActivity10, and they are of type MyActivity, right ?
interface MyActivity extends Activity {}
class MyActivity1 implements MyActivity {//..}
class MyActivity2 implements MyActivity {//...}
...
class MyActivity 10 implements MyActivity {//,,,}
now considering this,
> @Inject
> MyObject(SomeObject thisWillBeAnInitializedInstance, Provider<SomeObject>
> thisWillBeAProvider) {
and that the point of Provider being GIN provides them, and there
would be no need for us to implement it,
does it mean that I can just use the code below ?
@Inject
MyObject(SomeObject thisWillBeAnInitializedInstance,
Provider<MyActivity1>
thisWillBeAProvider) {
and it works out of the box ?
or I have to at least define the following Provider ?
public class MyActivityProvider implements Provider<A extends
MyActivity>{
private final A activity;
// ### do we have to use @Inject here ? ###
@Inject
public MyActivityProvider(A actvt){
this.activity = actvt;
}
A get() {
return activity;
}
}
and what is the correct way to configure it ?
bind(MyActivity.class).toProvider(MyActivityProvider.class).
and although I have bound only MyActivity.class to the provider,
it also provides MyActivity1, MyActivity2 and "? extends MyActivity" ?
Thank You
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" 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-web-toolkit?hl=en.