glassfish
  1. glassfish
  2. GLASSFISH-18379

Use JSR 330 annotations in GlassFish Connectors

    Details

    • Type: Task Task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: jca
    • Labels:
      None

      Description

      GlassFish modules should move away from using non standard Classes like Habitat and use standards based annotations and classes as specified by jsr 330(javax.inject.Inject, javax.inject.Provider etc.). To quote Jerome: "Classes like Habitat exposes too many APIs available to the users that makes the hk2 evolution very difficult. " Also some of the APIs are unclear (when to use habitat.getComponent() versus habitat.getByType() /habitat.getByContract() ).

      So, the first step is to move away from Habitat (where ever possible) and use jsr 330 interface and annotations.

      In order to do this, the hk2 team will be making the following changes to the GlassFish modules.

      1. Move away from org.jvnet.hk2.annotations.Inject to javax.inject.Inject

      1.1 We will convert

      @org.jvnet.hk2.annotations.Inject Foo foo

      to

      @javax.inject.Inject 
      Foo foo;

      1.2 We will convert

      @org.jvnet.hk2.annotations.Inject(name="foo") Foo foo

      to

      @javax.inject.Inject
      @javax.inject.Named("foo")
      Foo foo;

      1.3 We will convert

      @org.jvnet.hk2.annotations.Inject(optional=true) Foo foo

      to

      @javax.inject.Inject
      @org.jvnet.hk2.annotations.Optional
      Foo foo;

      1.4 We will convert

      @org.jvnet.hk2.annotations.Inject(name="foo", option=true) Foo foo

      to

      @javax.inject.Inject
      @javax.inject.Named("foo")
      @org.jvnet.hk2.annotations.Optional
      Foo foo;

      2. If we find that a class injects Habitat (or Services) and uses

      habitat.getByContract(Foo.class)

      or

      service.forContract(Foo.class).get()

      then we will do the following:

      2.1 Introduce a new injection:

      @javax.inject.Inject
      javax.inject.Provider<Foo>  fooProvider;

      2.2 replace the getBycontract() / forContract() calls with:

      fooProvider.get();

      3. If we find that a class...

      a) implements PostConstruct,
      b) injects Habitat (or Services) and
      c) uses habitat.getByContract(Foo.class) or services.forContract(Foo.class).get() in the postConstruct method,

      ...then we will do the following:

      3.1 replace the getBycontract() / forConttract() calls with:

      @javax.inject.Inject Foo foo;

      3.2 Obviously, we will talk to the module owner to find out why the injection was not made in the first place.

        Activity

        No work has yet been logged on this issue.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: