|
A High Level View of an EJB Conversation
|
|
-
Finding the bean
-
EJB specification mentions two ways in which a client can find a bean
-
JNDI API provides a uniform interface to naming and directory services.
-
A naming service is a service that associates a Symbolic Name with an object
-
Domain Name Service is a commonly used naming service that is used to transfer symbolic machine names into numeric IP addresses.
-
Previous model of DNS, needed to maintain a file containing a list of symbolic host names along with the numeric IP addresses that they should resolve to.
-
Problems in this approach:
-
If the /etc/hosts/file developed errors, couldn’t resolve symbolic names.
-
Needed to maintain the change of addresses when new machines were added.
-
If a machine did not appear in the /etc/hosts file, need to know its numeric IP address to connect to it.
-
Using DNS approach allows you to avoid many of these annoyances. It works as follows:
-
A client makes a query to a DNS server
-
If the DNS server knows how to resolve the address, it returns the address.
-
If the DNS server does not know how to resolve the address, it provides the query to another DNS server
-
Once the server is able to resolve the name, it returns the address to the client. Typically, it also caches the result so that, if the request is made again, it can be handled immediately.
-
JNDI provides a uniform interface to naming services.
-
JNDI client uses the Server’s SPI (Server Provider Interface) to access its services.
-
A Java client can use JNDI to lookup an EJB component.
-
The JNDI call returns a reference to an object implementing the EJB component’s “home” interface, which can then be used to gain access to the EJB object itself.
-
The other way to find an EJB component is to use CORBA’s Common Object Services (COS) naming service.
-
COS refers to a group of Services, including naming, that is provided as part of the CORBA services specification.
-
In addition to suing COS naming directly, can make use it via JNDI.
-
Getting access to a bean
-
The result of the naming lookup is a reference to an object implementing the EJB components home interface
-
A client uses the home interface to look up existing EJB instances, or to create new ones.
-
This lookup result in a reference to an object that implements the EJB object’s remote interface.
-
The client uses the remote interface to interact with the EJB objects on the server.
|