fmgasparino / google-gin

Automatically exported from code.google.com/p/google-gin
Apache License 2.0
0 stars 0 forks source link

Support Guice Multibinding #111

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Fathom a way of doing Gin-friendly plugins
2. Come across issue #95
3. Refathom a way of doing Gin-friendly plugins
4. Discover Guice's Multibinder
5. Realize it's not in Gin.

 http://code.google.com/p/google-guice/wiki/Multibindings

Original issue reported on code.google.com by jatw...@linuxstuff.org on 6 Jul 2010 at 4:18

GoogleCodeExporter commented 9 years ago
You're certainly not the first one asking for this, someone should write it. ;)

Original comment by aragos on 8 Jul 2010 at 10:28

GoogleCodeExporter commented 9 years ago
I tried copying the code into Gin, replacing Binder with GinBinder, Module with 
GinModule, wrapping the appropriate adapters and exposing some needed methods, 
but I got stuck when I got with:

http://code.google.com/p/google-guice/source/browse/tags/2.0/extensions/multibin
dings/src/com/google/inject/multibindings/Multibinder.java#220

Original comment by jatw...@linuxstuff.org on 8 Jul 2010 at 3:10

GoogleCodeExporter commented 9 years ago
What's the best choice for GIN Multibinder API?

Mi two proposals are:

 1- To provide GIN static multibinder counterparts, like GinMultibinder.newSetBinder(), GinMapBinder.newMapBinder(), etc..

 2- To provide an special AbstractMultibindingModule, providing the Multibinder static methods as module instance methods:

class MyMultibindingModule extends AbstractMultibindingModule {

  public void configure() {

    GinMultibinder<String> mb = newSetBinder(String.class);
    ...  
  }
}

I think the proposal 2 is easier to implement.

Original comment by andres.a...@gmail.com on 9 Jul 2010 at 3:04

GoogleCodeExporter commented 9 years ago
I can't figure how to allow runtime keys in MapBinders:

GinMapBinder<MyKey, Snack> mapbinder
    = GinMapBinder.newMapBinder(binder(), MyKey.class, Snack.class);

// new MyKey("twix") is a runtime instantiation!!!
mapbinder.addBinding(new MyKey("twix")).toInstance(new Twix());

We should reduce the support of keys to only allow instances of String, 
Boolean, Number, Enum and Class?

Original comment by andres.a...@gmail.com on 10 Jul 2010 at 12:02

GoogleCodeExporter commented 9 years ago
There's a relevant difference between pure Guice and Gin; compile time.

In Gin it would be nice to be able to say:

   GinMultibinder<SomeExtension> extensions = newSetBinder(SomeExtension.class);
   extensions.addBindings().toGenerator(GWT.create(SomeExtensionPoint.class));

Where SomeExtensionPointImpl would walk through the classpath and find types 
that implement SomeExtension at compile time. 

Really it's all about trying to make a plugin system.  :)

(The above doesn't reflect what I feel is a nice syntax though :-)

Original comment by jatw...@linuxstuff.org on 10 Jul 2010 at 4:38

GoogleCodeExporter commented 9 years ago
Is this on the roadmap yet?  It's really hindering our ability to move an 
existing application from rocket-gwt to Gin.

Original comment by sne...@gmail.com on 18 Mar 2011 at 4:48

GoogleCodeExporter commented 9 years ago
It's on the road map but not terribly close. We're only just finishing cleaning 
up the private module mess and will need to get extensions in for this to work.

Original comment by aragos on 18 Mar 2011 at 11:50

GoogleCodeExporter commented 9 years ago
Submitted for review: http://codereview.appspot.com/4515152/

Original comment by gok...@google.com on 27 May 2011 at 6:08

GoogleCodeExporter commented 9 years ago
Is there a plan for a next release where multibinding is part of?

Original comment by stefan.r...@googlemail.com on 15 Sep 2011 at 9:56

GoogleCodeExporter commented 9 years ago
Trying to add this to a trunk check out.  It seems the only class that is 
missing is the ModuleInstantiator, but the changes were minimal (i.e. convert 
HashMap to LinkHashMap).  Has that functionality been moved and is it necessary?

Original comment by skitch...@gmail.com on 28 Feb 2012 at 2:43

GoogleCodeExporter commented 9 years ago
Well it seems to have worked without that class, which is cool.  

Would be nice though, if you didn't have to specify the set bindings and it 
found all the classes that implemented/extended the type and added them to the 
binding set. Could be performed through JClassType provided by GWT.

Original comment by skitch...@gmail.com on 28 Feb 2012 at 3:57

GoogleCodeExporter commented 9 years ago
Also how would you be able to add multibinding in secondary modules?

Say I have a binding for a set of some interface.  Say I have other modules 
implementing that interface and wish to be added to that set.

A bottom-up approach would be to expose the class in the private module, 
allowing the main module to addBinding.  But I'd rather the module be able to 
attach itself to the main module.

How can I retrieve the binding set builder and perform MultiBinder.addBinding?

Original comment by skitch...@gmail.com on 28 Feb 2012 at 10:49

GoogleCodeExporter commented 9 years ago
The solution is following original Guice multibindings 
(http://code.google.com/p/google-guice/wiki/Multibindings) as the rest of GIN. 

I'm not sure what you mean by secondary modules?

Original comment by gok...@google.com on 29 Feb 2012 at 7:36

GoogleCodeExporter commented 9 years ago
In guice I can make multibinding to bind to annotations to create different 
sets of the same element type, is there any plan to support this in GIN?

Original comment by sxi...@gmail.com on 19 Mar 2012 at 6:07

GoogleCodeExporter commented 9 years ago
This is definitely something that I would like to have in Gin

Original comment by toucansa...@gmail.com on 27 Mar 2012 at 6:20

GoogleCodeExporter commented 9 years ago
Is there a planed a release date for this enhancement ?

Original comment by e...@follea.fr on 5 May 2012 at 2:33

GoogleCodeExporter commented 9 years ago
Multibindings is just released to the trunk and has all the Guice features.

Aragos can you mark the issue as fixed? (I don't have the rights)

Original comment by gok...@google.com on 11 Apr 2013 at 2:19

GoogleCodeExporter commented 9 years ago
Can you also update the compatibility table?

Original comment by gok...@google.com on 11 Apr 2013 at 2:34

GoogleCodeExporter commented 9 years ago

Original comment by aragos on 11 Apr 2013 at 1:52