There is recently a thread on theserverside: Spring 2.0 vs. the Anemic Domain Model
The thread discusses the solution presented by Spring 2.0 to resolve the Anemic Domain Model anti-pattern. The spring solution basically uses AspectJ and Java 5 annotation to weave the dependencies in. Therefore, clients can call "new DomainObject()" directly with the dependencies auto-magically injected from Spring.
Nuts presents 2 solutions, with and without AspectJ:
- Simple Rich Domain Injection describes a pure Object Oriented solution that doesn't rely on AspectJ. Dao and other factory interfaces are proxied to accept dependencies injected by the container. Not as convenient, but no magic is involved.
- Post Instantiation with AspectJ describes the solution using Nuts plus AspectJ. This solution gives the same level of convenience as the Spring 2.0 solution, yet allows fine grained control and more flexible configuration. When using auto-wiring, most of the configuration verbosity in Spring 2.0 can be eliminated.
Both solutions work with Java 1.4.
Depending on the project needs, the AspectJ solution is prefered if a large number of domain objects are involved and relying on AspectJ is not a concern; while the pure Object Oriented solution can typically be used with a small set of domain objects to construct a more conventional and flexible design that's independent of AspectJ.