The essence of the Mediator Pattern is to "Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently. With the mediator pattern, communication between objects is encapsulated with a mediator object. Objects no longer communicate directly with each other, but instead communicate through the mediator. This reduces the dependencies between communicating objects, thereby lowering the coupling.
I am representing a mediator pattern using a job scheduling / workflow application. The mediator object (implemented in xml as @workflow) has name="command_name" and the parameters and sql to be executed with sp_executesql. The mediator has no knowledge of what object created it nor what object will run it or even if (in the case of many objects) if all mediators will be executed by the same or disparate objects.
-- build workflow
declare @workflow [xml] =
N'<command name="command_name">
<parameters>@output [xml] output</parameters>
<sql><sql statement></sql>
</command>';
-- push @workflow onto work queue
execute [workflow].[queue] @workflow=@workflow;
The object which executes the mediator object has no knowledge of the application that created the mediator.
-- get @workflow from work queue and execute
set @workflow=[workflow].[get];
execute [workflow].[run] @workflow=@workflow output;
Reference
Reactor - The reactor design pattern is an event handling pattern for handling service requests delivered concurrently to a service handler by one or more inputs. The service handler then demultiplexes the incoming requests and dispatches them synchronously to the associated request handlers.
Active Object - The active object design pattern decouples method execution from method invocation for objects that each reside in their own thread of control. The goal is to introduce concurrency, by using asynchronous method invocation and a scheduler for handling requests.
Event Based Asynchronous - In (multithreaded) object-oriented programming, asynchronous method invocation (AMI), also known as asynchronous method calls or asynchronous pattern is a design pattern for asynchronous invocation of potentially long-running methods of an object.[1] It is equivalent to the IOU pattern described in 1996 by Allan Vermeulen.[2][3] The event-based asynchronous pattern in .NET Framework and the java.util.concurrent.FutureTask class in Java use events to solve the same problem.
copyright Katherine Elizabeth Lightsey 1959-2013 (aka; my life)
"All labor that uplifts humanity has dignity and importance and should be undertaken with painstaking excellence." - Martin Luther King, Jr.