Patch: Jersey Client Backend

From: Jorge L Williams <>
Date: Tue, 18 Nov 2008 12:54:50 -0700

Hey guys,

The following patch allows WADL2Java clients to use the Jersey-Client
library as a backend. This replaces the URLConnection based backend that
currently exists. Using Jersey allows access for a fair amount of
configurability. There's a new class (ClientConfigurator) that allows the
developer to specify a root ClientHandler and a ClientConfig (see JavaDoc
for jersey-client). When used in conjunction with the HttpClient backend
for Jersey a developer can gain access to new features such as preemptive

Here's how I setup my WADL2Java client:

DefaultHttpClientConfig clientConfig = new DefaultHttpClientConfig();

clientConfig.setCredentials (null, "", 443, username,

ClientConfigurator.setClientHandler(new HttpClientHandler());
ClientConfigurator.setClientConfig (clientConfig);

Note, this is based on the HttpClient backend which I've submitted as a
separate patch to the Jersey developer mailing list.

The client config and handler can change between requests.

A developer is not required to use ClientConfigurator at all. If it's not
used, a WADL client will use a default root ClientHandler, which uses
URLConnection, with a default ClientConfig. For the most part, developers
will not notice a difference between this backend and the previous one.
The only big difference is that WADL resource calls used to throw
MalformedURLExceptions and IOExceptions and they now throw
URISyntaxExceptions and UniformInterfaceExceptions.

-jOrGe W.