Sorry, the example should be with "SimpleInstanceProvider", not with
"Provider"

On Thu, Feb 3, 2011 at 6:05 PM, Gal Dolber <gal.dol...@gmail.com> wrote:

> If I inject a provider on 2 different classes I expect them to return a
> different instance, but each provider must return the same one.
>
> class A {
>     @Inject
>     public Provider<C> p; // p.get() returns always the same instance
> }
>
> class B {
>     @Inject
>     public Provider<C> p; // p.get() returns always the same instance
> }
>
> But A.p.get() is not the same instance than B.p.get().
>
> On Thu, Feb 3, 2011 at 5:54 PM, zixzigma <zixzi...@gmail.com> wrote:
>
>> I am using the same technique as Ryan suggested.
>>
>> Your comment : "non-singleton class that return always the same instance"
>> isn't a "non-singleton class that always return the same instance" in fact
>> the very definition of Singleton ? : )
>>
>> I have read that there is a difference between Singleton Design Pattern
>> and Singleton Scope.
>> Singleton Scope = always return the same instance, is this wrong ?
>>
>> your code:
>> the foo==null check in redundant,
>> because provider.get() does that for you.
>>
>> and if you want to always return the same instance,
>> then bind it in Singleton scope.
>>
>> Foo assertFoo() {
>>     if (foo == null) {
>>         foo = provider.get();
>>     }
>>     return foo;
>> }
>>
>> You have made me confused now,
>> I like to see some thoughts on this as well.
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Google Web Toolkit" group.
>> To post to this group, send email to google-web-toolkit@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-web-toolkit?hl=en.
>>
>
>
>
> --
> Guit: Elegant, beautiful, modular and *production ready* gwt applications.
>
> http://code.google.com/p/guit/
>
>
>
>
>


-- 
Guit: Elegant, beautiful, modular and *production ready* gwt applications.

http://code.google.com/p/guit/

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to