-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multibindings #37
Comments
From kevinb9n on February 27, 2007 00:22:04 (No comment was entered for this change.) Summary: Multibindings |
From limpbizkit on March 02, 2007 09:23:37 A rough sketch of possible syntax: bind(Number.class).asDefaultCollectionElement().to(new Integer(5)); ... public - It might be better without the asDefaultCollectionElement() method, and to require
- Just as we forbid injecting Guice classes, why not forbid anything with a classname |
From kevinb9n on March 08, 2007 14:13:47 (to the last part: I was thinking about exactly that a couple days ago! It seems a Labels: 1.1 |
From smiddlek on March 17, 2007 12:09:51 I'm glad to see this is being addressed in 1.1! I think it would be important to bind(Number.class).asCollectionElement().annotatedWith(...) I'd also love to see support for Maps. :) I believe Kevin saw some hacked together |
From crazyboblee on March 17, 2007 12:24:41 A slightly shorter syntax: bind(Foo.class).inCollection().annotatedWith(...).to(FooImpl.class).in(Scopes.SINGLETON); It's interesting to note that each element can have a different scope. |
From crazyboblee on March 17, 2007 12:35:07 A more descriptive syntax: bindElementInCollectionOf(Foo.class).annotatedWith(...).to(FooImpl.class); |
From crazyboblee on March 17, 2007 12:44:08 Yet another: multibind(Foo.class).annotatedWith(...)... |
From lwerner on March 17, 2007 17:54:07 Since it looks like I was one of the original requestors of this... :-) One thing I've discovered while using my current workaround for this missing feature I'm not 100% sure that this is Guice's problem. It's almost as easy for clients to One idea I'm playing with is to have my collection notice whether the items you put All of this is pretty speculative, but I figured I should get it written down |
From kevinb9n on March 18, 2007 00:08:04 For the modules which are contributing individual bindings to the collection, I kind bind(Handler.class).XXX().to(MyBlueHandler.class); because this is only one new method we have to add, not a new method like multibind() Only problem is I cannot think of what name for XXX() doesn't suck awfully. This still leaves undefined what kind of Collection we should instantiate as well as Rather than deciding that in the framework I think we can just have the module that bind(new TypeLiteral<Set<Handler>>() {}) If we see this, we will then support " In fact, the user can even apply a scope to the collection binding; we'll simply have Now what's missing is that guice really should inject only an unmodifiable view of |
From dhanji on March 18, 2007 16:09:02 I like this idea very much but we need to have a way to specify the collection bind(Number.class).collectAs(List.class).to(new Long(5)); ..should have very different meanings (I may want to contribute 5, 5, 5 as a list for |
From kevinb9n on April 16, 2007 10:04:00 Dhanji, I believe my proposal above does address this. |
From bslesinsky on May 17, 2007 11:19:01 Another possible syntax: allowMultiple(Foo.class); |
From bslesinsky on July 25, 2007 09:57:32 This functionality seems like a static version of the whiteboard pattern from OSGi; |
From robbie.vanbrabant on August 08, 2007 02:50:48 http://www.osgi.org/documents/osgi_technology/whiteboard.pdf |
From robbie.vanbrabant on August 08, 2007 03:36:40 Another idea: Perhaps not the most elegant solution, but straightforward and backwards compatible. |
From robbie.vanbrabant on August 13, 2007 04:43:58 Same thing, but with issue 123 syntax: |
From dhanji on September 01, 2007 06:18:57 Note that "for" is a reserved word in Java =( Also it should be possible to specify a key for the collection implementation. |
From robbie.vanbrabant on October 11, 2007 07:55:35 Another idea; use a special Module, much like AbstractModule: install(new AbstractMultibindModule() { By using that module, Guice could tag all bindings that happen in that module for |
From logan.johnson on December 12, 2007 06:27:39 I know this conversation is old, and I hope I haven't missed the boat entirely. The class SomeEventSource implements EventSource { class SomeModule extends AbstractModule { Controlling order is up to the user. You could define a priority scheme in your |
From bslesinsky on December 12, 2007 08:38:54 Interesting. I think we could just use regular binder syntax; the only thing needed I could see people still wanting arrays, lists, or sets of values to be injected, |
From logan.johnson on December 12, 2007 08:48:20 If we had "adder injections" (good name), then injecting collections/iterables would class SortedPlugins implements Provider<List>, PluginRegistry { public List<Plugin> get() { ... } The biggest difference between my suggestion and the ones I've seen before is that |
From logan.johnson on March 31, 2008 20:25:17 Related discussion on the user mailing list: http://groups.google.com/group/google-guice/t/640b245f49a2b802 |
From limpbizkit on April 29, 2008 11:07:39 I blogged about my API proposal, which doesn't require changes to core Guice: http://publicobject.com/2008/04/guice-multibinder-api-proposal.html |
From earwin on April 29, 2008 13:27:41 I used an alternative, no Guice alterations either, shorter syntax than your version, |
From limpbizkit on May 01, 2008 03:12:16 Initial draft implemented. Announcement here: http://groups.google.com/group/google-guice/browse_frm/thread/d601e981f5a90e4 Still unsupported: I'm going to close this issue and see if that's sufficient. If anyone wants more features, open new bugs! I Status: Fixed |
From kevinb9n on February 27, 2007 03:21:14
It would be good if certain keys could be multivalued; where multiple
modules could append one or more bindings each, and these could all be
injected as a Collection<Foo> or something. This would be useful for some
things Laura is doing, and for replacing excalibur, and for
AdWordsPaymentOptions, and . . .
I'm going ahead and calling this priority "high" for now.
Original issue: http://code.google.com/p/google-guice/issues/detail?id=37
The text was updated successfully, but these errors were encountered: