In Chapter 3, we described two fundamental roles in the RMI environment: the client of the remote object, and the object itself, which acts as a kind of server or service provider. These two roles exist in the EJB environment as well, but EJB adds a third role, called the container provider . This is responsible for implementing all the extra services for an EJB object mentioned earlier: transaction processing, security, object persistence, and resource pooling. If you’re familiar with CORBA, you can think of the EJB container as being roughly equivalent to the ORB in CORBA, with a few of the CORBA services thrown in as well. In EJB, however, the container is strictly a server-side entity. The client doesn’t need its own container to use EJB objects, but an EJB object needs to have a container in order to be exported for client use. Figure 8-1 shows a conceptual diagram of how the three EJB roles interact with each other.
Figure 8-1. The basic roles in an EJB environment
The EJB Client
An EJB client uses remote EJB objects to access data, perform tasks, and generally get things done. In the EJB environment, the first action a client performs is to find the home interface for a type of EJB object that it wants to use. This home interface is a kind of object factory, used to create new instances of the EJB type, look up existing instances (only when using entity EJB objects, ...