A good idea when designing entity beans is to keeping bulk accessors of
entity beans (ie: Value Object factory methods) separate from the entity
bean itself.
I think this is a great idea, particularly when a client could be
interested in many different subsets of an entity beans data (each of which
can be returned as a separate type of value object). Removing these methods
from the entity bean should clean it up, and leave it as a holder of
business methods, not value object factory methods which really have nothing
to do with the semantic meaning of the entity bean.
The problem is, how do you implement this, particularly in EJB 2.0? Can you
have a separate static Factory class that implements the "getValueObject"
method, that internally calls getters on an entity bean? This seems like bad
practice to me, since each "getter" call could potentially be remote, so
placing the "getValueObject" method on the entity bean could be better for
performance.
In EJB 2.0, I also thought of removing value object factory methods from
the remote interface to the home interface, since EJB 2.0 now allows placing
of business methods on the home interface. This would at least keep factory
methods out of the remote interface, but suffers from the same problem as
the last option, since even though the method is on the home interface, it
can only interact with an EJB through its remote interface.
To further complicate things, EJB 2.0 does not allow returning dependant
objects to a client, thus each dependant object will probably have to have
an accompanying value object used for marshalling purposes. In this case, we
are pretty much forced to place a "getValueObject" methods on the entity
bean, one for each value object it supports, because only the entity bean
itself has access to its dependant object.
Does anyone have any ideas on how to extract value object creation
from an entity bean?
Floyd
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".