[jax-rs-spec users] Access to PathParam's outside of a matched context

From: Paul Moore <>
Date: Mon, 22 Jul 2013 21:05:47 +0100

Hi all,

A quick question about @PathParam's outside of a matched context.

"Normally" we can use @PathParam to obtain the value of a URI parameter as
part of the resource definition. The combination of the @Path annotation
(with parameter placeholder) and the @PathParam annotation allows injection
of the relevant parameter, and we don't have to worry about it i.e.

public Response getExample(@PathParam("id") int id) {...}

In my situation, I'm including (hypermedia) links on my inbound
representations, and I need to dereference the URI into domain objects. By
way of example, I'd like to be able to get the "id" from the URI:

@Path annotation: /persons/{id}
id: 42

However, because I am working with resources outside the current context,
there's no injection support, and no real access (that I've found) to do
the dereferencing.

So far (in Jersey) I'm using something like the following:

        UriTemplate template = new
        Map<String, String> values = new HashMap<String, String>();
        values.put("id", null);
        template.match(link.get("href").toString(), values); // where link
here is a JsonObject

which is a little convoluted / potentially fragile, not to mention that
it's using UriTemplate which is implementation specific and not part of JAX

Am I missing something obvious or does the spec not support this?

Thanks in advance