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
Allow user-provided "autobinders" #49
Comments
From kevinb9n on March 05, 2007 14:49:19 I just had a realization: we could allow specification of a "MissingBindingHandler" |
From kevinb9n on March 05, 2007 15:09:38 (No comment was entered for this change.) Summary: MissingBindingHandler |
From kevinb9n on March 08, 2007 14:14:42 (No comment was entered for this change.) Labels: 1.1 |
From kevinb9n on March 13, 2007 17:30:41 TODO: have to cycle through 9 different possible names for this thing before finally This seems limited by the fact that you could have only one of these per injector. |
From kevinb9n on March 19, 2007 10:58:32 needs further thought; may be a better way to solve this like an alternate Binder Labels: -1.1 |
From ajoo.email on March 19, 2007 11:43:00 Is this the same as the "default impl resolver" proposal? I really think it is very valuable. And not having it is a real pain to our project. btw, I have an implementation of ImplementationResolver on my pc. I can share that |
From kevinb9n on March 19, 2007 12:56:19 I think it may be the same. It's a provider of providers. e.g., if we don't find a Bob and I are concerned about this one. It carries some risk of opening the That's a negative. And of course, all other things being equal, more power in the My use case: when using a one-off Injector to wire a small number of objects together Summary: MissingBindingHandler / a Provider-Provider |
From kevinb9n on March 19, 2007 14:47:30 Ben <ajoo.email
|
From kevinb9n on June 03, 2007 11:25:03 I'm tentatively naming this feature "autobinders". An autobinder receives a Key and a Binder, and can provide a binding for the key to My preference would be to make the injector configuration immutable as much as Here's a sketch. interface Autobinder<B> { In this way a particular autobinder can be restricted for use only with subtypes of a Then we tell Guice about this autobinder thus: public class MyModule implements Module { I believe that this feature as currently described is a generalization of what I was Summary: Allow user-provided "autobinders" |
From crazyboblee on June 04, 2007 16:42:46 Could the autobinder interface take a Key<T> and return a Provider<T> instead? Why |
From crazyboblee on June 04, 2007 16:45:27 Oh, you pass it a LinkedBindingBuilder, not a full Binder. Interesting. |
From gili.tzabari on June 06, 2007 06:02:28 Sorry, I'm not sure I fully understand this feature and its usefulness yet. Can |
From kevinb9n on June 08, 2007 12:35:45 todo: I will add links to all the mailing list threads containing problems that would |
From mcculls on July 23, 2007 01:28:26 what's the outlook for this issue? I'm willing to pitch in and help prototype/test this, as I'd find it very useful. 1) BindingAnnotations can be marked as 2) if the injector cannot find an InternalFactory for a member+key, it checks the key's BindingAnnotation 3) if the BindingAnnotation has 4) the autobinding factory looks for an implementation of Autobinder with the same binding annotation 5) when the factory is invoked, it calls the Autobinder impl with the original key and returns the result |
From edward.costello@orionhealth.com on October 18, 2007 21:36:08 I'm attaching a patch that implements this feature (as I need and understant it). This is slightly different from what was initially suggested. Autobinders are tied to Explict bindings take precedence over those from an autobinder. The new interfaces are basically: interface Autobinder { public class MyModule implements Module { Attachment: gist |
From edward.costello@orionhealth.com on October 23, 2007 13:40:38 Over the weekend I found a couple of bugs with the patch
|
From edward.costello@orionhealth.com on October 23, 2007 19:02:18 >> Updated previous patch was broken << Updated Version of the Patch Fixing the two above issues. Basically now the bindings added by an autobinder will block on the getProvider or The other issue is fixed by only adding the binding builder if the autobinder returns Attachment: gist |
From mcculls on November 05, 2007 23:48:52 New patch suggestion based on discussions with Bob, Kevin, Ed, and others. Missing Binder : BindingFactory<B> : Patch needs bit more javadoc and additional unit tests, but should work as designed. Attachment: gist |
From mcculls on November 06, 2007 19:00:03 Updated patch: exceptions thrown from BindingFactories are now logged in the Binder Attachment: gist |
From mcculls on November 28, 2007 23:35:03 My latest prototype patch for this issue is available from: http://peaberry.googlecode.com/svn/trunk/patch/BindingFactory.txt |
From mcculls on March 31, 2008 00:49:07 some design doc: https://code.google.com/p/peaberry/wiki/Patch_BindingFactory |
From rcouto on July 28, 2008 07:45:38 Would this be a solution to generic injection issue (id: 52)? Will the Dependency<T> Trying to be a bit more clear, if my class is Foo<T> and I have a field Bar<T>, could Currently, nasty things happen because TypeLiteral does not support TypeVariable nor |
From erik.putrycz on November 19, 2008 14:15:56 What is the status of this? The binderfactory would be a great feature. |
From crazyboblee on November 19, 2008 14:18:58 No plans to support this at the moment. Summary: Allow user-provided "autobinders" |
From sberlin on February 19, 2011 12:25:02 Same resolution as issue 27 - It's been 4 years since the issue was opened, Guice has seen wide use, and the general consensus thus far has been to purposely not expose this feature. It makes debugging even harder than it already is (which is the #1 pain point with Guice). |
From sberlin on February 19, 2011 12:28:57 (No comment was entered for this change.) Status: WontFix |
Any chance this issue could be re-opened for discussion. I've prototyped an auto-binding implementation using the ElementVisitor SPI but it requires custom processing of the elements prior to creating the injector and does not work with just in time binding. It would be nice to be able to register a MissingBindingHandler with a matcher (similar to the bindListener API) that can be added via the normal path of installing modules. |
From kevinb9n on February 28, 2007 17:09:35
It would be helpful if we could configure an injector in a special mode
where whenever it encounters a request for a type it doesn't have bound, it
will just create a dummy for that type. It could do this with Proxy or
cglib or easy mock or whatever.
Original issue: http://code.google.com/p/google-guice/issues/detail?id=49
The text was updated successfully, but these errors were encountered: