On 17 juil, 01:09, SD <[email protected]> wrote: > When using gin injection and ui binder, I am having some trouble > figuring out if I am getting multiple instances of my singleton > objects. > > A couple of questions: > If class A has a constructor that injects class B and also class C, > and class B has a constructor that injects class C, are there 2 > instances of class C that are created?
Yes, unless you tell GIN otherwise. > If there is an annotation on > class C @Singleton, where will a warning appear if there are 2 class C > objects. @Singleton tells GIN to instantiate a single C and inject this singleton instance everywhere needed, instead of instantiating a C object for each injection point. I don't understand why you're talking about a "warning". > Also, if class A is using ui binder and class A's xml file has > references to class B or C, then do new objects get instantiated or > does gin and ui binder find the objects that currently exist? GIN and UiBinder don't know of each other. If you want your instances injected by GIN, then you should provide them to UiBinder so it doesn't instantiate them by itself. This is generally done using @UiField(provided=true), and initializing the field (view GIN) *before* calling createAndBindUi. -- 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.
