|
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3) B14428-01 |
|
![]() Previous |
![]() Next |
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-29 shows how to use annotations and dependency injection to access an EJB 3.0 resource manager connection factory.
Example 19-30 shows how to use the initial context to look up an EJB 3.0 resource manager connection factory.
Example 19-30 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".