protected function detectGae()
    {
        if (! class_exists(self::GAE_ID_SERVICE)) {
            $this->runningOnGae = false;
            $this->appId = null;
            return;
        }

        $AppIdentityService = self::GAE_ID_SERVICE;
        $this->appId = $AppIdentityService::getApplicationId();
        $this->runningOnGae = ! preg_match('/dev~/', getenv('APPLICATION_ID'));

        if ($this->runningOnGae) {
            require_once(__DIR__ . '/gae_realpath.php');
        }
    }