users@jersey.java.net

Jersey 1.0.1: getMatchedResources and actual resources

From: Wilhelmsen Tor Iver <TorIverW_at_arrive.no>
Date: Thu, 5 Feb 2009 13:22:09 +0100

Does UriInfo.getMatchedResources() resolve correctly? I am trying to
pick up the parent in a sub-resource and only get an uninitialized bean
back.

Code extract:

@Path("/employee/{id}")
@Produces("application/xml")
public class Employee extends EmployeeBean {

        @GET
        public Response get(@PathParam("id") String id, @Context UriInfo
info) {
...

        @Path("vacationdays")
        public VacationDays getVacationDays() {
                return new VacationDays();
        }


public class VacationDays extends VacationDaysBean {

        @GET
        public Response get(@Context UriInfo info) {
                List<Object> res = info.getMatchedResources();
                VacationDaysBean ret = null;
                if (res != null && res.size() > 0) {
                        Object obj = res.get(res.size() - 1);
*** if (obj instanceof Employee) {

At the point in the code marked with *** above, obj exists but all
fields are null, the get() has not been called.

Am I doing something wrong, or is it not fully implemented yet? Would it
work if I added a constructor with a @PathParm as well? Or do I need to
use a different getter method?

Med vennlig hilsen

TOR IVER WILHELMSEN
Senior systemutvikler
Arrive AS
T (+47) 48 16 06 18
E-post: toriverw_at_arrive.no
http://www.arrive.no
http://servicedesk.arrive.no