Nathan, you're right about that. Configuring anything with Guice is as simple as bind the abstraction to the implementation. It's not different with Jersey. In Jersey 1.x it worked like that. The actual problem is that Jersey 2 does not provide integration with Guice yet. I'm stuned that Jersey just released the version 2.4 (yesterday) and they did not solved this issue yet! I'm considering changing to Resteasy...--
D. ReinertOn Sun, Sep 22, 2013 at 8:43 PM, Jones, Nathan <Nathan...@airnz.co.nz> wrote:I haven't had experience with both Guice and Jersey but for Guice and CXF we manually registered a JacksonJsonPovider using the CXF Guice module (https://code.google.com/p/guice-cxf/). Doing something like this should be very straight forward with Jersey since this is a more populate JAX-RS implementation. The Javadoc on com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider might give you some hints.
Note that we never use an object mapper directly; we only create an instance once to be used by the JacksonJsonPovider and then just return Jackson-annotated objects from our JAX-RS endpoints.
- Nathan
________________________________________
From: Danilo Reinert [mailto:danilo...@gmail.com]
Sent: Saturday, 21 September 2013 8:57 a.m.
To: us...@jackson.codehaus.org
Subject: [jackson-user] Configure ObjectMapper using Jersey and Guice
Good planets are hard to find - please think of the environment before you print this email.
I'm trying to customize the ObjectMapper and Reader to be used in my Jersey/Guice Application.
I've already create a Guice Provider for ObjectMapper and Reader based on this topic http://stackoverflow.com/questions/16757724/how-to-hook-jackson-objectmapper-with-guice-jersey , but it didn't work.
I'm using jackson 2.2.3, jersey 2.2 and guice 3.0.
How can I accomplish that?
--
D. Reinert
____________________________________________________________________
CAUTION - This message may contain privileged and confidential
information intended only for the use of the addressee named above.
If you are not the intended recipient of this message you are hereby
notified that any use, dissemination, distribution or reproduction
of this message is prohibited. If you have received this message in
error please notify Air New Zealand immediately. Any views expressed
in this message are those of the individual sender and may not
necessarily reflect the views of Air New Zealand.
_____________________________________________________________________
For more information on the Air New Zealand Group, visit us online
at http://www.airnewzealand.com
_____________________________________________________________________
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Christopher, I've read about the H2K integration. It seems too "workaround" to me adding a whole project only for the integration.
But I didn't know that "from the Jersey point of view, they have 'solved' this issue." Now, I'm horrified!.
H2K is a dependency injection framework, and if you use it along with Guice you'll be forced to use a particular H2KInject annotation when injecting by H2K is desired/necessary. This is annoying!!!!
Tatu, I have this same feeling about Jersey. In the transition period, it was not been updated for at least 4 months. And now, significant changes are happening, for worse. This centralizing corporate path Jersey is tracking is harmful.About my question on jersey forum, no answers were given yet. This unfortunate behavior is forcing me to try other projects.
Resteasy has been evolving in a great rhythm. As I'm not a dropwizard user, I'll try to migrate my JAX-RS impl to Resteasy and experiment it for a few months. I've read good things about this new version 3. The documentation is fair well. And it supports Guice! =)
Yeah, choice is good.
--
D. ReinertOn Tue, Sep 24, 2013 at 4:10 PM, Tatu Saloranta <ta...@fasterxml.com> wrote:On Mon, Sep 23, 2013 at 9:35 AM, Christopher Currie <chris...@currie.com> wrote:On Mon, Sep 23, 2013 at 8:42 AM, Danilo Reinert <danilo...@gmail.com> wrote:
Christopher, I've read about the H2K integration. It seems too "workaround" to me adding a whole project only for the integration.Jersey 2 already depends on HK2, so I don't think you're actually adding another project. AFAICT, HK2 is what makes all of the mechanics of method interception for @QueryParam and @Context arguments work, as opposed to their own implementation that was used in Jersey 1.That said, it looks like the HK2 bridge is not sufficient for Guice integration to work, because, as you say, it's held up by the Jersey team. [1][2]But I didn't know that "from the Jersey point of view, they have 'solved' this issue." Now, I'm horrified!.I apologize, I didn't mean to speak for the Jersey team. I was simply extrapolating from what I observed, and how I would build a similar system. It's similar to choosing a logging API; at some point you either have to pick one, or abstract them all into a common API. The fact that their choice has compatibility challenges they haven't solved was a point I had missed.They may have plans to do the abstraction, in order support Guice directly; or they may feel that the solution is to refactor their code to allow the HK2 bridge to work. It's impossible to say at this time, since the amount of feedback coming from the development team is fairly low.H2K is a dependency injection framework, and if you use it along with Guice you'll be forced to use a particular H2KInject annotation when injecting by H2K is desired/necessary. This is annoying!!!!This does appear to be a significant weakness, but without it I would expect you'd run into circular dependencies (HK2 can't find a binding, so it asks Guice, who doesn't have it either, and around you go).The point seems moot, though, since the Guice bridge doesn't appear to be enough at this time.All this to say: this is a bit off-topic for the Jackson list. Guice is supported by other JAX-RS implementations, including Jersey 1. It appears you're faced with a choice between Guice and Jersey 2, unless you want to volunteer the time to work in the Jersey 2 code base for the support that you need.Also: although moving to another JAX-RS implementation has its costs, you could also consider RESTeasy, or CXF. The only (?) concern I would have is that DropWizard is based on Jersey, but it uses Jersey 1 anyway.
As much as I respect Jersey for its past work as RI & high-quality general-purpose implementation, I am beginning to feel that it's been "Oracleized", meaning that it's become more of a pawn of corporate strategy, victim of Not-Invented-Here & mandates on components to use.
Instead of trail-blazing using best available components; not just ones that Mother Corporation provides. Things like using MOXy as default JSON provider, some DI framework no one else uses; java.utl.logging (ditto), and the list goes on.
Given this, investigating other less-visible JAX-RS choices does not seem like a bad idea.I would personally be interested in how other choices compare. Choice is good; as is exercising it.
-+ Tatu +-
--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To post to this group, send email to jackso...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I thought I might share my experience with RESTEasy in this discussion. We've been using RESTEasy with Jackson for the past 2 years and a half, since 2.0.1. We've rarely had any issues with its integration with Jackson or DI framework (we have our own DI framework). In the 2 year history, we've upgraded to Jackson 2 and RESTEasy 3 without any major hurdle.
We didn't have any problem using new features, like GZIP support, pre-emptive authentication and other things that are not necessarily implemented by RESTEasy. Also, its client-side implementation using dynamic proxy is a charm to work with, given that you use an interface to declare your JAX-RS Annotations.
Hope this helps,
Pascal.
It should be fine to inject ObjectMapper instance
JAX-RS provider is sort of orthogonal to configuration of ObjectMapper, so using differently configured instance is a supported (and anticipated) use case.
--
You received this message because you are subscribed to a topic in the Google Groups "jackson-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jackson-user/PUicZLhZ8jg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jackson-user...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.