users@hk2.java.net

Re: Re: Method Interception with HK2 and Guice

From: <cdr53x_at_free.fr>
Date: Wed, 12 Mar 2014 15:32:42 +0000 (UTC)

Hi,

I just wanted to let you know that I finally managed to solve this
issue.
In order to make it work I had to migrate to jersey 2.6, HK2 2.3.0-b01
and Guice bridge with the same version

Basically my code :
- uses Guice for my domain code injection and method interception ,
even the creation of the HK2 InterceptionService instance
- uses HK2 to bind an HK2 InterceptionService instance in REST
ressources
- uses bi-directional guice/hk2 bridge , the InterceptorService using
code injected by Guice

Also I found that the InterceptionService binding does not work unless
jersey is upgraded to 2.6 ( maybe 2.5.1 works, but 2.5 definitely does
not).
So it seems that AOP cannot be used with Jersey 2.5 and lower version.
I don't know if this is a jersey or HK2 issue ...

Maybe out of topic, and this is only my point of view but compared to
Guice, HK2 is really too complex. I ended up by setting up the
InterceptionService with Guice and then simply registering it's
instance in HK2. The other way around seemed like a pure nightmare to
me.
Anyway I really appreciate the fact that HK2 provides the bridges (
I'll try the spring bridge in the future) , even if they have their
issues.
At least they really work fine if one has to integrate a guice injected
domain into Jersey REST exposition !

Thanks for reading