Enterprise beans—the home and component interfaces

Client applications do not interact with an enterprise bean directly. Instead, the client interacts with the enterprise bean through two intermediate objects that are created by the container from classes generated by a deployment tool—one of which classes implements the EJB home interface and the other the EJB component interface. As the client invokes operations using these intermediate objects, the container intercepts each method call and inserts the management services.

The home and component interfaces are implemented as Java™ RMI remote objects, which allows the ORB to support them as distributed objects.
The home interface
The home interface is the mechanism by which the client identifies the enterprise bean it wants. It allows a client to create, remove, and (for entity beans, not supported by CICS®) find existing instances of, enterprise beans. Note that the “client” might not be a program running on a network workstation; it might, for example, be a servlet running on a Web server; or an enterprise bean, program, or object on the local EJB server, or on another EJB server.

When a bean is deployed in an EJB server, the container registers the home interface in a namespace that is accessible remotely. Using the Java Naming and Directory Interface (JNDI) API, any client with access to the namespace can locate the home interface by name. (To be precise, the client locates, by name, an object that implements the home interface. The home interface extends the EJBHome interface.)

The component interface
The component interface allows a client to access the business methods of the enterprise bean. It intercepts all business method calls from the client and inserts whatever transaction, state management, persistence, and security services were specified when the bean was deployed.

When a client creates or finds an instance of an enterprise bean, the container returns a component interface object (one per instance). (To be precise, the container returns a reference to an instance of a class that implements the component interface. The component interface extends the EJBObject interface.)