users@jersey.java.net

[Jersey] Re: Making client calls using server side resource interfaces

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Mon, 27 Aug 2012 11:28:04 +0200

We've added such extension to Jersey 2.0: https://github.com/jersey/jersey/tree/master/ext/proxy-client

There's an example using the extension feature: https://github.com/jersey/jersey/tree/master/examples/system-properties-example
See the example unit test in particular: https://github.com/jersey/jersey/blob/master/examples/system-properties-example/src/test/java/org/glassfish/jersey/examples/sysprops/SysPropsTest.java

Marek

On Aug 24, 2012, at 4:39 PM, James Shaw <hertzsprung_at_gmail.com> wrote:

> I'm not sure if this is something that's been considered (and perhaps
> rejected) before. Would be possible to generate proxy classes that
> implement resource interfaces, then use these interfaces to
> communicate with that resource? For example:
>
> @Path("/myResource")
> public interface MyResource {
> @GET String getMyResource();
> }
>
> public class MyResourceImpl implements MyResource {
> String getMyResource() { return "foo"; }
> }
>
> Then something like:
> System.out.println(Client.proxy("http://localhost:9998",
> MyResource.class).getMyResource());
>> foo
>
> It seems like IntrospectionModeller.createResource() could provide the
> basis for something like this. Any thoughts?