Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.1.0) Part Number B28221-02 |
|
|
View PDF |
Using EJB 3.0, you can look up a resource manage connection using resource injection (see "Using Annotations") or the InitialContext
(see "Using Initial Context").
Example 19-24 shows how to use annotations and dependency injection to access an EJB 3.0 resource manager connection factory.
Example 19-25 shows how to use the initial context to look up an EJB 3.0 resource manager connection factory.
Example 19-25 Looking Up an EJB 3.0 Resource Manager Connection Factory
@Stateless public class EmployeeServiceBean implements EmployeeService {
...
public void sendEmail(String emailAddress) {
InitialContext ic = new InitialContext();
Session session = (Session) ic.lookup("java:comp/env/mail/testMailSession");
...
}
}
For more information, see "Configuring the Initial Context Factory".