Implementing a CMP Entity Bean

Just as for BMP Entity beans, implementing a CMP Entity bean involves providing an implementation for the methods of the javax.ejb.EntityBean, corresponding methods for each method in the home interface, and a method for each method in the remote interface.

Implementing javax.ejb.EntityBean

Under BMP, the setEntityContext() method was used to look up various bean home interfaces from JNDI, and the JDBC DataSource called java:comp/env/jdbc/Agency was also obtained. Because most of these relationships are now managed by the container, only a couple of home interfaces now need to be obtained, and there is no requirement to look up the DataSource. Listing 7.4 shows this.

Listing 7.4. The JobBean's setEntityContext() ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.