On Saturday, January 8, 2011 9:23:22 PM UTC+1, zixzigma wrote:
>
>
> On Jan 8, 3:01 am, Thomas Broyer <[email protected]> wrote:
> > Using GIN, it means you'd @Inject Provider<?>s [.... ] for your
> activities into your ActivityManager (so that
> > an activity is instantiated each time you call the Provider's get()
> method),
>
> - do you mean injecting providers into "ActivityMappers" ? or
> "ActivityManagers" ?
>
ActivityMapper-s yes, sorry.
> - your comment on Provider vs Factories
> just to make sure if I understood your correctly,
> if we have a Provider and want to pass Activity specific parameters
> to it,
> this would not be possible with GIN Providers, right ?
> because GIN Providers have one get() methods, and not possible to pass
> parameters.
> that is why we have to use Factories instead of GIN Providers?
>
Yes. A Provider gives you an instance with all dependencies injected. A
factory allows you to further parameterize the instance (and if you use some
snapshot of GIN, you have access to AssistedInject so you don't have to code
your factories, just define their API through an interface)
- following on a related question I asked in another post,[1]
> lets say we are keeping a map of all of our application activities,
> which is @injected
> in a class(Registry) at application startup through a GIN Provider
> that puts all activity instances in that map;
> this approach would result in early instantiation of all activities.
> right ?
>
If you put activity instances, yes.
(remember, GIN generates Java code that's compiled by the GWT compiler –just
like any other generator–, that means this is code you could have written
yourself, so each time you get an instance from GIN, you can quickly imagine
which kind of code you would have written yourself to initialize it. As I
like to say: there's no magic!)
if we instead relied on ActivityProviders, and keeping a map of all of
> our ActivityProviders instead (rather than activity instances
> themselves),
> it appears we are deferring the early instantiation of Activities.
>
Yes.
> But injecting ActivityProviders will result in Activity Instantiation,
> for example in the code below,
> if we @Inject MyActivityProvider at startup in a class, MyActivity is
> alo instantiated right away, right ? (constructor injection)
>
The way you wrote it, yes (and it's therefore totally useless).
in cases where we have 150 Activities, for each of them an
> ActivityProvider, therefore 150 ActivityProviders, (somehow organized)
> and injecting these ActivityProviders upfront in a class(registry) at
> application startup, will it result in rightaway instantiation of all
> our Activities as well ?
>
Yes, of course.
// we are defining an ActivityProvider for each of our Activities
> public class MyActivityAProvider implements Provider<MyActivityA> {
>
What's the point in implementing Provider yourself?
--
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.