The javax.ejb Package for Session beans

Now it is time to add a little more detail. EJBs are written by implementing various interfaces of the javax.ejb package. Figure 5.1 shows a UML class diagram of the interfaces in javax.ejb that support Session beans.

Figure 5.1. The javax.ejb package defines remote and local interfaces, as well as an interface for the Session bean to implement.


Central to the EJB architecture are the javax.ejb.EJBHome and javax.ejb.EJBObject interfaces, common to both Session beans and Entity beans. These both extend the java.rmi.Remote interface, which means that the classes that implement them (not shown) are available through RMI stubs across the network.

The javax.ejb.EJBLocalHome and javax.ejb.EJBLocalObject interfaces are local equivalents, and the classes that implement these are accessible only locally (that is, by clients that reside within the same EJB container itself). Because local interfaces are most often used with Entity beans, and also because there's plenty for you to learn today, there's no major discussion of local interfaces until tomorrow.

Thejavax.ejb.EJBContext interface provides access to the home interfaces and, as you can see from its method list, also provides security and transaction control. The javax.ejb.SessionContext subclass (only used by Session beans) provides a reference to the bean's EJBObject, that is, its interface for remote clients.

The javax.ejb.HomeHandle and javax.ejb.Handle interfaces provide a mechanism to serialize a reference to either a home or a remote interface for use later. This capability is not often used, so isn't discussed further.

The Session bean itself implements the javax.ejb.SessionBean interface that defines the bean's lifecycle methods and has an implementation for all of the methods defined in the remote or the home interface.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.163.250