Sorry, you must definitely implement this in a different way. I agree
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. Just to put
> 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. It was taking about 120 milliseconds to do something that they
> expected to only take a few milliseconds. We quickly determined that the
> major part of the issue was that they weren't reusing the Jackson
> ObjectMapper. Once they reused the Jackson ObjectMapper, the time of this
> thing (including the IO involved in this operation) went down to 5
> milliseconds. So you can see that creating an ObjectMapper each time you
> 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 wanted
> was the ability to initialise an ObjectMapper on application start,
> and reinitialise it each time the application is updated (in development,
> this is needed, because Jackson might not pick up changes in annotations).
> The 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 notified
> of application start events. This is the same way that other core non
> plugin components of Play seem to do it. In fact, I put the JSON plugin
> 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. I would have
> thought this is the sensible way to go about doing that, am I wrong? If 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 (for
> example, to register custom serialisers/deserialisers), which also requires
> doing things on application start... and using the Plugin interface seemed
> 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 in
> Scala, but I think this is a separate issue, because the code bases in both
> 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=en.