RE: Jackson extension performance question

2013-01-29 Thread Tim Peierls
You can have one ObjectMapper for all resources, and there is no need to use 
the Restlet Guice integration stuff. All you have to do is (somewhere) register 
a singleton LocalJacksonConverter with the Restlet Engine (and remove any 
existing JacksonConverter). See the method in my example annotated with @Inject.

Remove that method, the @Singleton class annotation, and the javax.inject 
imports from my example, and it should compile for you.

That's assuming you're using Jackson 2.x. If you're using Jackson 1.x, you'll 
have to adjust the imports and maybe some details of the ObjectMapper call.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3046540


RE: Jackson extension performance question

2013-01-28 Thread Richard Berger
Tim: 
After some additional searching, I think I can get by with a simple singleton 
OBJECT_MAPPER for each of my ServerResources.  It's probably not as good as one 
for all the ServerResources, but it is much simpler - and has already provided 
a fairly dramatic performance improvement.  So please don't spend any time on 
my behalf (I am too deep in your debt already :) ).
RB

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3046499


RE: Jackson extension performance question

2013-01-28 Thread Richard Berger
Tim:

Was trying to use your LocalJacksonConverter in a Restlet application that I 
have.  But I wasn't sure how to go about doing that.  I figured that I should 
start in my createInboundRoot with something like...

ObjectMapper objectMapper = new ObjectMapper();
LocalJacksonConverter localJacksonConverter = new 
LocalJacksonConverter(objectMapper);

But that was as far as I got (problem is my small brain, not your excellent 
code :) ).  I haven't used the Restlet Guice extension and my experience with 
injection is very limited.  Not counting vaccines :) :).

Thanks for your help,
RB

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3046480


Re: Jackson extension performance question

2013-01-28 Thread Jerome Louvel
Hi Pier Luigi and Tim,

I've entered a RFE to keep track of this Jackson optimization idea:
https://github.com/restlet/restlet-framework-java/issues/715

Thanks,
Jerome
--
http://restlet.com
http://twitter.com/#!/jlouvel




2013/1/18 Tim Peierls 

> Sorry, that link should be:
>
> http://tembrel.blogspot.com/2012/03/restlet-guice-extension-considered.html
>
> --
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3044419
>

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3046398

RE: Jackson extension performance question

2013-01-18 Thread Tim Peierls
Sorry, that link should be:

http://tembrel.blogspot.com/2012/03/restlet-guice-extension-considered.html

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3044419


RE: Jackson extension performance question

2013-01-18 Thread Tim Peierls
It's much better to re-use a single ObjectMapper instance, or a small set of 
differently configured ObjectMapper instances.

Here's an example of using dependency injection to provide a single 
ObjectMapper that is then re-used by JacksonRepresentations created by a JSON 
converter:

https://github.com/Tembrel/restlet-misc/blob/master/src/main/java/net/peierls/restlet/misc/LocalJacksonConverter.java

You can use the same approach in your resources by injecting a singleton 
ObjectMapper into your resources (see, for example, 
http://tembrel.blogspot.com/2012/03/restlet-guice-extension-considered.html) 
and using a custom extension of JacksonRepresentation that uses that 
ObjectMapper.

Note that I'm using Jackson 2.x with a Restlet Jackson extension that works 
with Jackson 1.9, which is why my extension of JacksonRepresentation doesn't 
simply override createObjectMapper().

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3044414