Reputation: 487
I use Google Eclipse Plugin, develop a web page using GWT + GAE/Java. I would like to debug in localhost with the local GWT code but want to use the database in my actual deployed web page.
Is it possible?
Upvotes: 0
Views: 130
Reputation: 487
Filter doesn't work well with RemoteServiceServlets so add these to your 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();
}
Upvotes: 0
Reputation: 828
Yes, you can connect to your production database using Google App Engine Remote API. You can get inspired by Gealyk Remote Connector which is doing exactly the same. Check the Remote Connector Filter source code for example. Basically you need to create filter which
chain.doFilter(request, response)
Just be careful that depending on your internet connection the application might be slow and sometimes timeouts.
Upvotes: 2