 events = require 'events'
 
 ACTIONS = ['configured', 'booted', 'started', 'running', 'shutdown', 'stopped']
-
-## EXPERIMENTAL identity based lookups cache -> nero
-## it is working! still deactivated by default. to use
-## put USELOOKUPSCACHE: true into the base config object
-USELOOKUPSCACHE = false
-LOOKUPSCACHE = {}
 
 module.exports = 
 

                done: (err)=>
                    
                    if !__first && ( __first = true )
                        @_changeStatus? status
                        done?()
                    
                    else if err
                        done? err
                    

        ##
        stop: (done)->
            @_changeStatus 'shutdown'
                        
            @_init 'stop', 'stopped', done

        
        ##
        ##
        ##
        lookup: (name, identity, done)->
            if !identity || !identity.id || !identity.token
                return done new Error '2. parameter is not identity'
            
            ## myself
            if name is @id
                @logger.debug 'found(%s) for %s', @ID, identity.id
                return @forIdentity identity, done
            
            ## children
            if (base = name.split('.').shift()) is @id
                base = (name = name.substr base.length + 1).split('.').shift()
            
            for child in @children 
                if child.id is base
                    @logger.debug 'delegate lookup(%s) to child %s for %s', name, child.ID, identity.id
                    return child.lookup name, identity, done
            
            ## parent
            if @parent?.lookup
                @logger.debug 'delegate lookup(%s) to parent %s for %s', name, @parent.ID, identity.id
                return @parent.lookup name, identity, done
            
            ## global
            if floyd.__parent?.lookup
                @logger.debug 'delegate lookup(%s) to global parent for %s', name, identity.id
                return floyd.__parent.lookup name, identity, done
            
            ## not found
            @logger.debug 'lookup(%s) failed for %s', name, identity.id
            done new Error 'Context not found: '+name
            
        
        ##
        ## delegates a method call down the hirarchy
