JBoss.org Community Documentation
Resource environment references are elements that refer to administered objects that are associated with a resource (for example, JMS destinations) using logical names. Resource environment references are defined by the resource-env-ref
elements in the standard deployment descriptors. The Deployer
binds the resource environment references to the actual administered objects location in the target operational environment using the jboss.xml
and jboss-web.xml
descriptors.
Each resource-env-ref
element describes the requirements that the referencing application component has for the referenced administered object. The resource-env-ref
element consists of the following child elements:
An optional description element that provides the purpose of the reference.
A
resource-env-ref-name
element that specifies the name of the reference relative to the java:comp/env
context. Convention places the name in a subcontext that corresponds to the associated resource factory type. For example, a JMS queue reference named MyQueue
should have a resource-env-ref-name
of jms/MyQueue
.
A
resource-env-ref-type
element that specifies the fully qualified class name of the referenced object. For example, in the case of a JMS queue, the value would be javax.jms.Queue
.
Example 4.15, “An example ejb-jar.xml resource-env-ref fragment” provides an example resource-ref-env
element declaration by a session bean. Example 4.16, “ENC resource-env-ref access code fragment” gives a code fragment that illustrates how to look up the StockInfo
queue declared by the resource-env-ref
.
<session> <ejb-name>MyBean</ejb-name> <!-- ... --> <resource-env-ref> <description>This is a reference to a JMS queue used in the processing of Stock info </description> <resource-env-ref-name>jms/StockInfo</resource-env-ref-name> <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type> </resource-env-ref> <!-- ... --> </session>
Example 4.15. An example ejb-jar.xml resource-env-ref fragment
InitialContext iniCtx = new InitialContext(); javax.jms.Queue q = (javax.jms.Queue) envCtx.lookup("java:comp/env/jms/StockInfo");
Example 4.16. ENC resource-env-ref access code fragment