users@jersey.java.net

Re: [Jersey] Annotation Inheritance

From: animesh sonkar <animesh_smit_at_yahoo.com>
Date: Fri, 30 Oct 2009 21:16:21 +0530 (IST)

Yeah i solved this one too... public interface TestInterface { @Path("/test") @GET @Produces("text/plain") public String sayHello(); } Note @path here : @Path("") public class TestIMPL implements TestInterface { public String sayHello() { // TODO Auto-generated method stub return "Hello World"; } This solves my problem. Including @Path just lets the ServletContainer know that this is a Root Resource and no errors are thrown at startup. The resource is now accessible using "/test". But i have a doubt, could this be a bug in jersey? If yes, i cannot rely on @Path("") in IMPL. Also i obseerved that. if the impl was @Path("/dummy") public class TestIMPL implements TestInterface { public String sayHello() { // TODO Auto-generated method stub return "Hello World"; } then "/dummy" worked (sorry about previous post in which i mentioned this did not work) also "/dummy/test" gave me the same result.... Fits in the REST context? or another bug in jersey? Thanks i got the problem. Shifted @Path to TestIMPL and things were smooth But my whole intention was to provide an interface with @Path("/test") So an implementaion provider just needs to implement the interface method and the contract to the URL is taken care. i tried public interface TestInterface { @Path("/test") @GET @Produces("text/plain") public String sayHello(); } @Path("/dummy") public class TestIMPL implements TestInterface { public String sayHello() { // TODO Auto-generated method stub return "Hello World"; } } this time i did not get any exception but neither "/dummy" nor "/test" worked and no errors were genereted. Any idea how to go about? ________________________________ Try the new Yahoo! India Homepage. Click here. Try the new Yahoo! India Homepage. Click here. http://in.yahoo.com/trynew