thx!
it works
On Tuesday, 22 May 2012 11:58:39 UTC+2, Thomas Broyer wrote:
>
>
>
> On Tuesday, May 22, 2012 11:41:14 AM UTC+2, tanteanni wrote:
>>
>> thx thomas for fast reply,
>>
>> the problem is indeed that two instances are created one "
>> PlaceHistoryMapperWithFactory<TokenizerFactory> " instance and one
>> instances where constructors inject "AppPlaceHistoryMapper" (this one has
>> null factory).
>> But how to fix this? Your suggested provides-Code shouldn't change
>> anything, should it?
>>
>
> It depends.
> If you have code that depends on AppPlaceHistoryMapper, then change the
> return type of the provider-method to that.
> And if some code depends on
> PlaceHistoryMapperWithFactory<TokenizerFactory>, and/or PlaceHistoryMapper,
> then bind those types to AppPlaceHistoryMapper (see below).
>
>
>> So I tried your 2nd suggestion:
>> plus this in module:
>>
>>> bind(new
>>>> TypeLiteral<PlaceHistoryMapperWithFactory<TokenizerFactory>>() {
>>>
>>> }).to(AppPlaceHistoryMapper.class).in(Singleton.class);
>>>
>>> *It is working! *
>> But with this every user of AppPlaceHistoryMapper get a different
>> instance - (i guess this is not really a problem) - is it possible to
>> get/bind a singleton.
>> Is it possible to bind AppPlaceHistoryMapper
>> and PlaceHistoryMapperWithFactory<TokenizerFactory> to the same instance
>> of generated AppPlaceHistoryMapper Impl?
>>
>
> Yes:
> bind(new TypeLiteral<PlaceHistoryMapperWithFactory<TokenizerFactory>>() {
> }).to(AppPlaceHistoryMapper.class);
> bind(AppPlaceHistoryMapper.class).in(Singleton.class); // either that, or
> a @Provides @Singleton method.
>
> i.e.: when you need a PlaceHistoryMapperWithFactory<TokenizerFactory>,
> then use an AppPlaceHistoryMapper; and when you need an
> AppPlaceHistoryMapper, then bind it as a singleton.
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/EuAeL10nl84J.
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.