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

From: Jan Algermissen <>
Date: Tue, 17 Apr 2012 14:11:15 +0200

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?


> @Resource Client client;
> In this case, how would the Client be initialized? With what providers? This is important as there will be client-specific filters/interceptors and server-specific filters/interceptors. This also has an effect on default providers created by the container and how those default providers are registered.
> Some ideas:
> * have a @Client/_at_Server annotation that could be applied to a provider to scope it for either Client and/or Server.
> * Add getClientClasses() and getClientSingletons() to Application
> * Make the Configuration interface simpler so users can implement it and register it just like they do with the Application class. You might even be able to define binding annotations and have multiple Configurations per application that could be injected.
> Bill
> --
> Bill Burke
> JBoss, a division of Red Hat