Hello,

You can inject maps via constructors like this :
- add an annotation to the map parameter in the constructor :

public A(@com.google.inject.name.Named("name") final Map<String, 
> ItemService> itemServices) {
> ...
> }
>

"name" can be changed to any string.

- add a binding in the module class :

> bind(new TypeLiteral<Map<String, ItemService>>() 
> {}).annotatedWith(com.google.inject.name.Names.named("name")).toProvider(MyMapProvider.class);
>

There I used a provider to get the map, but you can also bind directly to 
an instance.

Hope it helps you,
Regards,

Mathieu

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-guice/-/Y0I7SPSo-9cJ.
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