Java Reference
In-Depth Information
Bean Object
The bean object is made up of the methods that implement the business logic for the bean.
Clients never directly access the methods in this object. They always make use of the home
and remote interfaces.
An interesting note is that the bean object does not implement either the home or remote inter-
faces. However, it must have methods that match the signatures for all of the methods in the
remote interface and methods that correspond with many of the methods in the home interface.
These are some of the interaction regulations that are laid out in the specification. We will take
a deeper look at these rules later. Depending on whether the bean is a session bean or entity
bean, the bean object must extend either javax.ejb.SessionBean or javax.ejb.EntityBean .
Primary Key
The primary key class is specific to entity beans. It is a very simple class that specifies the
attributes that make up the unique primary key for the entity bean. The only requirement is that
it implements .
Naming Conventions
The naming conventions for the interfaces and classes associated with an EJB do not actually
have any specific rules, however there is a recommended convention. This convention holds
true for both session and entity beans, and will be used throughout this chapter.
We will use a fictitious entity bean—Employee—to illustrate the naming conventions associ-
ated with an EJB. The overall component made up of all of the interfaces and classes neces-
sary for a bean is referred to as the bean itself, for example Employee Bean.
The home interface class is generally named after the bean with Home appended. In the case of
the Employee Bean, the home interface is named EmployeeHome . The remote interface is the
client's real view of the bean; therefore it takes the bean's name alone. The name of the remote
interface for the Employee Bean is simply Employee . The bean object containing the data for
the bean takes the bean's name and adds the word Bean , for example EmployeeBean .
The primary key class associated with entity beans is somewhat more ambiguous. If a specific
user-defined class will be the primary key, a good convention is the bean's name followed by
PK . Our Employee Bean's primary key class would be named EmployeePK . The ambiguity
arises because it is possible to use any Serializable class in Java. A very commonly used pri-
mary key class found in Java is Integer . It is up to the bean designer to define the primary
With the knowledge of the different classes and interfaces that are required for an EJB, we can
and look at the ways EJBs are used by clients and managed by application servers.
Search WWH ::

Custom Search