users@jersey.java.net

Re: [Jersey] Jersey injection into spring managed beans

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 14 Jun 2010 18:04:37 +0200

Hi,

I think you are running into a similar issue to:

   https://jersey.dev.java.net/issues/show_bug.cgi?id=469

Namely currently Jersey does not integrate with the bean post
processor and Jersey only works with Spring for JAX-RS root resource
and provider classes (after it has obtained a reference from Spring).

I think this is something that should be possible to fix since we now
have a mechanism in place that used for EJB and CDI integration that
could also be with a Spring bean post processor. The only thing we may
have to watch out for is when Spring initializes singletons (it may do
it before the Jersey servlet is initialized, in which case we will
need to introduce a Jersey context listener).

Paul.


On Jun 14, 2010, at 5:21 PM, Camel Christophe wrote:

> Hello everybody,
>
> I'm using Jersey and I'm facing the following issue. When declaring a
> bean as a service with the @Service annotation, I would like to inject
> Jersey information into a field of that bean, like this:
>
> @Service
> public class AService {
>
> /**
> * I expect this field to be valuated automagically by jersey.
> */
> @Context
> private WadlApplicationContext wadlContext;
>
> public void foo() {
> if( wadlContext == null ) {
> System.out.println( "doesn't work");
> } else
> {
> System.out.println( "cool !");
> }
> }
> }
>
> But this doesn't work: the wadlContext is always null. Moreover, It's
> always the case with all jersey injectable properties.
>
> What should I do to make it work properly ?
>
> I'm using Jersey 1.0.3.1. I declare the spring servlet from
> jersey-spring package in my web.xml. Everything works fine except
> spring
> injection into full spring beans.
>
> Thanks for any help.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>