   _routeCommandToEventSourceable: (commandType) ->
     @commandBus.registerHandler commandType, @_genericCommandHandler
 
-  _genericEventHandler: (event) =>
-    # Only route this event if the correlation property exists
-    return unless event.meta? and event.meta[this.eventCorrelationProperty]?
-    correlationId = event.meta[this.eventCorrelationProperty]
-    @log.info(@_logMsg("Handling event #{event.typeName()} for
-                       #{@eventSourceable}<#{correlationId}>\n"), event)
-    eventSourceable = @repository.find @eventSourceable, correlationId
-    throw Router.ERRORS.cannotHandleMessage(event) if !eventSourceable?
-    eventSourceable = @_handleDomainErrors(-> eventSourceable.handle event)
-    @repository.save(eventSourceable) if eventSourceable?
 
-  _genericCommandHandler: (command) =>
-    if not command? then return
-    @log.info(@_logMsg("Handling command #{command.typeName()} for
-                       #{@eventSourceable}<#{command.targetId}>"), command)
-    eventSourceable = @repository.find @eventSourceable, command.targetId
-    throw Router.ERRORS.cannotHandleMessage(command) if !eventSourceable?
-    eventSourceable = @_handleDomainErrors(-> eventSourceable.handle command)
-    @repository.save(eventSourceable) if eventSourceable?
+  _injectDependencies: (eventSourceable) ->
+    @injector.injectInto(eventSourceable)
 
   _logMsg: (message) -> "#{@configuration.appId}: #{this}: #{message}"
 
   _handleDomainErrors: (fn) ->
     try
-      return fn.call(this)
+      return fn.call(@)
     catch error
       if error instanceof Space.Error
-        this.publish(new Space.domain.Exception({
+        @publish(new Space.domain.Exception({
           thrower: @eventSourceable.toString(),
           error: error
         }))
         return null
       else
-        throw error
+        throw error

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

  constructor: ->

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'
    commandBus: 'Space.messaging.CommandBus'
    eventBus: 'Space.messaging.EventBus'
    log: 'log'
  }

  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 instances of
    the managed eventSourceable.'

    missingEventCorrelationProperty: 'Please specify Process::eventCorrelationProperty
