users@jersey.java.net

Re: [Jersey] chaining resources.

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 29 Jun 2009 16:50:22 +0200

On Jun 29, 2009, at 4:33 PM, Brendan Murphy wrote:

> Hi,
>
> I'm new to jersey and need help on how to use separate "REsources"
> to handle different parts of a single URI, is this possible?
>
> e.g take the URI "/employee/manager/john".
>
> I'd like to chain 3 different resource objects one to handle each
> part of the URI path. The first resource would handle "employee" and
> pass "/manager/john" to
> the next resource.
>
> If this is possible, how is coded using the jersey API?
>

Yes, you can use sub-resource methods and sub-resource locators e.g.:

   @Path("employee)
   public class Employee {
     @Path("manager/john")
     public ManagerJohn getResource() {
        return new ManagerJohn();
     }
   }

See the following for more details:

https://jersey.dev.java.net/documentation/1.1.0-ea/user-
guide.html#d4e271

Paul.