users@jersey.java.net

Re: [Jersey] A Jersey Client doing HTTP Cache

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Tue, 7 Sep 2010 09:48:45 +0200

On Sep 6, 2010, at 6:14 PM, Imran M Yousuf wrote:

> Hi Paul,
>
> On Mon, Sep 6, 2010 at 3:49 PM, Paul Sandoz <Paul.Sandoz_at_oracle.com>
> wrote:
>> Hi Imran,
>>
>> This is great!
>>
>
> Thanks.
>
>> I am a bit busy with JavaOne tasks to give this a full test drive
>> at the
>> moment.
>>
>
> I will patiently wait :).
>
>> But i did take a quick look at the source. I was wondering why it
>> was not
>> implemented as a ClientFilter but I see the caching API depends on
>> the
>> Apache HTTP client.
>
> Yes, one approach would have been to implement a client filter which
> would make it to work on any Jersey Client; in that case it would
> require a rewrite of what HTTPCache4J has written :). Since I worked
> with its original developer and I know its being used in production, I
> have the opinion that its better that I do not rewrite anything and
> thus I used it directly.
>

Yes, makes sense.


>>
>> Perhaps we could extend from the existing Jersey Apache HTTP client
>> support?
>> that way it should be familiar to existing developers and the same
>> properties will work. If you need changes to Jersey code to enable
>> that
>> please don't hesitate to log issues and send patches.
>>
>
> I first took the path of extending directly and then realized that to
> have all the code from ApacheHttpClientHandler (that is supporting its
> properties), I needed to write my own response resolver.
> http://httpcache4j.codehaus.org/create_response_resolver.html
> And might turn out creating a mess :(.
> In addition for authentication Erlend (developer and maintainer of
> HTTPCache4J) has done some neat work which I wanted to take advantage
> of, thus the rewrite. If the current version works fairly I will try
> to incorporate all rest of the features of Apache HTTP Jersey Client.

Yes, parity with the existing properties would be nice.


> I will need some guidance in terms of how to extend fruitfully. It
> would be extremely helpful for usage if we can support the same set of
> properties.
>

Perhaps one way to achieve this is to have

   class CachedApacheHttpClient extends ApacheHttpClient { ... }

and

   class CachedApacheHttpClientHandler extends ApacheHttpClientHandler
{ ... }

the former will create an instance of the latter to register with the
ApacheHttpClient. Given what you say there may not be much that can be
shared by the way of the ApacheHttpClientHandler implementation
itself. If so we can refactor ApacheHttpClientHandler into an abstract
base class for any shared functionality that would exist.

Paul.

> Thank you, waiting for some guidance.
>
> Regards,
>
> Imran
>
>> Paul.
>>
>>
>> On Sep 5, 2010, at 4:28 PM, Imran M Yousuf wrote:
>>
>>> Hi,
>>>
>>> I have been wanting a Jersey Client that handles HTTP Caching on the
>>> client by default without me as a developer having to worry about
>>> anything. And I am happy to say that we do have once such client
>>> which
>>> we hope does serve the purpose.
>>> http://code.google.com/p/smart-util/wiki/JerseyCacheClient
>>> Details about the source code is at -
>>> http://code.google.com/p/smart-util/wiki/SourceCode
>>>
>>> I would be extremely grateful if you would kindly help me test it
>>> out
>>> by replacing current client of your project with this client. I
>>> would
>>> welcome any new feature requests, not to mention contribution, and
>>> we
>>> want to make the client production ready so bugs would be attended
>>> with urgency. Any queries are welcome.
>>>
>>> Thank you in advance.
>>>
>>> --
>>> Imran M Yousuf
>>> Blog: http://imyousuf-tech.blogs.smartitengineering.com/
>>> Mobile: +880-1711402557
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>
>
>
> --
> Imran M Yousuf
> Entrepreneur & CEO
> Smart IT Engineering Ltd.
> 25/5B, Block F, Haji Chinu Miah Road Bylane
> Joint Quarter, Mohammadpur
> Dhaka - 1207, Bangladesh
> Email: imran_at_smartitengineering.com
> Blog: http://imyousuf-tech.blogs.smartitengineering.com/
> Mobile: +880-1711402557
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>