The following application-client.xml declares an env-entry, ejb-ref and resource-ref.
<?xml version="1.0" encoding="UTF-8"?>The env-entry can be looked up with name "java:comp/env/adminEmail", or injected into the application client main class or its superclasses. For example:
<application-client xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application-client_5.xsd">
<display-name>A sample application client</display-name>
<env-entry>
<description>admin email</description>
<env-entry-name>adminEmail</env-entry-name>
<env-entry-value>admin@example.x</env-entry-value>
</env-entry>
<ejb-ref>
<ejb-ref-name>ejb/testBean</ejb-ref-name>
<remote>test.TestRemoteInterface</remote>
<ejb-link>TestBean</ejb-link>
</ejb-ref>
<resource-ref>
<res-ref-name>HRDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<mapped-name>jdbc/__default</mapped-name>
</resource-ref>
</application-client>
@Resource(name="adminEmail")The ejb-ref and resource-ref can be looked up with names "java:comp/ejb/testBean" and "java:comp/env/HRDS", respectively.
//use static modifier in application client main class only
private static String adminEmail;
The reason I include ejb-ref and resource-ref is to show how they fit in descriptors. In Java EE 5 and later, it is easier to use @EJB and @Resource to declare and inject them into component classes.