Hello Daku,

the ClientResource#wrap method is only useful with Restlet annotations, not
JaxRS ones.
It will work by defing the interface as follow :
public interface DummyResource {
  @Get
  public String sayHello();
}
The implementation of this interface must be attached on a router defined by
the Application#createInboundRoot.

You can have a look at this sample application
http://wiki.restlet.org/docs_2.0/13-restlet/303-restlet.html.

Please, feel free to ask for more details.

Best regards,
Thierry Boileau


Hi,
> I am trying to wrap a resource hosted on a restlet engine, and then calling
> a function on that object as a result it creates and executes on some
> dangling object (might be a bug). For details see below:
>
>                ClientResource cr = new ClientResource(BaseURI + "/dummy");
>                DummyResource r = cr.wrap(DummyResource.class);
>                System.out.println("returning message: "+r.sayHello());
>
>
> The last statement evaluates to
>                returning message: null
>
> DummyResource interface:
>
>                import javax.ws.rs.GET;
>                import javax.ws.rs.Path;
>                import javax.ws.rs.Produces;
>                import javax.ws.rs.core.MediaType;
>
>                @Path("/dummy")
>                public interface DummyResource {
>
>                @GET
>                @Produces(MediaType.TEXT_PLAIN)
>                public String sayHello();
>                }
>
> Implementation:
>
>      public class DummyResourceImpl implements DummyResource{
>
>          public String sayHello() {
>                return "Hello";
>          }
>      }
>
>
> Interestingly, if I do not wrap at the client side, and expose the concrete
> class as a resource on the server side then it functions without any
> problems.
>
> Note : I have embraced this idea from "JAX-RS and Java interfaces" section
> on pg. 35 from the book called "Restful JAVA with JAX-RS".
>
> Daku
>
> --
> View this message in context:
> http://restlet-discuss.1400322.n2.nabble.com/buggy-ClientResource-wrap-tp6416674p6416674.html
> Sent from the Restlet Discuss mailing list archive at Nabble.com.
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2752271
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2752280

Reply via email to