I should have included my code in my previous post

My module:
@Override
    protected void configure() {
        MapBinder<String, DelegateFactory> mapBinder =
            MapBinder.newMapBinder(binder(), String.class,
                    DelegateFactory.class);
        // Implementation that is responsible for fetching the three tiered
        // client type.
        mapBinder.addBinding("CLIENT_TYPE") // Constructor key attribute
                .toProvider(FactoryProvider.newFactory(
                        DelegateFactory.class,
                        Delegate.class));
        // Implementation that is responsible for fetching the credit
product
        // type.
        mapBinder.addBinding("CP_TYPE")
                .toProvider(FactoryProvider.newFactory(
                        DelegateFactory.class,
                        Delegate.class));
        // Implementation that is responsible for fetching the report type.
        mapBinder.addBinding("REPORT_TYPE")
                .toProvider(FactoryProvider.newFactory(
                        DelegateFactory.class,
                        Delegate.class));
    }

Constructor

@Inject
public Delegate(@Assisted String key) {
    this.key = key;
}

@Inject
 public void setFactory(Map<String, DelegateFactory> factory) {
        this.factory = factory;
        this.delegate = factory.get("CLIENT_TYPE").create("CLIENT_TYPE");
 }

Invocation

Injector injector = Guice.createInjector(new DelegateModule());
injector.injectMembers(this);


On Wed, Nov 4, 2009 at 12:09 AM, Karthik Krishnan
<[email protected]>wrote:

> I am not sure how to reproduce the lock contention. I used this code sample
> as a reference http://pastie.org/453944 to build my own map binder. Would
> this work?
>
>
> On Tue, Nov 3, 2009 at 6:59 PM, Dhanji R. Prasanna <[email protected]>wrote:
>
>> I wouldn't worry about this unless you are *actually* seeing the lock
>> contention problem I describe.
>>
>> Furthermore, if you are mainly using assisted inject for long lived
>> objects you will be fine. =)
>>
>> Dhanji.
>>
>>
>> On Wed, Nov 4, 2009 at 1:56 PM, [email protected] <[email protected]>wrote:
>>
>>>
>>> We're working on this. For now, use the old form of assisted inject
>>> with the "@AssistedInject" annotation rather than the "@Inject"
>>> annotation.
>>>
>>> On Nov 3, 1:38 pm, Karthik Krishnan <[email protected]> wrote:
>>> > Hi All,
>>> >
>>> > I am using AssistedInject to inject Strings with variable values into
>>> > an object. I am using MapBinder to map the implementation to the type
>>> > of instance. We are able to get an instance of the class with the
>>> > injected string value. On an off chance, I looked at issue 435 that
>>> > mentions lock contentionhttp://
>>> code.google.com/p/google-guice/issues/detail?id=435
>>> > with assisted inject.
>>> >
>>> > We would not want the issue cropping up in our application. Is there a
>>> > work around or an emergency patch we should incorporate in our
>>> > application.
>>>
>>>
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" 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-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to