users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Client initialization on server-side

From: Bill Burke <bburke_at_redhat.com>
Date: Tue, 17 Apr 2012 12:07:48 -0400

On 4/17/12 8:11 AM, Jan Algermissen wrote:
>
> On Feb 1, 2012, at 4:36 PM, Bill Burke wrote:
>
>> The binding of providers on the server side for JAX-RS resources is pretty staightforward.
>>
>> It is not so straightforward for Clients though. Should we allow the injection of Client instances? i.e.
>
> Sorry to be a bit late on this....
>
> If we are talking about using an HTTP client from within a server thread, the situation is pretty similar to using a database connection.
>
> For that reason, I think that HTTP clients should be managed by the container as much as database connections are.
>
> FWIW, I'd like to approach obtaining an HTTP client similar to injecting an EntityManager.
>
> HTTP client pooling, HTTP caching and HTTP connection control etc. should all just be managed by the container.
>
> Maybe certain client configurations ('HTTP client contexts'?) could be configured analog to how persistens contexts are managed in persistence.xml.
>
> Makes sense?
>

Container management of Client should be optional. There's a lot of
issues involved, especially when you start dealing with HTTPS,
trust-stores, authentication, etc. that may be endpoint specific.

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com