B.2 The EJB Code for Rosa's SystemThe following code sniplet describes the remote interface of the entity bean called BreakfastOrder: import java.rmi.*; import javax.naming.*; import javax.ejb.*; import breakfast.ejb.breakfastorder.*; public interface BreakfastOrder extends EJBObject { public BreakfastOrderDataObject getBreakfastOrder() throws RemoteException; public void setBreakfastOrder(BreakfastOrderDataObject update) throws NamingException, FinderException, CreateException, RemoteException; public float calculatePrice() throws RemoteException; } The following code snippet shows the implementation of the data class for BreakfastOrder : import breakfast.ejb.*; import java.util.*; public class BreakfastOrderDataObject extends DataObject implements java.io.Serializable { private BreakfastOrderKey key; /** * Creates a new BreakfastOrderDataObject. * @param key initialize all fields necessary to uniquely identify * this object */ public BreakfastOrderDataObject(BreakfastOrderKey key) { this.key = key; this.deliveryAddress = new Address(); } public int getBreakfastOrderID() { return key.getBreakfastOrderID(); } // References to associated single classes: private CustomerKey customercustomerKey; /** * Sets the foreign key CustomerKey of the singular referenced * Customer * @param CustomerKey */ public void setCustomerCustomer(CustomerKey s) { this.customercustomerKey = s; } /** * Returns the foreign key CustomerKey of the singular referenced Customer * @return CustomerKey */ public CustomerKey getCustomerCustomer() { return customercustomerKey; } // References to by-value-treated collections of objects: private breakfast.ejb.breakfastorder.BreakfastDataObjectCollection breakfastbreakfast; public void addBreakfast( breakfast.ejb.breakfastorder.BreakfastDataObject added) { this.breakfastbreakfast.add(added); } public void removeBreakfast( breakfast.ejb.breakfastorder.BreakfastDataObject removed) { this.breakfastbreakfast.remove(removed); } /** * Returns the internal BreakfastDataObjectCollection of the multiple * contained Breakfast. * @return breakfast.ejb.breakfastorder. * BreakfastDataObjectCollection */ public breakfast.ejb.breakfastorder.BreakfastDataObjectCollection getBreakfast() { if (breakfast == null) { breakfast = new breakfast.ejb.breakfastorder.BreakfastDataObjectListImpl(); } return breakfast; } // No associated collections of objects by reference // Attributes: private java.util.Date orderDate; /** * Returns attribute orderDate. * @return java.util.Date */ public java.util.Date getOrderDate() { return orderDate; } public void setOrderDate(java.util.Date value) { this.orderDate = value; } private Address deliveryAddress; /** * Returns a copy of attribute deliveryAddress. * Since deliveryAddress is a StructType, we do not want that the * object returned by getDeliveryAddress() can implicitly change the * state of the owner BreakfastOrder. * Therefore a copy is returned. * @return Address */ public Address getDeliveryAddress() { return deliveryAddress != null ? deliveryAddress.deepCopy() : null; } public void setDeliveryAddress(Address value) { this.deliveryAddress = value; } private java.util.Date deliveryDate; /** * Returns attribute deliveryDate. * @return java.util.Date */ public java.util.Date getDeliveryDate() { return deliveryDate; } public void setDeliveryDate(java.util.Date value) { this.deliveryDate = value; } private java.util.Date deliveryTime; /** * Returns attribute deliveryTime. * @return java.util.Date */ public java.util.Date getDeliveryTime() { return deliveryTime; } public void setDeliveryTime(java.util.Date value) { this.deliveryTime = value; } private floatdiscount; /** * Returns attribute discount. * @return float */ public float getDiscount() { return discount; } public void setDiscount(float value) { this.discount = value; } } |