Thanks Sergey, Looks like the first option will solve the problem for me:)
Best regards Kiren On Tue, Sep 11, 2012 at 10:06 PM, Sergey Beryozkin <[email protected]>wrote: > Hi > > On 11/09/12 20:41, Kiren Pillay wrote: > >> Hi All, >> >> We have a project where the customer really doesn't want to go the full >> REST route. We are basically migrating a Corba IDL interface with 100+ >> functions over to web services and they want a generic URL to send >> requests >> through to. >> >> For the new implementation, I want to implement the following scheme: >> >> /rest/function/function1?**params=.. >> /rest/function/functionN?**params=.. >> >> This way each function can be mapped directly to the the servicing >> component, where each component is in a different class. . However from >> what I'm seeing, if the root resource is "function" for example, the >> resource component servicing the request may not be in a different >> implementing class. When I call the URL in the second function, I get "No >> operation matching request path "/RestTest/rest/function/**functionN" Is >> this >> the expected behaviour? >> >> I know I'm fighting against the way JAX-RS was meant to be used, but is >> there a way the above scheme can be made to work? >> >> This issue has been raised a number of times, yes, by default, when > multiple root resources share the same top-level Path value, the first > matching root resource is selected. JAX-RS 2.0 fixes this issue - I might > be able to get the fix in time for 2.7.0 - but more likely in 2.7.1 as the > update might be sensitive. > > In meantime, here are few possible options: > > - If every root resource has only a single function, then having a > top-level Path like "/function/function1", etc, will do > - Register a custom ResourceComparator (as jaxrs:provider): > > > http://cxf.apache.org/docs/**jax-rs-basics.html#JAX-**RSBasics-** > Customselectionbetweenmultiple**resources<http://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Customselectionbetweenmultipleresources> > > This can be the simplest option - you can use it to 'order' two root > resource representations. > > - perhaps consider introducing a root resource mediator, which will use a > subresource locator, ex, it will return MyRestTest for "/function", > OtherService for "/function1", etc > > As a side note, you might want to consider using a no-annotations approach > given that the legacy Corba services are exposed: > > http://cxf.apache.org/docs/**jax-rs-advanced-features.html#** > JAX-RSAdvancedFeatures-**RESTfulserviceswithoutannotati**ons<http://cxf.apache.org/docs/jax-rs-advanced-features.html#JAX-RSAdvancedFeatures-RESTfulserviceswithoutannotations> > > HTH, Sergey > > > Regards >> Kiren >> >> ==============================**=================== >> @Service("testService") >> >> public class MyRestTest { >> >> @GET >> @Produces("text/xml") >> @Path("/function") >> public MyType dummyFunction(){ >> MyType mt=new MyType(); >> mt.key="key"; >> mt.value= >> "**OKKKKKKKKKKKKKKKKKKKKKKKKKKKKK**KKKKKKKKKKKKKKKKKKKKKKKKKKKKKK** >> KKKKKKKKKKKKKKKKKKKKKKK"; >> try { >> Thread.sleep(50); >> } catch (InterruptedException e) { >> // TODO Auto-generated catch block >> e.printStackTrace(); >> } >> return mt; >> } >> >> ==============================**============================= >> >> @Service("otherService") >> @Path("/function") >> public class OtherService { >> >> @GET >> @Produces("text/xml") >> @Path("/functionN") >> public MyType dummyFunction(){ >> MyType mt=new MyType(); >> mt.key="key"; >> mt.value= "Other"; >> try { >> Thread.sleep(50); >> } catch (InterruptedException e) { >> // TODO Auto-generated catch block >> e.printStackTrace(); >> } >> return mt; >> } >> } >> >> > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > > Blog: http://sberyozkin.blogspot.com >
