public static function &getInstance()
 {
     if (self::$_instance == null) {
         self::$_instance = new __EventDispatcher();
     }
     return self::$_instance;
 }
 /**
  * Set the required permission to access to current system resource
  *
  * @param __Permission &$permission The required permission for current system resource
  */
 public function setRequiredPermission(__Permission &$required_permission)
 {
     $this->_required_permission =& $required_permission;
     //Raise the event onSystemResourceCreate:
     __EventDispatcher::getInstance()->broadcastEvent(new __ContextEvent($this, EVENT_ON_REQUIRED_PERMISSION_ASSIGNMENT));
 }
 /**
  * This method stop to listen for any event raise. No actions will be executed for any event.
  *
  */
 public final function stopToListen()
 {
     __EventDispatcher::getInstance()->unregisterEventListener($this);
 }
 /**
  * Starts the session.
  * 
  * This method raises 2 events:<br>
  *  - EVENT_ON_SESSION_START: If the session has been started successful.
  * 
  * @throws __SessionException if the session has already been started
  *
  */
 public function startSession()
 {
     if ($this->getSessionStatus() != __SessionManager::STATUS_STOPPED) {
         throw new __SessionException('An atempt to start the session has been detected while the session was already started.');
     }
     try {
         session_start();
         $session = $this->getSession();
         $app_name = __Lion::getInstance()->getRuntimeDirectives()->getDirective('APP_NAME');
         if (!$session->hasData($app_name)) {
             $dummy_value = true;
             $session->setData($app_name, $dummy_value);
             $this->_new_session = true;
         }
         __EventDispatcher::getInstance()->broadcastEvent(new __Event($this, EVENT_ON_SESSION_START));
     } catch (Exception $e) {
         throw new __SessionException($e->getMessage(), $e->getCode());
     }
 }
 /**
  * Constructor method
  *
  */
 public function __construct()
 {
     $this->_user_session = new __UserSession();
     $this->_context_id = __CurrentContext::getInstance()->getContextId();
     __EventDispatcher::getInstance()->registerEventCallback(EVENT_ON_REQUIRED_PERMISSION_ASSIGNMENT, new __Callback($this, 'onRequiredPermissionAssignment'), $this->_context_id);
 }