Hi there,
While reading through page# 416 of
EJB Code spec (Section: 16.5.1.2 EJB Reference Programming Interfaces), I came across an example which looks like this:
1 @EJB(name=�ejb/EmplRecord�, beanInterface=EmployeeRecordHome.class)
2 @Stateless public class EmployeeServiceBean
3 implements EmployeeService {
4 public void changePhoneNumber(...) {
5 ...
6 // Obtain the default initial JNDI context.
7 Context initCtx = new InitialContext();
8 // Look up the home interface of the EmployeeRecord
9 // enterprise bean in the environment.
10 Object result = initCtx.lookup("java:comp/env/ejb/EmplRecord");
11 // Convert the result to the proper type.
12 EmployeeRecordHome emplRecordHome = (EmployeeRecordHome)
13 javax.rmi.PortableRemoteObject.narrow(result,
14 EmployeeRecordHome.class);
15 ...
16 }
17 }
What I find puzzling here is that code is "injecting" EJB reference (line# 1) and then ALSO performing a JNDI Lookup (line# 10) - why? I thought we should be doing either of the two things and NOT both. Could someone shed some light on this, please? What am I missing here
Many thanks in advance!
Saeed