users@jersey.java.net

field injection with _at_FormParam _at_QueryParam or _at_PathParam and default values

From: James Strachan <james.strachan_at_gmail.com>
Date: Sun, 1 Aug 2010 07:54:29 +0100

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/