private static function getInstance()
 {
     if (self::$s_instance == null) {
         self::$s_instance = new DatabaseReaderFactory();
     }
     return self::$s_instance;
 }
 public function write(&$obj, IProtocolFormatter $writer)
 {
     $dbReader = DatabaseReaderFactory::getReader($obj->getDatabaseName());
     if ($dbReader == null) {
         if (LOGGING) {
             Log::log(LoggingConstants::ERROR, "Database reader for " . $databaseName . " not found");
         }
         $writer->writeNull();
         return;
     }
     $arr = array();
     while ($object = $dbReader->readObject($obj->getResource())) {
         $arr[] = $object;
     }
     if ($writer instanceof AmfV3Formatter) {
         MessageWriter::writeObject($arr, $writer);
     } else {
         $remotingDataSet = new RemotingDataSet($arr);
         MessageWriter::writeObject($remotingDataSet->getDataSetInfo(), $writer);
     }
 }