Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0D19B9763 for ; Tue, 6 Dec 2011 11:04:56 +0000 (UTC) Received: (qmail 24581 invoked by uid 500); 6 Dec 2011 11:04:55 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 24448 invoked by uid 500); 6 Dec 2011 11:04:55 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 24440 invoked by uid 99); 6 Dec 2011 11:04:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2011 11:04:55 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sberyozkin@gmail.com designates 209.85.215.41 as permitted sender) Received: from [209.85.215.41] (HELO mail-lpp01m010-f41.google.com) (209.85.215.41) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2011 11:04:47 +0000 Received: by lahi5 with SMTP id i5so3145821lah.0 for ; Tue, 06 Dec 2011 03:04:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=9RVGJ3LyzzAaQ2Jj0pqhwcHu/hDl9KfTZXrCufT1lgs=; b=DBH0VpXexCQ7nYyfaSRL9/VFTm5ihm7LSSOPSRNt86jf09DWF8tP0O9fhrJY08dhpi Klba8ca4AakPOkXD+iq50WYrlacFETa9Yqjj2qVSXrQcfIeYZ++QzpMBnbK7uSZ8wuh0 V3ahNntDclCB7nXL0T5A9enIkTSWmKjRlpk+A= Received: by 10.152.102.173 with SMTP id fp13mr8748803lab.24.1323169467374; Tue, 06 Dec 2011 03:04:27 -0800 (PST) Received: from [10.36.226.4] ([217.173.99.61]) by mx.google.com with ESMTPS id ne3sm20612718lab.7.2011.12.06.03.04.26 (version=SSLv3 cipher=OTHER); Tue, 06 Dec 2011 03:04:26 -0800 (PST) Message-ID: <4EDDF6B9.6050806@gmail.com> Date: Tue, 06 Dec 2011 11:04:25 +0000 From: Sergey Beryozkin User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 MIME-Version: 1.0 To: users@cxf.apache.org Subject: Re: JAX-RS Annotations and path resolution References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 06/12/11 10:11, Jeff Wang wrote: > Ok, I think I'm getting away from what I'm trying to accomplish, which > is to figure out the best way to annotate sub-resources. Currently, I > have foo, which is a sub-resource of bar. so I'd like to GET > /bar/1/foo for the list of Foos that bar 1 has. or POST /bar/1/foo to > create a new foo. or GET /bar/1/foo/3, to get foo 3. > > Currently, I have created two separate service beans, have with a > class level @PATH annotation of "/bar" and "/bar/{barId}/foo" > respectively, and individual @PATH additions as required (for fooId > and barId as appropriate. > > Right now, Bar, the POJO has a very simple JPA and XML mapping. > @XMLRootElement > @Entity > public class Bar { > @Column(name="fooId") > public Foo; > } > > (getters, setters, and other fields removed.) How would a equivalent > mapping be expressed in a sub-resource locator? Would it be actually > easier to read? > Not sure if it answers your question, here is one example: @Path("bar/{id}/foo") public class BarResource { @GET public Foos getFoos(@PathParam("id") int id) {} @POST public void addFoo(Foo foo) {} // optional: @GET @Path("{fooid}") public Foo getFoo (@PathParam("id") int id, @PathParam("fooid") int foo_id) {} } Additionally you can have a "/bar" path on a Bar itself and register it as another root resource, or push the above "{id}/foo" to the 3 existing methods and a GET which will return Bar - that would cover /bar only Cheers, Sergey > thanks > Jeff Wang -- Sergey Beryozkin Talend Community Coders http://coders.talend.com/ Blog: http://sberyozkin.blogspot.com