Static Class Structure
Mediator
Mediator1,…
Mediator
interface.
colleague1,colleague2,…)
to colleagues.
Colleague1,Colleague2,…
Mediator interface
instead of referring to
each other directly.
Dynamic Object Collaboration
Mediator1 object mediates
(controls and coordinates)
the interaction between
Colleague1
and Colleague2 objects
(to synchronize their state, for example).
Colleague1
and Colleague2 are configured
with a Mediator1 object.
Colleague1 changes,
which causes Colleague1
to call mediate(this) on
its Mediator1 object.
Colleague1 passes itself
(this) to the Mediator1
so that Mediator1 can call back
and get the changed data.
Mediator1
gets the changed data from
Colleague1 and
performs an action2() on Colleague2.
Colleague2 changes,
Colleague2
calls mediate(this) on
its Mediator1.
Mediator1 now
gets the changed data from
Colleague2 and
performs an action1() on
Colleague1.