2013-11-26 39 views

回答

0

過濾不RemoteServiceServlets很好工作,所以這些添加到您的RemoteServiceServlet:

RemoteApiOptions options; 
RemoteApiInstaller installer; 

@Override 
protected void onBeforeRequestDeserialized(String serializedRequest) { 
    if (getThreadLocalRequest().getRequestURL().indexOf("127.0.0.1") != -1) { 
     if (options == null) { 
      options = new RemoteApiOptions().server("example.appspot.com", 443).credentials("username", 
        "password"); 
      installer = new RemoteApiInstaller(); 
      try { 
       installer.install(options); 
       options.reuseCredentials("username", installer.serializeCredentials()); 
      } 
      catch (IOException e) { 
       e.printStackTrace(); 
      } 
     } 
     else { 
      installer = new RemoteApiInstaller(); 
      try { 
       installer.install(options); 
      } 
      catch (IOException e) { 
       e.printStackTrace(); 
      } 
     } 
    } 
} 

@Override 
protected void onAfterResponseSerialized(String serializedResponse) { 
    if (getThreadLocalRequest().getRequestURL().indexOf("127.0.0.1") != -1) 
     installer.uninstall(); 
} 
2

是的,你可以使用Google App Engine Remote API連接到生產數據庫。你可以從Gealyk Remote Connector得到靈感,這是完全一樣的。例如,檢查Remote Connector Filter源代碼。基本上你需要創建,如果所安裝的

  1. 檢查遠程API過濾器,如果它不使用定的憑據安裝
  2. 繼續使用chain.doFilter(request, response)
  3. 卸載遠程API安裝程序時,執行應用程序代碼完成

只要小心,根據您的互聯網連接,應用程序可能會很慢,有時甚至超時。

+0

musketyr,你有什麼建議的權利嗎? 「基於OAuth的授權,不支持在App Engine上運行的客戶端」 「http://stackoverflow.com/questions/33815315/how-to-debug-server-code-in-eclipse-on-appengine-database-oauth-基於遠程一個 – lembas

相關問題