/**
     * Fetches an application by its url
     * @param string $uri
     * @param string $outputType
     * @return ApplicationDefault
     */
    static public function fetchByUri( $uri, $outputType = 'html' )
    {
        // We keep $currentApplication to avoid loosing it during the process
        $currentApplication = ApplicationDefault::instance();
        $realServerURi      = $_SERVER['REQUEST_URI'];
        $uri                = trim($uri, '/ ');
        $uriparams          = explode('/', $uri);
        $applicationName    = $uriparams[0];

        $functions = array(
            'html'     => 'main_view',
            'json'     => 'json',
            'ajax'     => 'ajax'
        );

        array_unshift($uriparams, 'app_content');

        $_SERVER['REQUEST_URI'] = '/esibuild/'.$functions[$outputType].'/app_content/'.$uri;

        $params = array(
            self::paramBlockKey()               => 'app_content',
            'ModuleName'                        => 'esibuild',
            'FunctionName'                      => $functions[$outputType],
            self::paramCurrentApplicationKey()  => $applicationName,
            'Parameters'                        => $uriparams
        );

        $application            = BlockFactory::factory( $params, $outputType );
        $_SERVER['REQUEST_URI'] = $realServerURi;

        // We set $currentApplication again
        ApplicationDefault::setInstance($currentApplication);

        return $application;
    }