Developing an Entity Bean
There’s no better place to start than the Cabin EJB, which we have been examining throughout the previous chapters. The Cabin EJB is an entity bean that encapsulates the data and behavior associated with a cruise ship cabin in Titan’s business domain.
Cabin: The Remote Interface
When developing an entity bean, we first want to define its remote interface. The remote interface defines the bean’s business purpose; the methods of this interface must capture the concept of the entity. We defined the remote interface for the Cabin EJB in Chapter 2; here, we add two new methods for setting and getting the ship ID and the bed count. The ship ID identifies the ship to which the cabin belongs, and the bed count tells how many people the cabin can accommodate:
package com.titan.cabin;
import java.rmi.RemoteException;
public interface CabinRemote extends javax.ejb.EJBObject {
public String getName( ) throws RemoteException;
public void setName(String str) throws RemoteException;
public int getDeckLevel( ) throws RemoteException;
public void setDeckLevel(int level) throws RemoteException;
public int getShipId( ) throws RemoteException;
public void setShipId(int sp) throws RemoteException;
public int getBedCount( ) throws RemoteException;
public void setBedCount(int bc) throws RemoteException;
}The CabinRemote
interface defines four properties:
name, deckLevel,
shipId, and bedCount.
Properties are attributes of an enterprise bean that can be accessed by public set and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access