 
 class Space.Module extends Space.Object
+
+  @ERRORS:
+    injectorMissing: 'Instance of Space.Injector needed to initialize module.'
 
   injector: null
   RequiredModules: null

    else
      Space.Module.published[identifier] = module

  @require: (requiredModule, requestingModule) ->

    module = Space.Module.published[requiredModule]

    if Meteor.isServer then @npm = Npm

    @injector.injectInto this
    # Map classes that are declared as singletons
    @injector.map(singleton).asSingleton() for singleton in @Singletons
    @isInitialized = true
    @configure()
    @isConfigured = true

  start: ->
    # Start all required modules first if necessary
    for moduleId in @RequiredModules
      module = @app.modules[moduleId]
      unless module.isStarted then module.start()

    if !@isStarted
      # Create the singleton instances that are declared
      @injector.create(singleton) for singleton in @Singletons
      # Let the user do other stuff on module startup
      @run()

    @isStarted = true

  # Override this method to configure your mappings etc. after the
  # module was initialized but the application is not running yet.
  configure: ->

  # Override this method for final initialization when the application runs
  run: ->

  # ========== STATIC MODULE MANAGAMENT ============ #

  # All published modules register themselves here
  @published = {}

  # Publishes a module into the space environment to make it
  # visible and requireable for other modules and the application
  @publish: (module, identifier) ->

    if Space.Module.published[identifier]?
