/**
  * @see \Components\Http_Scriptlet::dispatch() dispatch
  */
 public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_)
 {
     $response = $context_->getResponse();
     $content = null;
     try {
         // FIXME Temporary fix - create a explicit route for ui/scriptlet/embedded.
         if (Environment::isEmbedded()) {
             $scriptlet = new Ui_Scriptlet_Embedded();
             $scriptlet->request = $context_->getRequest();
             $scriptlet->response = $context_->getResponse();
             $method = $scriptlet->request->getMethod();
             if (false === method_exists($scriptlet, strtolower($method))) {
                 throw new Http_Exception('ui/scriptlet', null, Http_Exception::NOT_FOUND);
             }
             $content = $scriptlet->{$method}();
         } else {
             $content = parent::dispatch($context_, $uri_);
         }
     } catch (\Exception $e) {
         Runtime::addException($e);
         if ($e instanceof Http_Exception) {
             $e->sendHeader();
         }
     }
     echo $content;
 }
 /**
  * @param \Components\Uri $uri_
  */
 public function dispatch(Uri $uri_, $method_ = null)
 {
     ob_start();
     try {
         $this->dispatchImpl($uri_, $method_);
     } catch (\Exception $e) {
         if (Runtime::isCli()) {
             throw $e;
         }
         Runtime::addException($e);
         if ($e instanceof Http_Exception) {
             $e->sendHeader();
         }
     }
     // FIXME Why??
     if (Runtime::isCli()) {
         echo ob_get_clean();
     } else {
         ob_flush();
         /**
          * Do not corrupt output for other mimetypes - assuming:
          * - Exceptions are logged
          * - Debug output & exceptions are sent via headers
          *
          * Visualization happens via client side / logging or
          * custom implementations of http/scriptlet#dispatch.
          */
         if (false === Io_Mimetype::TEXT_HTML()->equals($this->getResponse()->getMimetype())) {
             Debug::clear();
             Runtime::clearExceptions();
         }
         if (session_id()) {
             session_write_close();
         }
     }
 }