users@jax-rs-spec.java.net

[jax-rs-spec users] Re: client proxy framework

From: Adam Bien <abien_at_adam-bien.com>
Date: Thu, 7 Apr 2016 10:30:12 +0200

Hi Bill,

I get a lot requests in projects about that.

+1,

cheers,

adam
> On 06.04.2016, at 22:26, Bill Burke <bburke_at_redhat.com> wrote:
>
> The new api would be really really simple:
>
> interface WebTarget {
>
> <T> T proxy(Class<T> intf);
> }
>
> Everything else would just be a re-use of all the annotations. Write would include rules for invocation and errors which would be similar to SyncInvoker methods. The only additional one I've always wanted to add was a @PostCreate that does a POST, expects a 201 and Location header in the response. This would allow you to automatically turn a Location header into a proxy, i.e.
>
> public interface CustomerResource {
> @GET
> public Customer get();
>
> @DELETE
> void delete();
>
> }
>
> public interface CustomersResource {
> @PostCreate
> @Consumes("application/json")
> CustomerResource create(Customer json);
>
> }
>
>
>
> On 4/6/2016 3:27 PM, arjan tijms wrote:
>> Would be incredibly useful, especially as a replacement for remote EJBs.
>>
>> Now if there only was some support for security context propagation and distributed transactions, but I digress ;)
>>
>> But what about cloning https://java.net/projects/jax-rs-spec/sources/api/show to GitHub and prototyping the proposed standard API there?
>>
>>
>>
>>
>> On Wed, Apr 6, 2016 at 5:09 PM, Markus KARG <markus_at_headcrashing.eu> wrote:
>> I wonder wheter the spec leads are still registered with this mailing list. 😉
>>
>>
>> Von: Bill Burke
>> Gesendet: Mittwoch, 6. April 2016 17:00
>> An: jsr370-experts_at_jax-rs-spec.java.net
>> Betreff: Re: client proxy framework
>>
>>
>> Lol. :)
>>
>>
>> On 4/6/2016 9:18 AM, Sergey Beryozkin wrote:
>>
>> > Reading your emails is one of the reasons I'm in this group :-), what
>>
>> > would I do without you posting :-) ?
>>
>> >
>>
>> > On 06/04/16 14:06, Bill Burke wrote:
>>
>> >> Ping. Again, this would be good feature to add IMO. Its simple to
>>
>> >> implement and would be used by a lot of developers. I need to know
>>
>> >> soon if this is something the spec leads are interested in. I'm about
>>
>> >> to renounce my JAX-RS EG membership and hand it off to somebody else
>>
>> >> at Red Hat as I'm really busy with other things. If there is interest
>>
>> >> in this proposal, I'll stick around to write it up.
>>
>> >>
>>
>> >> On 2/28/2016 6:13 PM, Bill Burke wrote:
>>
>> >>> This is not a feature I came up with 1 week ago on a whim. Its a
>>
>> >>> proven feature that has been around for 5+ years in Resteasy and is
>>
>> >>> wildly popular. A number of other projects I'm involved with use it
>>
>> >>> to publish their REST interface as its something users have demanded.
>>
>> >>>
>>
>> >>> I'd be happy to write it up, but I need to know soon as my schedule
>>
>> >>> is really busy in 2016. IMO, it would probably be the most popular
>>
>> >>> feature of 2.1 if it was added. Even non-Resteasy users would be
>>
>> >>> familiar with it as its already documented in both revisions of my
>>
>> >>> JAX-RS RESTFul Java O'Reilly books which have also been around for
>>
>> >>> 5+ years. :)
>>
>> >>>
>>
>> >>> Again, it would be something like this:
>>
>> >>>
>>
>> >>> interface MyRestClient {
>>
>> >>> @GET
>>
>> >>> @Product("application/json")
>>
>> >>> @Path("{name}")
>>
>> >>> Customer get(@QueryParam("name") name);
>>
>> >>> }
>>
>> >>>
>>
>> >>> Client client = ...;
>>
>> >>> MyRestClient proxy =
>>
>> >>> client.target("http://example.com").proxy(MyRestClient.class);
>>
>> >>>
>>
>> >>> Customer cust = proxy.get("Bill Burke");
>>
>> >>>
>>
>> >>
>>
>> >
>>
>>
>> --
>>
>> Bill Burke
>>
>> JBoss, a division of Red Hat
>>
>> http://bill.burkecentral.com
>>
>>
>>
>>
>
> --
> Bill Burke
> JBoss, a division of Red Hat
>
> http://bill.burkecentral.com

 workshops.adam-bien.com
 effectivejavaee.com
 blog.adam-bien.com
 airhacks.news

 Author of:
 "Real World Java EE Night Hacks”,
 "Real World Java EE Patterns— Rethinking Best Practices"