Hello.

When I used Multibinder and MapBinder at the same time, I encountered
a strange result.
I wrote the following code in order to add a FlickrPhotoSummarizer
object into Set and Map.

        protected void configure() {
                Multibinder<UriSummarizer> uriBinder =
Multibinder.newSetBinder(binder(), UriSummarizer.class);
                uriBinder.addBinding().to(FlickrPhotoSummarizer.class);


                MapBinder<String, UriSummarizer> uriMapBinder =
                    MapBinder.newMapBinder(binder(), String.class,
UriSummarizer.class);
        
uriMapBinder.addBinding("flickr").to(FlickrPhotoSummarizer.class);              
     //
A
        }

So, Set<UriSummarizer> was injected to the following class.

       public class ClientWithMultibinder implements Client {
            private Set<UriSummarizer> summarizers;

            @Inject
            public ClientWithMultibinder(Set<UriSummarizer> summarizers) {
                this.summarizers = summarizers;
            }

            ........
       }

I expected that summarizers shoud have only one FlickrPhotoSummarizer
object. But it had two.
I commented out "A" line on trial, and it had one.

I can't understand what happened.
I hope sombody helps me.

Thank you for your reading my awkward English.

-- 
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