How correctly realize Domain-entity, which will invoke in servlet? What is saying best practicies? And Martin Fowler recommends?
I give a simple example: For example we have an EJB project, classes StudentDAO and GroupDAO (students and groups).
And we have next example code in the servlet:
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
{
// Read GET-params
...
// Invoke to business-logic classes
final List<Group> groups = groupDAO.getAll();
final List<Student> students = studentDAO.filter(//... different filtering params...);
// Send request to client, or catch exceptions and send it
...
}
So, we direct appeal to DAO entities.
Is next variant is better:
@EJB
GroupDomain groupDomain;
@EJB
StudentDomain studentDomain;
...
final List<Group> groups = groupDomain.getAll();
final List<Student> students = studentDomain.filter(//... ...);
Or the Domain entity should be single? But how to get list of all groups and filtered list of students in this case?
Aucun commentaire:
Enregistrer un commentaire