Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-178

Require container-provided Producer implementation to use getInjectionPoints()

    XMLWordPrintable

Details

    • Clarification
    • Resolution: Done
    • Minor
    • 1.1.PRD
    • 1.0
    • Portable Extensions
    • None
    • Release Notes

    Description

      A CDI extension should be able to turn a field of a into a CDI injection point as easily as by overriding the getInjectionPoints() method of the container-provided InjectionTarget implementation e.g.:

          event.setInjectionTarget(decorate(event.getInjectionTarget()));
      
      ...
      
          protected <T> InjectionTarget<T> decorate(final InjectionTarget<T> delegate)
          {
              return new ForwardingInjectionTarget<T>() {
      
                  @Override
                  public Set<InjectionPoint> getInjectionPoints() {
                      Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
                      injectionPoints.addAll(super.getInjectionPoints());
                      injectionPoints.addAll(); // additional injection points
                      return injectionPoints;
                  }
      
                  @Override
                  protected InjectionTarget<T> delegate() {
                      return delegate;
                  }
              };
          }
      

      However, the spec does not require the container-provided InjectionTarget implementation to make use of the getInjectionPoint() method when creating a new instance. As a result, the approach above may or may not work.

      Therefore, it is currently necessary for a portable extension to also provide an implementation of at least the inject() method (for field injection points) and implement the injection itself. This is problematic in 1.0 of the spec since a portable extension does not necessarily have access to the BeanManager instance of the BDA where the injection target is deployed, thus different visibility rules apply.

      Clarify that the container-provided implementation of the Producer interface should use the result of the getInjectionPoints() method as a source of information about the injection points to inject.

      Attachments

        Issue Links

          Activity

            People

              pmuiratbleepbleep Pete Muir (Inactive)
              rhn-engineering-jharting Jozef Hartinger
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: