----- Original Message -----
From: "Geert Mergan" <[EMAIL PROTECTED]>
> I think I have a similar solution:
>
> - UI via servlet that calls session bean
>
> - session bean calls business logic layer (plain java classes)
>
> - session bean calls persistence layer. I'm still investigating what
> technology I will use for persistence: could be CMP, BMP, DAO, JDO, castor,
> toplink, Cocobase....
Actually, I reverse the persistence and business logic layers. The session bean
makes calls to the appropriate entity beans and gets value objects in return. I
think a pseudocode example would be a good idea. Let's assume there is a call to
get a specific employee. We have an Employee interface implemented by an
EmployeeState class:
public interface Employee {
String getSSN();
void setSSN(String ssn);
String getName();
void setName(String name);
}
public class EmployeeState implements Employee {
String ssn;
String name;
public String getSSN() {
return ssn;
}
etc...
}
The session bean's method is responsible for looking up the entity bean and
constructing the state object to send back to the caller:
Employee getEmployee(String ssn) throws EmployeeNotFoundException {
EmployeeRemote remote = employeeHome.findByPrimaryKey(ssn);
Employee employee = new EmployeeState();
employee.setSSN(remote.getSSN());
employee.setName(remote.getName());
return employee;
}
This isn't the entire pattern. My value objects are mutable and therefore extend
some classes to assist in detecting changes. Also they lazy load dependent
objects as needed. There is more, but this is the gist.
The benefits as I see them are:
1. Lazy-loading of complex dependent object structures.
2. Mutablility and the ability for the value objects to trigger their own
persistence. Note that the value objects rely on the entity beans for
persistence.
3. This persistence takes place in a well-defined framework, including the
dependent objects.
4. The client does not have to deal with any RemoteExceptions, except for the
communication with the Session Bean.
5. The value object will perform the necessary retries when non-application
exceptions occur, thus providing transparent failover.
jim
===========================================================================
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".