Message from discussion
[2.0] JSON in Play
Received: by 10.68.234.38 with SMTP id ub6mr1612540pbc.2.1338458623986;
Thu, 31 May 2012 03:03:43 -0700 (PDT)
X-BeenThere: play-framework@googlegroups.com
Received: by 10.68.195.100 with SMTP id id4ls3452682pbc.8.gmail; Thu, 31 May
2012 03:03:36 -0700 (PDT)
Received: by 10.68.220.230 with SMTP id pz6mr1608604pbc.3.1338458616539;
Thu, 31 May 2012 03:03:36 -0700 (PDT)
Received: by 10.68.220.230 with SMTP id pz6mr1608602pbc.3.1338458616528;
Thu, 31 May 2012 03:03:36 -0700 (PDT)
Return-Path: <guillaume.b...@gmail.com>
Received: from mail-pz0-f54.google.com (mail-pz0-f54.google.com [209.85.210.54])
by gmr-mx.google.com with ESMTPS id iq5si447170pbc.1.2012.05.31.03.03.36
(version=TLSv1/SSLv3 cipher=OTHER);
Thu, 31 May 2012 03:03:36 -0700 (PDT)
Received-SPF: pass (google.com: domain of guillaume.b...@gmail.com designates 209.85.210.54 as permitted sender) client-ip=209.85.210.54;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of guillaume.b...@gmail.com designates 209.85.210.54 as permitted sender) smtp.mail=guillaume.b...@gmail.com; dkim=pass header...@gmail.com
Received: by dadv36 with SMTP id v36so1358069dad.27
for <play-framework@googlegroups.com>; Thu, 31 May 2012 03:03:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to
:content-type:content-transfer-encoding;
bh=ZLzdDK/RwwsZqYGdSV6pR4SOc7kZV0aaVCGIVJraKbI=;
b=X7ZJJi/mV7OmtYBgIfjbQh1uBNzNFDjkbX95Al/NnMTewpP//hgJw4xJ2z4fJvygZm
z5ZCmE0I9dYiQozglkxRirnI4dLoVNj6uORkF34i++/EtaBG1zH7OvspzhQ3TAgntki+
FhHMj4YRy89nA95XGnrvZbmXWwaq5mUcwT0jnelCspqbsAW9P0Rw2D2ohakcF1P1nG2H
KQCbKGFnEo/aBhQeUhQD5nkyf7TaprIYGg4/sMkClaZZsGsTcvWetYrDW98sZGOFxnxF
e5zN9iUM537z9rXL7rYLhncqHumlJzNts2nqOW3HUcBLcW9Bh6WlTdX3Qdcvl8WNAJqz
1k9A==
Received: by 10.68.200.193 with SMTP id ju1mr5062238pbc.90.1338458616148; Thu,
31 May 2012 03:03:36 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.68.44.65 with HTTP; Thu, 31 May 2012 03:03:15 -0700 (PDT)
In-Reply-To: <773487a4-a4fa-421b-8021-1eb5733995a4@googlegroups.com>
References: <773487a4-a4fa-421b-8021-1eb5733995a4@googlegroups.com>
From: Guillaume Bort <guillaume.b...@gmail.com>
Date: Thu, 31 May 2012 12:03:15 +0200
Message-ID: <CAC0WruzadcJ-QxxfxRajdYLg5v5aSP++3MQg21U5+0UL9ZR...@mail.gmail.com>
Subject: Re: [play-framework] [2.0] JSON in Play
To: play-framework@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
> So, should I implement it in some different way, or can my original pull
> request be accepted?
Sorry, you must definitely implement this in a different way. I agree
that it would be an interesting optimization but it shouldn't be tied
to any Plugin concept (and neither to the application lifecycle).
Please think about the Json support as a separate library.
On Thu, May 31, 2012 at 11:59 AM, James Roper <jrop...@gmail.com> wrote:
> Hey all,
>
> I'd like to address the topic of JSON parsing in Play again. =A0Just to p=
ut
> some hard numbers on this, yesterday, unrelated to play framework, I was
> looking at some code that someone told me was going much slower than
> expected. =A0It was taking about 120 milliseconds to do something that th=
ey
> expected to only take a few milliseconds. =A0We quickly determined that t=
he
> major part of the issue was that they weren't reusing the Jackson
> ObjectMapper. =A0Once they reused the Jackson ObjectMapper, the time of t=
his
> thing (including the IO involved in this operation) went down to 5
> milliseconds. =A0So you can see that creating an ObjectMapper each time y=
ou
> need to use it can have a massive performance impact.
>
> I submitted this pull request, but it was rejected because it made json
> support a "plugin":
>
> https://github.com/playframework/Play20/pull/225
>
> Actually, I wasn't interested in making JSON support a plugin, all I want=
ed
> was the ability to initialise an ObjectMapper on application start,
> and=A0reinitialise=A0it each time the application is updated (in developm=
ent,
> this is needed, because Jackson might not pick up changes in annotations)=
.
> =A0The only way I can see for an internal component in play to hook into =
play
> to do this is to implement the Plugin interface, from where it gets notif=
ied
> of application start events. =A0This is the same way that other core non
> plugin components of Play seem to do it. =A0In fact, I put the JSON plugi=
n
> into Plays own play.plugins file, which means it's impossible to disable
> it... which means it's not really a plugin at all, it's just using the
> plugin mechanism to hook into application start events. =A0I would have
> thought this is the sensible way to go about doing that, am I wrong? =A0I=
f I
> am wrong, what is the correct way for a core play component to hook into
> application start events?
>
> I also wanted to provide a way to configure the ObjectMapper play uses (f=
or
> example, to register custom serialisers/deserialisers), which also requir=
es
> doing things on application start... and using the Plugin interface seeme=
d
> to be the right way to do this too.
>
> Also, Scala JSON support is already using a singleton instance, though
> perhaps we want to provide a mechanism for configuring the ObjectMapper i=
n
> Scala, but I think this is a separate issue, because the code bases in bo=
th
> the Java and the Scala support are completely different.
>
> So, should I implement it in some different way, or can my original pull
> request be accepted?
>
> Cheers,
>
> James
>
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/zsJdd-rJ-sMJ.
> To post to this group, send email to play-framework@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framework+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=3Den.
--=20
Guillaume Bort, http://guillaume.bort.fr