[weld-dev] Why does org.jboss.weld.test.core.TestCore only support qualified injection?

Johan Eltes johan.eltes at callistaenterprise.se
Sun Dec 27 05:02:21 EST 2009


org.jboss.weld.test.core.TestCore is used by the org.jboss.weld.test.junit.CDIRunner to inject the dependencies of the test case. However, it only supports injection of qualified fields. As a side effect, dependencies declared as concrete classes can not be injected, since qualifiers only make sense to interface/abstract dependency declarations:

package org.jboss.weld.test.core;
...

public class TestCore {
...
 private void injectField(Field field, Object target) throws Exception
   {
      if (!hasBindTypeAnnotation(field.getAnnotations()))
      {
         return;
      }
      if (!field.isAccessible())
      {
         field.setAccessible(true);
      }
      Object injectable = getInstanceByType(field.getType(), field
            .getAnnotations());

      if (injectable != null)
      {
         field.set(target, injectable);
      }
   }

Just wondering the value of this restriction?

/Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20091227/e84991a1/attachment.html 


More information about the weld-dev mailing list