Skip to content

Flow Of Control

mangeshdase edited this page Oct 29, 2021 · 2 revisions

The Flow of Control begins at the controller, moves through the use case, and then winds up executing the presenter.

The flow of control can be understood by following diagram,

flow of control1

User Registration Flow of Control

  • A request is received by the AccountResource controller then the registerAccount action is invoked.

  • The flow of control begins at the controller, moves through the use case, and then winds up executing the presenter(In Clean Architecture terms, the WebUI would be the presentation layer).

  • Then the Use Case(Application-specific business rules) needs to call the presenter by using a great design pattern, Mediator. It has two great benefits that fit really well with the Clean Architecture:

    1. Objects delegate their interaction to a mediator object instead of interacting with each other directly.
    2. It should be possible to change the interaction between a set of objects independently.
  • The registerAccount use case asks the repositories about the AccoutResource. It will call UserServicePort interface.

  • Then UserServicePort call the registerUser() method which will be implemented in UserService class.

  • Then userPersistencePort will call findOneByLogin() method it will be check the emailId is already exists or not.

  • If emailId exists then it will throw EmailAlreadyUsedException exception.

  • If not then it call save() method which is declared in UserPersistencePort interface and implemented in UserJPAAdapter class.

  • Then it will call UserRepositoy which extends JpaRepository to save the data in database.

Clone this wiki locally