Developing EJBs (continued)… Define Entity Beans
public class AccountBean implements EntityBean {
protected EntityContext _entityContext;
public int account_number; // ACCOUNT_NUMBER
public String customer_name; // CUSTOMER_NAME
public double balance; // BALANCE
public void credit ( double amount ) { balance += amount;}
public void debit ( double amount ) { balance -= amount; }
public double getBalance() { return balance; }
// Container managed beans return void - can have many create methods
public void ejbCreate(int accountNo, String customer) throws Exception {
this.account_number = accountNo; this.customer_name = customer; this.balance = 0d;
public void ejbCreate( int accountNo, String customer, double balance) throws Exception {
this.account_number = accountNo; this.customer_name = customer; this.balance = balance;
// these methods are required by the EntityBean interface
public void ejbActivate () throws RemoteException {}
public void ejbLoad () throws RemoteException {}
public void ejbPassivate() throws RemoteException {}
public void ejbRemove () throws RemoteException, RemoveException {}
public void ejbStore () throws RemoteException {}
public void setEntityContext(EntityContext context) throws RemoteException {
this._entityContext = context;
public void unsetEntityContext() throws RemoteException {
this._entityContext = null;