Dependent Value Classes
Dependent value classes are custom serializable objects that can be used as persistence fields (although this use is not recommended). They are useful for packaging data and moving it between an entity bean and its remote clients. They separate the client’s view of the entity bean from its abstract persistence model, which makes it easier for the entity bean class to change without affecting existing clients.
The remote interface methods of an entity bean should be defined independently of the abstract persistence schema. In other words, you should design the remote interfaces to model the business concepts, not the underlying persistence programming model. Dependent value classes can help separate a remote client’s view from the persistence model by providing objects that fill the gaps in these perspectives.
For example, the CustomerEJB
could be modified so
that its lastName
and firstName
fields are not exposed to remote clients through their accessor
methods. This is a reasonable design approach, since most clients
access the entire name of the customer at once. The remote interface
might be modified to look like:
import java.rmi.RemoteException; public interface CustomerRemote extends javax.ejb.EJBObject { public Name getName( ) throws RemoteException; public void setName(Name name) throws RemoteException; }
This remote interface is simpler than the one we saw earlier. It allows the remote client to get all the name information in one method call instead ...
Get Enterprise JavaBeans, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.