The same multi binder is given, yes. If I recall correctly, the multi
binder itself has no scope, but the bindings within do. I'd need to
look it up. That said, if you bind several multi binders to the same
key… you're not creating a new one (it's a mis-naming of the
newMultibinder() method). You get a new multi binder if a multi binder
doesn't already exist for that key. I any other case, you contribute
bindings to the already-existing multi binder.
Christian.
On 13 Jun 2013, at 12:10,
elect...@gmail.com wrote:
> I have to admit I'm not 100% about what is the *scope* of a
> Multibinder...
>
> My idea if that by using "final" on my main module's configure()
> method, I
> can make sure it is not overriden :
> -------------------
> public class MainModule extends AbstractModule
> {
> @Override
> *final* protected void configure()
> {
> overridableConfigure();
> manageMultibindedBindings();
> }
>
> protected void overridableConfigure()
> {
> // - standards bindings + third-party modules bindings
> // - can be overriden
> }
>
> *final *protected void manageMultibindedBindings()
> {
> // add more bindings using the Multibinder's elements.
> }
> }
> -------------------
> Then, I'm sure all the elements are binded in the Multibinder when
> manageMultibindedBindings() is called, right?
>
> But if another module is binded *at the same level* than MainModule,
> would
> the same Multibinder will shared? What exactly is the scope of a
> Multibinder? (I guess should so some tests by myself to validate
> that!)
>
> Thanks for the help!
>
>
>
> On Thursday, June 13, 2013 2:09:03 PM UTC-4, Christian Gruber wrote:
>>
>> One problem of obtaining this information is that module/binding
>> resolution order is a brittle thing to rely on, and you have no
>> guarantee that all or any particular bindings would be resolved by
>> the
>> time you hit your configure() method.
>>
>> Now it sounds like you don't need all the bindings, and we could in
>> theory expose a way to get at the current set of bindings in a multi
>> binder, but I am concerned to know how you would use this in
>> practice…
>> how would it be useful if you couldn't know you had the necessary
>> bindings in place before reading from them? What would you do if
>> later
>> modules added more bindings?
>>
>> c.
>>
>>> an email to
google-guice...@googlegroups.com <javascript:>.
>>> To post to this group, send email to
>>>
google...@googlegroups.com<javascript:>.
>> email:
cgr...@google.com <javascript:> :::: mobile:
+1 (646) 807-9839