public function attach($service, $callback, $priority = 1)
    {
        $service = $this->normalizeServiceName($service);
        
        // If we don't have a priority queue for the service yet, create one
        if (empty($this->services[$service])) {
            $this->services[$service] = new PriorityQueue();
        }
        
        if (is_string($callback)) {
            $id = $callback;
            $callback = null;
        } else {
            $id = null;
        }
        
        $listener = new LazyCallbackHandler(
            $callback, 
            array('service' => $service, 'priority' => $priority, 'service_id' => $id));
    
        // Inject the callback handler into the queue
        $this->services[$service]->insert($listener, $priority);
        return $listener;
    }