Hi all,

We have had some discussions recently around using a common MediaType class for 
representing MIME types in jclouds. I have been flip-flopping on this for the 
past couple of weeks around Guava/JAX-RS and wanted some community feedback on 
the best approach forward.

I prefer the more robust Guava MediaType [1] class over JAX-RS [2] 
implementation, however it just seems awkward to use for simple 
representations.  Guava defines the base JSON type (with UTF-8) as:

   MediaType.JSON_UTF_8 -> "application/json; charset=utf-8”

To get the more common representation of “application/json” would require us to 
represent it as :

   MediaType.JSON_UTF_8.withoutParameters();

I recently submitted PR# 365 [3] with this notation and I really don’t like the 
syntax. I find it confusing and too verbose. JAX-RS simplifies the 
representation to:

   MediaType.APPLICATION_JSON -> “application/json"

OkHttp also defines a simple MediaType [4] class similar to JAX-RS, but that 
would tie us to OkHttp and I don’t think that is a wise decision.

Do others find this awkward? Should we stick to the current JAX-RS MediaType 
across the board, use Guava, or create our own?

/jd

[1] 
http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/net/MediaType.html
[2] http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/MediaType.html
[3] 
https://github.com/jclouds/jclouds/pull/365<https://github.com/jclouds/jclouds/pull/365/files#diff-b78d40d7e7da844f27336e122a7e5662R125>
[4] 
https://github.com/square/okhttp/blob/master/okhttp/src/main/java/com/squareup/okhttp/MediaType.java


Reply via email to