You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Jeremy Daggett <je...@RACKSPACE.COM> on 2014/05/19 18:33:24 UTC

MediaType class in jclouds

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



Re: MediaType class in jclouds

Posted by Ignasi Barrera <ig...@gmail.com>.
I also don't like the "withoutParameters()" notation, but I wouldn't
like to have yet another MediaType class.

I'd stick to the Guava one, and in that cases we don't really want to
use eh ugly "wighoutParameters" form, why don't just use the String
literal?

On 19 May 2014 18:33, Jeremy Daggett <je...@rackspace.com> wrote:
> 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
>
>