1 Reply Latest reply on Oct 21, 2019 9:19 AM by Matěj Novotný

    WeldJunit5 - bindResource and Wildfly resource injection- name versus lookup

    Ralf Battenfeld Apprentice

      Hi

       

      We use the weld test container a lot for testing our application, running in the latest wildfly release. We are extremely happy with weld for easy testing.

      There is one little thing which makes my life a bit harder or I didn't found so far the solution.

       

      I can bind a resource like this:

       

          @WeldSetup

          public WeldInitiator weld = WeldInitiator

                  .from(some.class)

                 .bindResource("DefaultManagedThreadFactory", new ManagedThreadFactory() {

       

                      @Override

                      public Thread newThread(Runnable r) {

                          return new Thread(r);

                      }

       

                  })

                  .inject(this)

                  .build();

       

      Weld will inject the resource if the lookup attribute is used @Resource(lookup = "DefaultManagedThreadFactory") but this is not runnable in wildfly, here I have to use the name attribute @Resource(name= "DefaultManagedThreadFactory")

       

      Is it possible to support also the name attribute for resource injections?

       

      Regards,

      Ralf