4 Replies Latest reply on Dec 15, 2005 11:08 PM by Phillip Warner

    Domain-specific information in @Resource

    Phillip Warner Newbie

      (Couldn't decide whether to include here or in the Messaging forum...ultimately decided to place here. Sorry if it's misplaced.)

      I'm using @Resource to inject a reference to a JMS destination. The JMS spec. indicates a preference to use the "Common" interfaces (see pp. 75-76, 79-80) which in this case would be Destination (where Queue or Topic would be the domain-specific implementation).

      In a -service.xml for specifying a JMS destination, i.e.,

       <mbean code="org.jboss.mq.server.jmx.Queue"
       name="jboss.mq.destination:service=Queue,name=myDestination">
       <attribute name="JNDIName">queue/myDestination</attribute>
       <depends optional-attribute-name="DestinationManager">
       jboss.mq:service=DestinationManager
       </depends>
       </mbean>
      

      I specify the Queue or Topic MBean implementation. This works just fine. However, when I attempt to inject the resource, i.e.,
       @Resource(name="myDestination")
       private Destination myDestination;
      

      the container complains that it cannot find the resource. After trying permutations on the name, including: name="queue/myDestination", I found a workaround, which is:

       @Resource(name="myDestination",type=javax.jms.Queue.class)
       private Destination myDestination;
      


      This defeats the whole purpose of using the common interface, where I (seemingly?, or assuming?) can change the underlying destination to Topic (or Queue if otherwise) as I deem necessary, in the -service.xml.

      Am I missing something?

      (NOTE: I've since changed a few things where this is now irrelevant, but it seems like an issue that should(?) be addressed.

      Cheers!