Specifying a Stateless Session Bean

As you will by now have gathered, the responsibilities of Session beans (and indeed, Entity beans) are specified through its remote and home interfaces. These are what the EJB container makes available to the remote clients.

To define a home interface for a stateless Session bean, extend javax.ejb.EJBHome. To define a remote interface, extend javax.ejb.EJBObject. Because both EJBHome and EJBObject extend the java.rmi.Remote interface, the rules for remote objects (in the Java sense of the word) must be followed.

The following is the home interface for the Agency session bean. If it looks familiar, it should be—you saw this for the first time just yesterday.

 package agency; import java.rmi.*; import javax.ejb.*; ...

Get Sams Teach Yourself J2EE™ in 21 Days now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.