///////////////////////// code 1/////////////////////////////////
@EJB
private DocumentSession documentSessionLocal;
//////////////////////////////
////////////////////////////////code 2/////////////////////////
@EJB(name="ejb/EmplRecord", beanInterface=EmployeeRecordHome.class)
@Stateless
public class EmployeeServiceBean implements EmployeeService {
public void changePhoneNumber(...) {
// Obtain the default initial JNDI context.
Context initCtx = new InitialContext();
// Look up the home interface of the EmployeeRecord
// enterprise bean in the environment.
Object result = initCtx.lookup("java:comp/env/ejb/EmplRecord");
// Convert the result to the proper type.
EmployeeRecordHome emplRecordHome = (EmployeeRecordHome)
javax.rmi.PortableRemoteObject.narrow(result, EmployeeRecordHome.class);
...
}
}
///////////////////////////////////////code 2 end//////////////////////////////////////
Q1 There are two different codes i am having here.. code 1 is used to injection
ejb reference to a variable if that is the case then why we need to do look up as done in code 2. can't we just inject ejb reference in the variable and straight away used that.
Q2 Do we still have to use portableremoteobject.narrow ?