I really dislike how Jersey 2 does 
DI: https://java.net/jira/browse/JERSEY-1933

In one project, I use Resteasy, with a custom Guice-based InjectorFactory; 
that doesn't provide fail-fast behavior given that resources are not 
instantiated at launch time but only lazily, as needed. I could probably 
open-source it (it'll be eventually open source as part of the project I'm 
using it on, but maybe I can open-source it on its own earlier), to make 
things simpler I only call injector#injectMembers and let Resteasy 
instantiate the classes (the problem with constructing with Guice is that 
it's mutually exclusive with non-@Inject constructors, such as simple 
constructors with @Context arguments as supported out of the box by JAX-RS, 
or it makes things much more complex with the need to detect whether Guice 
or Resteasy should instantiate the class depending the constructor(s)). It 
should be possible to have a fail-fast behavior by enumerating resources 
out of Resteasy's Registry after startup and validating their dependencies 
with Guice.

In another project, I tried providing singleton resources via the 
Application, getting the instances out of Guice (in Jersey 2.x, this only 
works if you use @com.google.inject.Inject, not @javax.inject.Inject, see 
Jersey bug linked above); you have fail-fast here because you instantiate 
all the resources in the Application's getSingletons()). I abandoned that 
option given that I wanted to use @javax.inject.Inject everywhere (leaving 
Guice as an implementation detail), and I already had something working by 
binding classes in HK2 to singleton instances retrieved out of Guice (the 
hk2-guice bridge didn't exist at the time, and even afterwards I couldn't 
integrate it into my app due to circular dependencies)

It also depends a lot how you're bootstrapping/deploying your JAX-RS 
application (I don't use a servlet container for instance, but instead 
setup an embedded HTTP server)

I don't use custom MembersInjector-s or Jrebel, so I can't comment about 
them.

On Wednesday, February 26, 2014 1:23:46 PM UTC+1, Jonas wrote:
>
> Hello,
>
> I wonder if there are any good jax-rs frameworks that works nicely with 
> guice. 
> We are currently using Jersey 2.x with guice but the support is very 
> limited. 
>
> Do you guys know of any framework that supports the following?
>
> - Fail fast behaviour for missing dependencies
> - Support for custom MembersInjector's
> - Jrebel support 
>
>
> Thanks!
> Jonas
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to