-class Space.eventSourcing.Router extends Space.messaging.Controller
-
+class Space.eventSourcing.Router extends Space.Object
   @type 'Space.eventSourcing.Router'
 
+  @mixin [
+    Space.messaging.CommandHandling
+    Space.messaging.EventSubscribing
+    Space.messaging.EventPublishing
+  ]
+
+  _commandHandlers: {}
+
   dependencies: {
+    repository: 'Space.eventSourcing.Repository'
+    injector: 'Injector'
     configuration: 'configuration'
-    repository: 'Space.eventSourcing.Repository'
-    commitStore: 'Space.eventSourcing.CommitStore'
+    commandBus: 'Space.messaging.CommandBus'
+    eventBus: 'Space.messaging.EventBus'
     log: 'log'
   }
 
-  @ERRORS: {
-
+  ERRORS: {
     managedEventSourcableNotSpecified: 'Please specify a Router::eventSourceable
     class to be managed by the router.'
 
     missingInitializingMessage: 'Please specify Router::initializingMessage
-    (an event or command class) that will be used to create new instanes of
+    (an event or command class) that will be used to create new instances of
     the managed eventSourceable.'
 
     missingEventCorrelationProperty: 'Please specify Process::eventCorrelationProperty


  eventSourceable: null
  initializingMessage: null
  routeEvents: null
  routeCommands: null
  eventCorrelationProperty: null

  constructor: ->

  _routeCommandToEventSourceable: (commandType) ->
    @commandBus.registerHandler commandType, @_genericCommandHandler


  _injectDependencies: (eventSourceable) ->
    @injector.injectInto(eventSourceable)

  _logMsg: (message) -> "#{@configuration.appId}: #{this}: #{message}"

  _handleDomainErrors: (fn) ->
    try
      return fn.call(@)
    catch error
      if error instanceof Space.Error
        @publish(new Space.domain.Exception({
          thrower: @eventSourceable.toString(),
          error: error
        }))
        return null
      else
        throw error