in the context of DDD, I understand that application service orchestrates domain Service and Repository(application workflow), now my question is which layer responsible to inject the dependencies, is dependency injection must be done in UI(the layer that uses application service) or in Application Service . for example, in the case of concrete repository injection Which layer should do that?
another question is, can I place application service code directly in web service and use that web service as application service layer?
Best Regards
... is dependency injection must be done in UI(the layer that uses application service) or in Application Service . for example, in the case of concrete repository injection Which layer should do that ?
Dependency injection container should be used as high as possible. In general, this means in the bootstrap of the application, even before the UI.
for example, in the case of concrete repository injection Which layer should do that ?
The layer that was first called, the entry point to the entire application, in the Composition root.
another question is, can I place application service code directly in web service and use that web service as application service layer?
It depends a lot on your architecture and on what is a "web service" for you. If you are referring to a layered architecture: If it is something like a REST controller then NO, in this case the "web service" is in the Presentation layer and the Application service is in the Application layer. The Application layer contains all the use cases, every Application service is a use case. Read more here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With