Return-Path: Delivered-To: apmail-cxf-users-archive@www.apache.org Received: (qmail 38286 invoked from network); 27 Oct 2009 23:06:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Oct 2009 23:06:13 -0000 Received: (qmail 77193 invoked by uid 500); 27 Oct 2009 22:39:33 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 77153 invoked by uid 500); 27 Oct 2009 22:39:33 -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 77135 invoked by uid 99); 27 Oct 2009 22:39:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Oct 2009 22:39:30 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [131.239.30.131] (HELO ntmamx1.progress.com) (131.239.30.131) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Oct 2009 22:39:27 +0000 Received: from ntmamx1.progress.com (127.0.0.1) by ntmamx1.progress.com (MlfMTA v3.2r9) id hstrac0171sm for ; Tue, 27 Oct 2009 18:39:13 -0400 (envelope-from ) Received: from progress.com ([172.16.3.168]) by ntmamx1.progress.com (SonicWALL 7.1.1.1995) with ESMTP; Tue, 27 Oct 2009 18:39:13 -0400 Received: from NTEXFE01.bedford.progress.com (ntexfe01 [10.128.10.24]) by progress.com (8.13.8/8.13.8) with ESMTP id n9RMd5Xu023357 for ; Tue, 27 Oct 2009 18:39:06 -0400 (EDT) Received: from MAIL02.bedford.progress.com ([172.16.2.55]) by NTEXFE01.bedford.progress.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 27 Oct 2009 18:39:05 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Delegating REST request to sub-resource classes ?? Date: Tue, 27 Oct 2009 18:39:04 -0400 Message-ID: In-Reply-To: <26032996.post@talk.nabble.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Delegating REST request to sub-resource classes ?? Thread-Index: AcpUIhmhVD/3kwtISEm0rnhrmtCsygDMsmdA From: "Sergey Beryozkin" To: X-OriginalArrivalTime: 27 Oct 2009 22:39:05.0661 (UTC) FILETIME=[4A2AE6D0:01CA5756] X-Mlf-Version: 7.1.1.1995 X-Mlf-UniqueId: o200910272239130393710 Hi It is=20 subresourceLocatorItemHandler() which will do the delegation in this example, because it is a subresource locator. This method has only a @Path annotation so it returns an object (CatalogHandler impl) which will be able to execute a required action... So if you have=20 POST catalogue/123/delete/xyz Then 'catalogue' will be consumed by CXF servlet, 123/delete will be captured by=20 @PathParam("id") and @PathParam("action") so you can use an "action" to select a handler which will do something with an item with id "id". Now that I know for sure you always do POST then you can do interface CatalogueItemHandler { @POST @Path("{lastsegment}") =20 public Response handle(@PathParam("lastsegment") String str); }=20 > public class SearchCatalogueItemHandler { >=20 > SearchCatalogueItemHandler(); > public Response handle(String lastsegment) {} > } 'lastsegment' will capture 'xyz' Cheers, Sergey=20 -----Original Message----- From: vmrm [mailto:rmode@vmware.com]=20 Sent: 23 October 2009 21:47 To: users@cxf.apache.org Subject: Re: Delegating REST request to sub-resource classes ?? Thanks Sergey, for helping, as always. But, I am confused a bit here as to how the request is going to be delegated to any of subresourceclass=20 handler. Do we assume that getItemHandler method will do the delegation?=20 If yes, can you please help me understand how?=20 And will it handle following requirement ? The request :=20 POST catalogue/123/delete/xyz HTTP1.1 ...headers... Content-lenght:0 will trigger the method "subresourceLocatorItemHandler" in "BaseRESTResource" but=20 1) how will it call the class DeleteCatalogueItemHandler ? 2) Also, in DeleteCatalogueItemHandler how can I have::=20 @Path ("/section/{someID}") public CatalogueHandler deleteFromSection (@PathParam("someID") int someId) { return getDeleteStatus (); } I hope the questions aren't bothering, but i really want to make this work :) Sergey Beryozkin-2 wrote: >=20 > Hi >=20 > you can have something like >=20 > public class BaseRESTResource { >=20 > @Path("{id}/{action}") > public CatalogueItemHandler subresourceLocatorItemHandler(@PathParam("id") > int id, @PathParam("action") String action) { > CatalogueItem item =3D findItem(id); > CatalogueItemHandler handler =3D getItemHandler(action) > handler.setItem(item); > return handler; > } >=20 > } >=20 > interface CatalogueItemHandler { >=20 > public Response handle(); > } >=20 > public class SearchCatalogueItemHandler { >=20 > SearchCatalogueItemHandler(); > @POST > public Response handle() {} > } >=20 > public class DeleteCatalogueItemHandler { >=20 > DeleteCatalogueItemHandler(); >=20 > @POST > public Response handle() {} > } >=20 > etc >=20 > probably much better options are available; this one assumes it's not > possible to use DELETE/etc HTTP verbs so you have to use POST=20 > in all cases, etc... >=20 > cheers, Sergey >=20 > ----- Original Message -----=20 > From: "vmrm" > To: > Sent: Friday, October 23, 2009 2:12 PM > Subject: Delegating REST request to sub-resource classes ?? >=20 >=20 >> >> Hi, >> >> I am using the NON SPRING CXF-2.2.2 REST implementaion. My web.xml looks >> like this: >> >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> >> CXFServlet >> CXF Servlet >> >> org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet >> >> >> jaxrs.serviceClasses >> >> com.rest.BaseRestResourceClass >> >> >> 1 >> >> >> CXFServlet >> /catalogue/* >> >> >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> >> Now as shown ablove all requests with URIs like (example): >> >> /catalogue/123/add/x >> /catalogue/314/search/y >> /catalogue/256/delete/z >> >> are delegated to the "BaseRESTResourceClass" and respective methods are >> called for different URIs . >> >> >> Problem: I want to have different resource classes for different >> patterned >> URIs like: >> >> /catalogue/123/add/* ---> AddResourceClass >> /catalogue/123/search/* ---> SearchResourceClass >> /catalogue/123/delete/* ---> DeleteResourceClass >> >> Is there a way to do this(delegation) in the BaseRESTResourceClass or >> otherwise ? >> >> >> P.S: I thought of doing it in the web.xml itself, but, as we know, it >> doesn't allow the specific patterns like: >> ----------------------------------------------------------- >> >> Addition_CXFServlet >> /catalogue/*/add/* >> >> ----------------------------------------------------------- >> >> Deletion_CXFServlet >> /catalogue/*/delete/* >> >> ----------------------------------------------------------- >> >> >> Thanks. >> >> >> >> >> >> --=20 >> View this message in context: >> http://www.nabble.com/Delegating-REST-request-to-sub-resource-classes--- -tp26026208p26026208.html >> Sent from the cxf-user mailing list archive at Nabble.com. >>=20 >=20 >=20 >=20 --=20 View this message in context: http://www.nabble.com/Delegating-REST-request-to-sub-resource-classes--- -tp26026208p26032996.html Sent from the cxf-user mailing list archive at Nabble.com.