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
    }

    private 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. 
>
> On 13 Jun 2013, at 10:52, [email protected] <javascript:> wrote: 
>
> > I want to allow third-party modules to be able to bind some custom 
> > ISomeInterface elements (well,* classes* of ISomeInterface in fact : 
> > "Class<? extends ISomeInterface >"). I use Multibinder for that and it 
> > works great. 
> > 
> > But I would like to be able, at the very end of my main module's 
> > configure() method, to process the elements that have been binded in 
> > the 
> > Multibinder to add further bindings for those. More specifically, I'd 
> > like 
> > to be able to automatically bind an AssistedFactory for each of the 
> > elements that have been multibinded. 
> > 
> > Is there a way to retrieve the currently binded elements of a 
> > Multibinder, 
> > without the injector been created yet (while still being in 
> > "configure()")? 
> > 
> > Something like : 
> > 
> > ------------------- 
> > Multibinder<Class<? extends ISomeInterface>> myMultibinder = 
> > Multibinder.newSetBinder(binder(), new TypeLiteral<Class<? extends 
> > ISomeInterface >>(){}); 
> > Set<Class<? extends ISomeInterface>> currentBindings = 
> > myMultibinder.getBindings(); 
> > ------------------- 
> > 
> > Then I would use the "currentBindings" to bind assisted factories. 
> > 
> > Any idea? 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "google-guice" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to [email protected] <javascript:>. 
> > To post to this group, send email to 
> > [email protected]<javascript:>. 
>
> > Visit this group at http://groups.google.com/group/google-guice. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>
>
> Christian Gruber :: Google, Inc. :: Java Core Libraries :: Dependency 
> Injection 
> email: [email protected] <javascript:> :::: mobile: +1 (646) 807-9839 
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to