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


Christian Gruber :: Google, Inc. :: Java Core Libraries :: Dependency Injection
email: [email protected] :::: 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