users@jersey.java.net

[Jersey] Re: Client and custom socket factory

From: Christopher Piggott <cpiggott_at_gmail.com>
Date: Fri, 11 Feb 2011 09:38:37 -0500

On Fri, Feb 11, 2011 at 9:16 AM, Petr Jurák <petr.jurak_at_gmail.com> wrote:
> Hello,
> Try something like this:
>
> Client c = Client.create();
> WebResource r = c.resource(“http://youripaddress:8080/xyz”);

I'm not sure what you mean, that's the normal way of doing it ... but
it doesn't manipulate the source address of the socket.

What I want to be able to do is more like:
     r = c.resource("http://something:port/something", MY_ETH_ADDR);
or
     r = c.resource("http://something:port/something", MY_CELL_ADDR);

in order to set the source address, on a WebResource by WebResource
basis. At that point, the ip routing policy I set up will route out
the interface that is bound to that source address. Of course, the
above methods don't exist.

What I am trying to figure it is a reasonable way to do this within
the existing jersey client framework. As Pavel pointed out, the
jersey-apache-client might have a way, but I haven't found it yet.

Maybe the answer is "Don't use jersey-client" :-( but jersey-client
is sooooo nice ... the URI builder, the message body readers and
provider framework.... I hate to give that up because of something
that should be so simple.

--Chris