I agree -- I don't really consider that a solution. Still, I haven't seen
any other use-cases for injecting the InjectionPoint into a Provider. The
*only* thing that the custom injection SPI makes more complicated is
injecting arbitrary things through an existing @Inject constructor. With
field & method injection, it's trivial to add a new field/method with a
@MyCustomInject annotation. With constructor injection, it's more difficult
because you need to actually change your constructor to use @MyCustomInject
instead of @Inject.
There are a few things that can be done here.
a) Nothing. Logging is the only use-case that's been brought up in 3 years,
and logging can be solved by injecting the factory and using a
getLogger(Class) method.
b) Add some kind of support for resolving custom dependencies in
pre-existing @Inject points. That is, a signature like
@Inject Cxtor(Foo foo, @Named("bar") bar, @CustomInjectable baz)
Foo is a normal dependency, bar is a binding annotation dependency, baz is
some new kind of @CustomDependency that would work somehow similar to the
custom injection SPI.
c) Allow the InjectionPoint to be injected into Providers.
I'm -1 on c) for reasons stated earlier in the thread. I'm also -1 on b)
because reading the code is very confusing -- you don't easily know if the
annotation is a binding annotation or a custom dependency annotation. a)
seems like a reasonable solution to me.
Sam
On Wed, Apr 28, 2010 at 7:23 AM, Max Bowsher <[email protected]> wrote:
> On 28/04/10 08:23, Peter Reilly wrote:
> > The specific problem of injecting non-static log4j Logger is possible
> with guice
> > see:
> http://anyweight.blogspot.com/2009/07/injecting-log4j-loggers-via-guice.html
>
> Eek. Injecting a dummy Logger via Guice's normal injection just so you
> can use @Inject, and then reinjecting the Logger you actually want as a
> custom injection is rather horrid :-(
>
> Max.
>
>
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" 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-dev?hl=en.