user manual

Chapter 23: Using JMS 251
Connecting to JMS Connection Factories from Application Components
...
<resource-ref>
<res-ref-name>jms/MyJMSQueueConnectionFactory</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-env-ref>
<res-env-ref-name>jms/MyJMSQueue</res-env-ref-name>
<res-env-ref-type>javax.jms.Queue</res-env-ref-type>
</resource-env-ref>
...
</session>
Although this portable descriptor provides some logical names for the
resources, they still need to bound to the actual JNDI name of the deployed
datasource object. This is accomplished with the ejb-borland.xml descriptor,
which binds the logical names with their JNDI locations. Like we did with JDBC
datasources, we will use the <resource-ref> element of the ejb-borland.xml
descriptor to do this:
<session>
<ejb-name>session_bean</ejb-name>
...
<resource-ref>
<res-ref-name>jms/MyJMSQueueConnectionFactory</res-ref-name>
<jndi-name>serial://resources/qfc</jndi-name>
</resource-ref>
Note that the <res-ref-name> elements from both descriptor files are identical.
Now, we need to bind the logical name for the queue (or topic, whatever the
case may be) to its JNDI name. We accomplish this with the <resource-env-ref>
element of the Borland-specific descriptor. It's DTD element looks like the
following:
<!ELEMENT resource-env-ref (resource-env-ref-name, jndi-name)>
Like the Resource Reference element, we specify two things:
resource-env-ref-name: this is the logical name of the topic or queue, and
its value must be identical to the value of the <res-env-ref-name> in ejb-
jar.xml.
jndi-name: this is the JNDI name of the topic or queue that resolves the
logical name.
So, in order to complete the connection entry, we add the Resource
Environment Reference to the descriptor, yielding:
<session>
...