Implementing a BMP Entity Bean

Implementing an Entity bean involves providing an implementation for the methods of the javax.ejb.EntityBean, corresponding methods for each method in the local-home interface, and a method for each method in the local interface.

Implementing javax.ejb.EntityBean

The setEntityContext() method is a good place to perform JNDI lookups, for example to acquire a JDBC DataSource reference. Listing 6.4 shows how this is done for the JobBean code.

Listing 6.4. JobBean.setEntityContext() Method
 1: package data; 2: 3: import javax.ejb.*; 4: import javax.naming.*; 5: import javax.sql.*; 6: // imports omitted 7: 8: public class JobBean implements EntityBean 9: { 10: public void setEntityContext(EntityContext ctx) { 11: this.ctx ...

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.