From the course: Spring: Design Patterns
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
The Mediator pattern
- [Instructor] The Mediator pattern is another one of these patterns that we see used in a couple places in the Spring Framework, but we don't use that often when we write code. In the Spring Framework, the single most important place that we see the Mediator pattern used is in the DispatcherServlet and the way that it operates in Spring MVC. Now, often it can also be used when setting the state of various components at once, and that's another time that we see that used throughout the Framework because when they have to do this, these are all hidden kind of underneath the covers. So how does this pattern actually work? So, the Mediator provides encapsulation on object behavior. Communication channels flow through the Mediator, who then, in turn, allow its mediated classes to do work. Mediated classes do not communicate with each other and that's really the key of this pattern. They only communicate with the Mediator. And the Mediator classes themselves can register or unregister as…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.