The resource references are another examples of environment entries. For such entries, using subcontexts is recommended:
java:comp/env/jdbc for references to DataSources objects.
java:comp/env/jms for references to JMS connection factories.
In the standard deployment descriptor, the declaration of a resource reference to a JDBC connection factory is:
<resource-ref> <res-ref-name>jdbc/AccountExplDs</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> |
And the bean accesses the datasource as in the following:
InitialContext ictx = new InitialContext(); DataSource ds = ictx.lookup("java:comp/env/jdbc/AccountExplDs"); |
Binding of the resource references to the actual resource manager connection factories that are configured in the EJB server is done in the JOnAS-specific deployment descriptor using the jonas-resource element.
<jonas-resource> <res-ref-name>jdbc/AccountExplDs</res-ref-name> <jndi-name>jdbc_1</jndi-name> </jonas-resource> |