users@jersey.java.net

Guice injection does not support field/method injection without forcing you to bind the Resource class to the module...

From: James Strachan <james.strachan_at_gmail.com>
Date: Fri, 30 Apr 2010 15:07:04 +0100

I started tinkering with some Guice IoC in a Scalate Jog project...
http://scalate.fusesource.org/documentation/jog.html

and was quite suprised to not have a resource injected when using
Guice's @Inject. Turns out I think that the code only attempts to use
Guice to inject if it can see an @Inject annotation on a constructor -
or the resource is bound with the module.

I just wondered why this was done? I figured at least check for
method/field annotations too? I've raised an issue to track it...
https://jersey.dev.java.net/issues/show_bug.cgi?id=520

Maybe we should just change the
GuiceComponentProviderFactory.isImplicitGuiceComponent method to
check for @Inject on any field or method too?

Would it be too bad to just assume Guice is gonna create an instance I
wonder? e.g. in case we also use JSR 303 @Inject too or other custom
injection annotations like @Resource etc?

I just wondered if folks implemented it this way for a specific reason
- if not I was going to experiment making the code try to use Guice in
more than this very restrictive situation (constructor injection
only)?

-- 
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/