Defining the Remote Interfaces

We define both local and remote interfaces for the order entity bean, but only the local interface for the line item entity bean.

Defining the Order Interfaces

Both the local and remote home interfaces of the order entity bean provide methods for accessing the bean's persistent fields. In addition, they contain the business methods addLineItem() and getOrderLineItems(). The addLineItem() method is used to add a line item to the order. The getOrderLineItems() returns a collection of ClientLineItem objects (as opposed to OrderLineItemLocal objects).

Listing 12.4 shows the Order remote interface.

Listing 12.4. The Full Text of day12/Order.java
package day12;
import java.util.*;
import java.rmi.*;
import javax.ejb.*;
public interface Order extends EJBObject{
   public String getOrderId()
      throws RemoteException;
   public String getStudentId()
      throws RemoteException;
   public void setStudentId(String studentId)
      throws RemoteException;
   public double getAmount()
      throws RemoteException;
   public void setAmount(double amount)
      throws RemoteException;
   public java.sql.Timestamp getOrderDate()
      throws RemoteException;
   public void setOrderDate(java.sql.Timestamp date)
      throws RemoteException;
   public String getStatus()
      throws RemoteException;
   public void setStatus(String status)
      throws RemoteException;
   public void addLineItem(String courseId, double fee)
      throws RemoteException;
   public Collection getOrderLineItems()
      throws RemoteException;
}

The Order remote interface does not provide accessor methods for the container-managed persistent field line items.

Caution

The accessor methods for container-managed relationship fields must not be exposed in the remote interface of the entity bean.


Listing 12.5 shows the OrderLocal local interface.

Listing 12.5. The Full Text of day12/OrderLocal.java
package day12;
import java.util.*;
import java.rmi.*;
import javax.ejb.*;
public interface OrderLocal extends EJBLocalObject {
   public String getOrderId();
   public String getStudentId();
   public void setStudentId(String studentId);
   public double getAmount();
   public void setAmount(double amount);
   public java.sql.Timestamp getOrderDate();
   public void setOrderDate(java.sql.Timestamp date);
   public String getStatus();
   public void setStatus(String status);
   public void addLineItem(String courseId, double fee);
   public Collection getOrderLineItems();
}

Defining the OrderLineItemLocal Local Interface

The local interface of the order line item entity bean provides methods for accessing the bean's persistent fields. In addition, it contains the accessor methods for the container-managed persistent field order.

Listing 12.6 shows the OrderLineItemLocal local interface.

Listing 12.6. The Full Text of day12/OrderLineItemLocal.java
package day12;
import javax.ejb.*;
public interface OrderLineItemLocal extends EJBLocalObject {
   public String getOrderLineItemId();
   public String getCourseId();
   public void setCourseId(String courseId);
   public double getFee();
   public void setFee(double fee);
   public OrderLocal getOrder();
   public void setOrder(OrderLocal o);
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.246.245