Java Reference
In-Depth Information
public int getMembershipYear() { return membershipYear; }
public Date getLastDuePaymentDate() { return lastDuePaymentDate; }
// mutators
public void setMemberId(String s) { memberId = s; }
public void setLastName(String s) { lastName = s; }
public void setFirstName(String s) { firstName = s; }
public void setStreetAddress(String s) { streetAddress = s; }
public void setCity(String s) { city = s; }
public void setState(String s) { state = s; }
public void setZipCode(String s) { zipCode = s; }
public void setCountry(String s) { country = s; }
public void setPhone(String s) { phone = s; }
public void setFax(String s) { fax = s; }
public void setEmail(String s) { email = s; }
public void setSpouseName(String s) { spouseName = s; }
public void setMembershipYear(int n) { membershipYear = n; }
public void lastDuePaymentDate(Date d) { lastDuePaymentDate = d; }
}
Listing 21-8: Remote interface of MemberEJB using value object
/** MemberEJB Remote Interface. It use a value object, MemberInfoVO, to
reduce network
* and transaction overhead.
* @author: Andrew Yang
* @version: 1.0
*/
package java_database.MemberEBean;
import java.rmi.*;
import javax.ejb.*;
public interface Member extends EJBObject {
public MemberInfoVO getMemberInfo() throws RemoteException;
public void updateMemberInfo(MemberInfoVO mInfo) throws
RemoteException;
}
In practice, you may need to address a variety of data-access requirements. The required granularity
may well fall between two extremes. Then you may want to design multiple value objects for your entity
bean. This approach gives you more fine-grain control for accessing an entity object's state and still lets
you retain the performance benefits that value objects provide. It works best for entity beans with many
individual attributes, but where the bean's clients typically need access to only a small number of them.
In this approach, you group those individual getters and setters into subsets that clients logically
want to access together. You can have duplicated getters and setters in different subsets. Then
Search WWH ::




Custom Search