jersey
  1. jersey
  2. JERSEY-1957

Implement Spring integration for Jersey 2

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.2
    • Component/s: extensions
    • Labels:
      None

      Description

      Spring integration exists for Jersey 1, but not the new version.

      Integrate Jersey 2 with Spring framework with the following features:
      1) inject Spring beans into Jersey managed JAX-RS resource classes
      2) allow JAX-RS resource classes to be managed by Spring instead of Jersey

      DEMO: Run an example using Spring injection. Show documentation in user guide.

        Issue Links

          Activity

          Hide
          marko asplund added a comment -
          Show
          marko asplund added a comment - This feature has been discussed on the Jersey users mailing list. A prototype can be found here: https://github.com/marko-asplund/jersey/tree/master/ext/jersey-spring/jersey-spring https://github.com/marko-asplund/jersey/tree/master/examples/helloworld-spring
          Hide
          marko asplund added a comment -

          This issue has been discussed on the Jersey users mailing list during 2013 may-july.
          The following functional requirements were specified for Jersey Spring integration:

          1. inject Spring beans into jersey JAX-RS resource classes and providers (filters, interceptors, ...)
            • injection by @Autowire
            • injection by @Inject
          2. allow JAX-RS resource classes and providers to be managed by Spring instead of Jersey
          3. inject Jersey injections into the Spring managed JAX-RS resource classes and providers (these mentioned in point 2)
            • inject by @Inject and @Context (this is needed as resource classes must still be compliant with JAX-RS spec which allows injection of JAX-RS providers be these annotations). This means Spring managed beans will support these injections.
            • and of course allow standard Spring injection for these Spring managed beans with @Autowire, definition by xml (applicationContext.xml), @Inject

          The prototype should satisfy these requirements.
          These features have been implemented and demonstrated in examples HelloWorldResource1 through HelloWorldResource3.

          About scopes: Spring manages bean lifecycle for Spring managed beans.
          Jersey scopes map to Spring scopes in the following manner:

          • @RequestScope ==> scope="request" or @Scope("request")
          • @Singleton ==> scope="singleton" or @Scope("singleton")
          • @PerLookup ==> scope="prototype" @Scope("prototype")

          Here's how to build the prototype and examples:

          # building the Jersey Spring integration
          git clone https://github.com/marko-asplund/jersey
          cd jersey/ext/jersey-spring
          mvn clean install
          
          # building the Jersey Spring integration example web app
          cd ../../examples/helloworld-spring
          mvn clean install
          

          NOTE: configure log level for org.glassfish.jersey.server.spring category to ALL in your application server to see log messages about Jersey Spring integration.
          (Scope functionality can be validated e.g. by enabling debug logging as described above and tracing object identity in the log)

          Feedback is welcome!

          Show
          marko asplund added a comment - This issue has been discussed on the Jersey users mailing list during 2013 may-july. The following functional requirements were specified for Jersey Spring integration: inject Spring beans into jersey JAX-RS resource classes and providers (filters, interceptors, ...) injection by @Autowire injection by @Inject allow JAX-RS resource classes and providers to be managed by Spring instead of Jersey inject Jersey injections into the Spring managed JAX-RS resource classes and providers (these mentioned in point 2) inject by @Inject and @Context (this is needed as resource classes must still be compliant with JAX-RS spec which allows injection of JAX-RS providers be these annotations). This means Spring managed beans will support these injections. and of course allow standard Spring injection for these Spring managed beans with @Autowire, definition by xml (applicationContext.xml), @Inject The prototype should satisfy these requirements. These features have been implemented and demonstrated in examples HelloWorldResource1 through HelloWorldResource3. About scopes: Spring manages bean lifecycle for Spring managed beans. Jersey scopes map to Spring scopes in the following manner: @RequestScope ==> scope="request" or @Scope("request") @Singleton ==> scope="singleton" or @Scope("singleton") @PerLookup ==> scope="prototype" @Scope("prototype") Here's how to build the prototype and examples: # building the Jersey Spring integration git clone https: //github.com/marko-asplund/jersey cd jersey/ext/jersey-spring mvn clean install # building the Jersey Spring integration example web app cd ../../examples/helloworld-spring mvn clean install NOTE: configure log level for org.glassfish.jersey.server.spring category to ALL in your application server to see log messages about Jersey Spring integration. (Scope functionality can be validated e.g. by enabling debug logging as described above and tracing object identity in the log) Feedback is welcome!
          Hide
          cowwoc added a comment -

          Please link this issue to JERSEY-1950 as both should be solved in a consistent manner.

          Show
          cowwoc added a comment - Please link this issue to JERSEY-1950 as both should be solved in a consistent manner.
          Hide
          marko asplund added a comment -

          The jersey-spring prototype repository (https://github.com/marko-asplund/jersey) now includes two alternative implementations in different branches:

          • "feature/JERSEY-1957" branch: uses the upcoming HK2 v2.2.0 and spring-bridge
          • "master" branch: the original prototype without spring-bridge
          Show
          marko asplund added a comment - The jersey-spring prototype repository ( https://github.com/marko-asplund/jersey ) now includes two alternative implementations in different branches: "feature/ JERSEY-1957 " branch: uses the upcoming HK2 v2.2.0 and spring-bridge "master" branch: the original prototype without spring-bridge
          Hide
          gicappa added a comment -

          Has the inetgration work ended ? When do you think it will be generally available for public?
          Thanks!

          Show
          gicappa added a comment - Has the inetgration work ended ? When do you think it will be generally available for public? Thanks!
          Hide
          Jakub Podlesak added a comment -

          Spring integration is available in 2.2 version, please see https://jersey.java.net/documentation/latest/spring.html for some more details.

          Show
          Jakub Podlesak added a comment - Spring integration is available in 2.2 version, please see https://jersey.java.net/documentation/latest/spring.html for some more details.

            People

            • Assignee:
              Miroslav Fuksa
              Reporter:
              marko asplund
            • Votes:
              4 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 3 hours
                3h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours Time Not Required
                2h