Worflow Mediators

The IWorkflowMediator is a mediator object for workflows. The mediator is a clean interface aggregating stateful workflow features into a simple external interface. The mediator works well with IoC containers. Consider this controller:

public virtual ActionResult Submit(int ticketId) {
    var ticket = Ticket.GetById(ticketId);
    var workflow = Container.Resolve<IWorkflowMediator<Ticket>>();
    return View(ticket);

The controller gets a ticket, finds the workflow that has to do with tickets, and submits the ticket to the workflow. This requires zero understanding of the details of the ticket workflow. The details that you don't see is that the controller also compiled the workflow, checked the object's transition path against the security policy that the workflow implements, and validated the object against some global rules. All this is possible because the mediator pattern simplifies and abstracts interaction with your workflows to keep business logic in the business layer.

Last edited Mar 29, 2011 at 5:20 AM by tkellogg, version 1


No comments yet.