Hi James,
You are correct, nothing is mentioned in the spec, although i expected
it should.
IIRC the reason why we did not perform injection on non-null field
values is because they could have been set by the constructor or at
initialization, and the time we considered it better not to overwrite
something that was already set by the developer.
I did a quick test with Guice and it overwrites fields. So perhaps we
could relax this constraint and the developer should take care mixing
injection declarations that could results in IoC frameworks fighting
over an injection target?
Paul.
On Aug 1, 2010, at 8:54 AM, James Strachan wrote:
> I raised an issue a little while ago when getting confused the
> following scala didn't work...
>
> class MyResource {
> @QueryParam("foo") val foo: String = "someNiceDefaultValue"
> ...
> }
>
> Turns out field injection doesn't kick in if the field is non-null
> which I found a bit surprising at the time.
>
> I just wondered where this requirement/design decision came from? I
> took another look at the 1.1 specification and didn't see any mention
> in section 3.2 (though confess to skimming it). I understand the need
> for @DefaultValue with parameters (as in Java there's no such thing as
> default values on parameters - though thats not an issue in scala :)
>
> I just thought I'd ask before raising an issue; as I'm not sure why
> for field injection of JAXRS annotations, we'd not do it for non-null
> values (e.g. default values set in the constructor). I understand for
> other general purpose injection annotations there might be the
> possibility that spring/guice do them first so a non-null check makes
> sense - but I'm not sure why we'd not inject JAXRS annotation points?
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>