users@jersey.java.net

Null parameters to resource methods?

From: Chris Hubick <chris_at_hubick.com>
Date: Sat, 24 Oct 2009 13:42:31 -0600

Hi.

I want my resource class to have a method like:

@GET
public MyResource getResource(CustomResourceSpec optional)

Where when Jersey matches a request to that method, it would call it
with a null CustomResourceSpec argument, but where other classes can
reuse the same method, supplying a non-null argument.

Is there any facility like this?

As shown, I get an error like "A HTTP GET method, getResource, should
not consume any entity."

I tried annotating the arg with a fake @QueryParam("xxx"), which should
never really have a value, but I get an error like "Method, getResource,
annotated with GET ... is not recognized as valid Java method annotated
with @HttpMethod", which I'm pretty sure is because it doesn't know
about CustomResourceSpec, as it will send null for a primary type
argument.

Am I stuck creating extra Jersey/JAX specific no-arg wrapper methods in
all these cases?

I wish there was a @NullParam annotation or something to tell Jersey to
just supply null for those parameters.

Advice appreciated, Thanks!

-- 
Chris Hubick
mailto:chris_at_hubick.com
http://www.hubick.com/chris/