dev@jersey.java.net

Re: [Jersey] Spring framework support for Jersey 2

From: miroslav fuksa <miroslav.fuksa_at_oracle.com>
Date: Fri, 03 May 2013 21:18:30 +0200

Hi Marko,

please see my comments below.

thanks
Mira

On 2.5.2013 16:34, Marko Asplund wrote:
> Hi Mira,
>
> Thanks for the feedback!
>
> I studied the build log for the failed build but I couldn't find any
> reference to the two projects added in my pull request.
> Could the build issue be caused by something else?
>
> The added modules are:
> jersey-spring
> jersey-examples-helloworld-spring
Currently the project needs to be build with the profile "promoted". So,
to build the project you need to run maven:
mvn clean install -P attach-src,all-tests,promoted

I have fixed the configuration on buildhive, so now the problem with
missing artifacts should not appear. I have scheduled a new build. Can
you build the project locally on your machine using the profiles above?

>
> As for implementing support for Spring to inject Jersey injections,
> I've a few questions.
> Are you referring to enabling Spring beans to be injected with
> dependencies from the Jersey service registry using JSR 330 injection
> annotations? So, basically I'd inject beans registered with the Jersey
> HK2 ServiceLocator in Spring beans annotated with JSR 330 annotations,
> right?
Yes, we need to support these injections.

In Jersey 1 we are able to inject Spring beans into Jersey resource
classes. This is what your implementation is doing using a
AutowireInjectionResolvser. In Jersey 1 we are also able to use Spring
beans as Resource classes. This is what should be also supported in
Jersey 2. It means you deploy a JAX-RS application and resource classes
will be managed by Spring (they are extracted from Spring context, their
lifecycle is managed by Spring). This is what is also covered in Jersey
1 tests. If we use Spring beans as resource classes we will still need
to support the functionality as for other classes. Therefore we will
need to support JSR 330 injections in these classes (including @Context
injection defined by the JAX-RS 2.0 spec).

I am not sure whether such a implementation will not require more
changes to the Jersey core. There might be a need to add new extension
points to allow this particular integration.

>
> I'll have a look at the Jersey 1 Spring integration tests.
>
>
> thanks,
>
> marko