users@jersey.java.net

[Jersey] Making client calls using server-side resource interfaces

From: James Shaw <js102_at_zepler.net>
Date: Fri, 24 Aug 2012 22:12:20 +0100

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?