我使用插件,使用GWT + GAE/Java开发一个网页。我希望在本地主机中使用本地GWT代码进行调试,但希望在实际部署的网页中使用数据库。
有可能吗?
发布于 2013-11-28 08:24:39
过滤器在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();
}发布于 2013-11-26 17:45:25
是的,您可以使用远程API连接到生产数据库。你可以从Gealyk远程连接器中得到灵感,它也在做同样的事情。例如,检查远程连接器滤波器源代码。基本上,您需要创建过滤器
chain.doFilter(request, response)继续您的应用程序代码只是要注意,取决于您的互联网连接,应用程序可能是缓慢的,有时超时。
https://stackoverflow.com/questions/20221797
复制相似问题