eWebProgrammer
Distributednetworks GofPatterns
prev prev
  Course navigation
    Finding the home object
Lookup
EJB Context Lookup
javax.naming.Context initialContext = new javax.naming.InitialContext();
The JNDI initialContext() method returns the initial context. The initial context is equivalent to the root directory of the JNDI Name Service.
The result is stored in the variable initialContext.
Object objRef = initialContext.lookup("MyHello")
Looks up the "MyHello" service in the initial context and returns the remote reference (the stub) for the Hello bean's home object. This reference is stored in objRef.
javax.rmi.PortableRemoteObject.narrow(
Transforms the actual remote reference type, stored in objRef, to a HelloHome reference.
HelloHome home
home will contain the remote reference (the stub) to the home object when the statement is completed.
The stub implements the HelloHome interface.
(HelloHome)
A Java cast to the correct type.
HelloHome.class
The class of the return from lookup. This is required by the narrow()method.
  Course navigation