1. Vineet Reynolds
  2. Java EE 6-Galleria

Wiki

Clone wiki

Java EE 6-Galleria / OverallApplicationArchitecture

Architectural themes

Domain driven design using Java EE 6

DDD as an architectural approach, is feasible in Java EE 6. This is primarily due to the changes made in EJB 3.x and in the introduction of JPA. The improvements made in the EJB 3.x and JPA specifications allow for a domain and application layer to be modelled in Java EE 6 using DDD. Although JPA (like Hibernate) does not facilitate the creation of a truly rich domain model, the resulting model is certainly not anemic by nature. It should be noted that injection of dependencies into JPA entities is certainly a desirable feature, but one that cannot be achieved. After all, dependency injection only works when the container/framework is responsible for object creation and initialization; the JPA/Hibernate model, instead defers the responsibility of object creation and initialization to the developer. It is this inability to inject dependencies into a JPA entity that prevents the model from being truly rich. Nevertheless, one can design an application to ensure that persistence services are injected into the application layer, and used to access/persist the entities within a transactional context established by the application layer.

The domain model of the project contains entities and repositories to access the aggregate roots of the entities. The domain entities are modelled as JPA entities, while the repositories are designed using Stateless Session EJBs. The application layer of the domain is designed using Stateless Session EJBs that operate on the repositories, while using the transaction, security and persistence infrastructure services of Java EE 6.

Details of the domain model can be found in a separate page.

Testing the domain model

In-container testing

Updated