4
votes

Is the application layer (application services) where I add @Stateful, @Stateless, @WebService etc. in DDD? From the link below this seems to be right.

Second question: I have made a repository class, should all method calls involving repository be wrappen in an application service? Or can I use repository classes directly in let say backing beans in JSF? When and what do I put in the application layer. I don't understand where the EJBs belong in this artitechture.

Application Layer: This layer coordinates the application activity. It doesn't contain any business logic. It does not hold the state of business objects, but it can hold the state of an application task's progress.

http://www.infoq.com/articles/ddd-in-practice

2

2 Answers

6
votes

Java EE advocates anemic model, which is the opposite of DDD. If you want DDD, your entities must also perform the business logic, which is contrary to the separation of service layer and entities.

0
votes

It's supposed that in DDD architecture the Application Layer and all the other layer communicate only with lower layer of the system. For this reason the application service wrapp repositories, but if you are using dependency inyection you can reuse all your repositories along the application service layer

The real work of AppService is to coordinate operations beetwen other service or repositories or inclusive domain services.

In your entities must to be bussiness logic only about your own entities. Always respecting Single Responsibility Principle (http://www.developerfusion.com/article/137636/taking-the-single-responsibility-principle-seriously/).

I hope be helpful