Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-2554

ProcessInjectionPoint.setInjectionPoint() doesn't work in some environment.

XMLWordPrintable

      Issue edited for clarity
      This issue is a follow up on this forum thread - read it for more details.

      In short the request is to fire ProcessInjectionPoint event in servlet environment for injection into components supporting injection that aren't beans (such as Servlets).

      Notably, this request stands outside CDI specification as the spec itself only speaks of PIP events for beans, interceptors and decorators in general and expands on this in EE environment (fires PIP for Java EE components supporting injection). It does not mention servlet environment at all.

      Following text and code is copied from the forum post

      _My project use weld-se-core and weld-servlet-core that version is 3.0.5.Final. I use undertow(eagerFilterInit=true) as project servlet container. I have some servlets that were injected some services. The CDI injection are available in Servlets, Filters and Listeners, but the ProcessInjectionPoint.setInjectionPoin() doesn't work on servlet's injection point, but work fine on the other beans.

      The code snippet is as follows:_

      public class SomeExtension implements Extension{
      
           void onProcessInjectionPoint(@Observes ProcessInjectionPoint<?, ?> pip, BeanManager beanManager) {
      
                //...
                pip.setInjectionPoint(new SomeInjectionPoint()); // this was work fine in common beans, but doesn't work on the servlet injection, use configureInjectionPoint().addQualifiers()  is similar.
      
           }
      
      }
      
       
      
      @ApplicationScoped
      @WebServlet(urlPatterns = "/some")
      public class SomeServlet extends HttpServlet {
      
           @Inject
           SomeService someService; // in this inject, I add some additional qualifiers, but it doesn't work.
      
      }
      
       
      
      @ApplicationScoped
      public class SomeService  {
      
           @Inject
           OtherService otherService; // in this inject, I add some additional qualifiers,  it work fine. use same Extension observes method.
      
      }
      

              Unassigned Unassigned
              finesoft-1 bingo chen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: