Re: GZIPed JSON

2008-07-07 Thread Thierry Boileau

Hello Takenori,

you can use the Encoder filter 
(http://www.restlet.org/documentation/1.1/nre/com/noelios/restlet/application/Encoder.html) 
which is able to compress automatically the response's entity according 
to the client's preferences (based on the header accept-encoding).
This filters lets the resource (or the Restlet) generate its 
(decompressed) representation without taking into account such issues.

Is it what your are looking for?

best regards,
Thierry Boileau
Hi, 

Thanks to Restlet, 
I enjoy REST world in Java :)


I design a huge financial data REST service, 
with spreadsheet-like front end by gwt on client.


 To maximize the throuput, 
I am going to prepare GZIPed JSON on NAS. 


1. Database - JDBC - JSON - GZIP - Client
2. JSON - GZIP - Client
3. GZIP - Client

With EncodeRepresentation, 
I was able to implement 1 and 2. 

But I can not find a clear way to do 3, 
EncodeRepresentation#write looks related, though. 


Could you suggest a way to achieve something like this?

e.g. GZippedJSONResource
* if client supports GZIP, the content is directly sent, 
otherwise, it is extracted, then is transformed appropriately. 


#represent:
File f = new File(new URI(gzippedJSONURI));
GZippedJSONRepresentation gjr = new GZippedJSONRepresentation(f);
return gjr;

Best,
Takenori


  


Re: GZIPed JSON

2008-07-07 Thread Thierry Boileau

Hi Takenori,

the Encoder has two attributes : a list of accepted media-types for 
compression, and a list  of ignored data types. If the latter contains 
the media-type of your representation then no compression occurs. By 
default, this list contains the following media types which should be 
sufficient for you:
- MediaType.APPLICATION_CAB, MediaType.APPLICATION_GNU_ZIP, 
MediaType.APPLICATION_ZIP, MediaType.APPLICATION_GNU_TAR, 
MediaType.APPLICATION_JAVA_ARCHIVE, MediaType.APPLICATION_STUFFIT, 
MediaType.APPLICATION_TAR, MediaType.AUDIO_ALL, MediaType.IMAGE_ALL, 
MediaType.VIDEO_ALL



best regards,
Thierry Boileau
Hi Thierry, 

Thanks for the direction. 


I'm not 100% sure, but Encoder is for uncompressed representation, correct?
Then, it transforms it into an appropriate one transparently. 

I appreciate the feature. 

But that means, a compression happens every time. 
So I wonder if the JSON content is already gzipped as a file, 
it can be passed without compression overhead. 

The media type is known, JSON. 


Is such a thing possible? or does make sense?

Best,
Takenori





  


Re: GZIPed JSON

2008-07-07 Thread Takenori Sato
I see, thanks. 

I will take a closer look at it!

Takenori



GZIPed JSON

2008-07-06 Thread Takenori Sato
Hi, 

Thanks to Restlet, 
I enjoy REST world in Java :)

I design a huge financial data REST service, 
with spreadsheet-like front end by gwt on client.

 To maximize the throuput, 
I am going to prepare GZIPed JSON on NAS. 

1. Database - JDBC - JSON - GZIP - Client
2. JSON - GZIP - Client
3. GZIP - Client

With EncodeRepresentation, 
I was able to implement 1 and 2. 

But I can not find a clear way to do 3, 
EncodeRepresentation#write looks related, though. 

Could you suggest a way to achieve something like this?

e.g. GZippedJSONResource
* if client supports GZIP, the content is directly sent, 
otherwise, it is extracted, then is transformed appropriately. 

#represent:
File f = new File(new URI(gzippedJSONURI));
GZippedJSONRepresentation gjr = new GZippedJSONRepresentation(f);
return gjr;

Best,
Takenori