hk2
  1. hk2
  2. HK2-57

Integration with other DI providers

    Details

    • Type: Task Task
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.*
    • Fix Version/s: 2.1.*
    • Component/s: None
    • Labels:
      None

      Description

      HK2 needs to be able to delegate injection to other providers.

        Activity

        Hide
        tbeerbower added a comment -

        From Marek ...

        In Jersey 1.x, we have first consulted the external providers and only then fell back to the default Jersey injection.

        Additionally, there are several types of injection providers recognized by original Jersey 1.x code:

        • providers that instantiate and inject the component, but JAX-RS/Jersey injection is then performed by Jersey runtime as well as component lifecycle is managed by Jersey
        • providers that instantiate, inject and manage the injected component lifecycle, but JAX-RS/Jersey injection is then performed by Jersey runtime
        • providers that instantiate, inject and manage the injected component lifecycle, including JAX-RS & Jersey injection

        FWIW, I have also found a provider type that lets jersey instantiate, inject and manage the component and only wraps the component into a proxy, but I failed to find an external use case for this type of provider.

        ...it makes sense to distinguish between "eager" and "fallback" providers. Also, HK2 needs some strategy for instantiation of injected components. Sometimes the component should be provided by the external provider rather than instantiated directly, e.g. JAX-RS resources implemented as CDI managed beans or EJBs.

        Today, Jersey 2.x would typically do this to get a JAX-RS resource class instance:

        SomeResource resource = injector.inject(SomeResource.class);

        The above assumes that HK2 is able to decide who is responsible for creating/providing the instance, injecting it (fully or partially) and managing the instance lifecycle.

        Show
        tbeerbower added a comment - From Marek ... In Jersey 1.x, we have first consulted the external providers and only then fell back to the default Jersey injection. Additionally, there are several types of injection providers recognized by original Jersey 1.x code: providers that instantiate and inject the component, but JAX-RS/Jersey injection is then performed by Jersey runtime as well as component lifecycle is managed by Jersey providers that instantiate, inject and manage the injected component lifecycle, but JAX-RS/Jersey injection is then performed by Jersey runtime providers that instantiate, inject and manage the injected component lifecycle, including JAX-RS & Jersey injection FWIW, I have also found a provider type that lets jersey instantiate, inject and manage the component and only wraps the component into a proxy, but I failed to find an external use case for this type of provider. ...it makes sense to distinguish between "eager" and "fallback" providers. Also, HK2 needs some strategy for instantiation of injected components. Sometimes the component should be provided by the external provider rather than instantiated directly, e.g. JAX-RS resources implemented as CDI managed beans or EJBs. Today, Jersey 2.x would typically do this to get a JAX-RS resource class instance: SomeResource resource = injector.inject(SomeResource.class); The above assumes that HK2 is able to decide who is responsible for creating/providing the instance, injecting it (fully or partially) and managing the instance lifecycle.
        Hide
        tlcksnyder added a comment -

        reassign due to Tom leaving Oracle.

        Show
        tlcksnyder added a comment - reassign due to Tom leaving Oracle.
        Hide
        jwells added a comment -

        All requested integrations are available: CDI, Spring and Guice. Any further integration issues can be added as individual bugs

        Show
        jwells added a comment - All requested integrations are available: CDI, Spring and Guice. Any further integration issues can be added as individual bugs

          People

          • Assignee:
            jwells
            Reporter:
            tbeerbower
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: