Java Reference
In-Depth Information
public interface CalculateLoanHome extends EJBHome
public CalculateLoan create()
throws RemoteException, CreateException;
This is a simple interface that has only a few rules to follow. Now we will look at the bean
class and some of the more difficult to understand rules that the specification imparts to EJB
Bean Class
The bean class holds the implementation for the EJB. It has certain requirements in relation to
both the home and remote interfaces. The rules related to each interface are different, so we
will go through them independently.
First we will cover the general requirements for the session bean's bean class. It must imple-
ment the javax.ejb.SessionBean interface. In implementing SessionBean , four methods
must be implemented: ejbActivate() , ejbPassivate() , ejbRemove() , and
setSessionContext() . All of these methods will be discussed briefly later in the chapter.
The class must contain a public constructor that takes no arguments. This is the only construc-
tor that is useful in any EJB because all client construction of these beans is done through the
create() methods.
The first requirement is related to the home interface. For each create() method in the home
interface, the bean class must have an ejbCreate() method with an argument list that exactly
matches the signature of the corresponding create() method. The ejbCreate() method also
defines the same throws clause as the matching create() method. Each ejbCreate() method
must be public and return void. The following code snippet gives an example of a create()
method from a home interface and the matching ejbCreate() method that would exist in the
bean class:
public BeanRemote create(Integer number)
throws RemoteException, CreateException, AppDefinedException;
public void ejbCreate(Integer number)
throws RemoteException, CreateException, AppDefinedException
this.number = number;
Search WWH ::

Custom Search