Java Reference
In-Depth Information
All the business methods defined in the remote interface must be implemented in the bean class. Th e
methods in the bean-implementations class must have the same function name, function signature, and
return type as the corresponding methods defined in the remote interface. You will see the
implementation of MemberEJB in the next section .
An Example BMP Entity Bean — MemberEJB
An example application is being built through Chapters 20-22. The example application is used by a
yacht club for its cruise operation. From time to time, the club offers its member free yacht cruises. The
cruising yacht allows only the club members on board. The business entity, club member , is
implemented as a BMP entity bean. The underlying database table, member, is illustrated in Table 21-1 .
The home interface and remote interface of MemberEJB are shown in Listing 21-3 and Listing 21-5 ,
respectively. The implementation class is shown in Listing 21-6 .
Listing 21-6: MemberEJB implementation class
/** MemberEJB Implementation class.
* System.out.printline() is used to display the error message to the
standard output.
* You should replace System.out.println() with approperate log functions of
the EJB
* server you use, so that the error message will be written to the log file.
* @author: Andrew Yang
* @version: 1.0
*/
package java_database.MemberEBean;
import java.rmi.*;
import java.util.*;
import java.sql.*;
import javax.ejb.*;
import javax.naming.*;
public class MemberBean implements EntityBean {
// instance attributes
private String memberId;
private String lastName;
private String firstName;
private int membershipYear;
private InitialContext ctx;
private EntityContext context;
/** default constructor */
public MemberBean() {
try {
ctx = new InitialContext();
Search WWH ::




Custom Search