9 Replies Latest reply on May 16, 2013 11:51 AM by meetoblivion

    Using Weld to inject new JMS 2 API




      I'm adding support for JMS 2.0 in WildFly and one of its new features is an injectable JMSContext object[1].


      I'm following the Weld documentation to provide a portable extension[2] to HornetQ so that its JMSContext can be injected.

      However this fails because the call


      final AnnotatedType<JMSContext> at = bm.createAnnotatedType(JMSContext.class);

      final InjectionTarget<JMSContext> it = bm.createInjectionTarget(at);


      throws an exception:


      org.jboss.weld.exceptions.DefinitionException: WELD-001508 Cannot create an InjectionTarget from public abstract interface class javax.jms.JMSContext as it is an interface

                at org.jboss.weld.manager.SimpleInjectionTarget.&lt;init&gt;(SimpleInjectionTarget.java:65)

                at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:922)

                at org.hornetq.jms.cdi.HornetQCDIExtension.afterBeanDiscovery(HornetQCDIExtension.java:55



      I tried using a producer method[3] to create a HornetQJMSContext (the HornetQ implementation of the JMSContext interface) but that does not seem to be picked up.


      I'm sure I am missing something pretty obvious but how can I chose the HornetQ implemenation of JMSContext when I create a injection target for the JMSContext interface? Should I use alternatives for that (I'm not sure to understand how they'd help)?


      Any links to the right section to RTFM would be helpful





      [1] https://github.com/jmesnil/wildfly/blob/WFLY-509_JMS_2.0_support/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/messaging/jms/SimplifiedJMSClientTestCase.java#L65

      [2] https://github.com/jmesnil/hornetq/blob/JMS_2.0_API/hornetq-jms-cdi/src/main/java/org/hornetq/jms/cdi/HornetQCDIExtension.java#L51

      [3] https://github.com/jmesnil/hornetq/blob/JMS_2.0_API/hornetq-jms-cdi/src/main/java/org/hornetq/jms/cdi/JMSContextGenerator.java#L37