eWebProgrammer eweb  

Client View of Bean  «Prev  Next»
Lesson 4Finding the home object
ObjectiveDescribe how to look up the home object.

Finding and looking up the home object in EJB

The client acquires the remote reference to the home object from the Name Service. Assuming the name of the bean's service is "hello", the code fragment in the client will be:

javax.naming.Context initialContext = new javax.naming.InitialContext(); - The JNDI initialContext() method returns the initial context.

Jndi Initialcontext Lookup
This is not EJB code but rather JNDI, and this is all there is to it. Using JNDI is similar to looking up a file in a directory. Use the MouseOver to see the description of each piece of the code.

JNDI Advice

The EJB 1.1 spec. calls for use of the narrow() to ensure portability with RMI-IIOP[1] .
This is the predominant protocol RMI will use in the future.

Remote Method Invocations

A remote procedure call (RPC) is a procedural invocation from a process on one machine to a process on another machine. RPCs enable traditional procedures to reside on multiple machines, yet still remain in communication. They are a simple way to perform cross-process or cross-machine networking. A remote method invocation in Java takes the RPC concept one step further and allows for distributed object communications. RMI-IIOP allows you to invoke methods on objects remotely, not merely procedures. You can build your networked code as full objects. This yields the benefits of an object-oriented programming, such as inheritance, encapsulation, and polymorphism.
In the next lesson, you will be introduced to code in the client used to create the session bean.

[1] RMI-IIOP: The protocol, based on IIOP, that is planned for the implementation of RMI.