That great Michael, but one problem exists. You couldn't use guiceyfruit (TypeListener) solution for constructor injection... But (for me), it's most useful injection type...
If you are using field or method (setter) injection, type listener works great! As to me, all who want to read anotation parameters in providers, need to join forces and argue guice owners into this functionality necessity. Or may be create patch by ourselves. As I understand Bob Lee position, he want to be sure that all binding could be resolved, application is consistent. But if we will bind a set of possible annotations to one provider, it can't guarantee application consistence. (Sorry Bob, if I have corrupted your opinion). Any cases, it will be the great to read guice owners position on this question again. Best regards, Aleksey. On Jul 31, 1:44 am, Michael Burton <[email protected]> wrote: > Well, I couldn't wait, so I walked through what guiceyfruit was doing > and managed to accomplish what I needed using a custom TypeListener > and MembersInjector (without guiceyfruit). > > Works great! I'm quite pleased with the result. For anyone looking > to solve this problem in the future, I recommend using this solution > (or guiceyfruit, which is more polished). It would be grand if Guice > supported it directly, but as a workaround this solution seems > scalable and pretty efficient. I had thought it wasn't possible > previously, but now at least I know it is even if it's not as > convenient as a standard Provider. > > Thanks James, > > Mike > > On Jul 30, 11:44 am, Michael Burton <[email protected]> wrote: > > > > > Great James, it looks like that's very much along the lines of what > > I'm looking for. I'll try it out sometime in the next few weeks. > > > It seems like I've been reading a lot of "yeah that would be nice" > > posts about being able to read attribute values from within > > providers. It certainly would help me for Android and other > > projects. Guice maintainers, any thoughts about incorporating this > > into Guice? > > > Cheers, > > Mike > > > > GuiceyFruit currently focusses on using an annotation to specify a > > > parameterised injection point (like @Resource) which only tends to > > > work on a field or property injection point - not on annotations on > > > parameters at a regular @Inject injection point. > > > > If you did it more like this... > > > > @StringResource(R.string.foobar) > > > public void setString( String foobar) > > > > then you could bind the StringResource annotation as an injection > > > point like the way @Resource is supported; you can then write a kind > > > of provider which takes the StringResource annotation and uses its > > > values to create an object. > > > > e.g. > > > >http://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit-... > > > > for code sharing reasons much of the heavy lifting is actually in this > > > base class > > > >http://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit-... > > > > So in GuiceyFruit you'd implement a class which extends > > > AnnotationMemberProviderSupport<StringResource> then you bind it in > > > your GuiceyFruitModule via the bindAnnotationInjector() method > > >http://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit-... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-guice?hl=en -~----------~----~----~----~------~----~------~--~---
