private function handleCtrlResult($ret)
    {
        if ($ret === null) {
            return;
        }
        register_shutdown_function("closeResources");
        if (isset($_GET['format']) && $_GET['format'] == 'xml') {
            header('Content-type: application/xml; charset=utf-8');
            $ret = (object)$ret;
            echo $this->objectToXml($ret);
            die;
        }
        header('Content-type: application/json; charset=utf-8');
        echo json_encode($ret);
        die;
    }