Injection of Dependencies Layers Application / Domain / Repository

2

In an application using the DDD concepts I am in doubt about who could inject (dependencies) into a particular class if there is any standard for it.

This is between the Application, Domain, and Repository layers.

1) AnAppService Client (Application layer) that needs to inject user, should I inject UserApplicationService and from it call UserService (Domain) or inject UserService directly in ClientApplicationService?

2) In the ClientService (domain) should I inject UserService and from it call UserRepository or could I inject UserRepository directly into ClientService?

I'm concerned about cyclic reference if I'm injecting peer classes.

But I also think that I should not inject the Repository of another Entity, because often the methods of the repository have a rule in the service that should be called previously.

Someone has already had this question, how do you usually handle it?

    
asked by anonymous 03.05.2018 / 12:46

1 answer

0

This is easy, in the DDD is provided an element called infrastructure, dependency injection resides there.

    
05.05.2018 / 09:03