简体   繁体   中英

How to create a application that works both on Google App Engine and Local tomcat server?

I am creating a java based application and i want to use google app engine for its deployment. But i want this application to be movable to other servers like tomcat etc on my local or other machines. So i though want to use google app engine. But want to keep my application independent of any Google specific things. Can somebody summarize the points i must take care of. I want to keep it independent both from application and database layer perspective.

Though I am not master in google app engine however the thumb rule to make your webapp portable is to use standard specification APIs instead of vendor specific APIs. For example if your app is using google app engine UserServive (com.google.appengine.api.users.UserService) or data store com.google.appengine.api.datastore.DatastoreService , if is tightly bound with Google app engine and can not be migrated to standalone tomcat engine. To loose couple your database for further migration you should consider using MySQl schema in google app engine. Because in future you can host your database anywhere by just taking a dump. Also, you should use JDBC apis/JPA for database operations from your application using MySQL JDBC JAR

To summarize, you should avoid any API call which has com.google.appengine* import in your source. Also, you should have your own mysql schema running in google app engine cloud.

I think you can and it's only a matter of design. Just an example: if your application need user authentication, you can create an interface AuthenticationService and two implementations:

  • GAEAuthenticationService for the Google App Engine
  • FakeAuthenticationService for local tests running with jetty (for example)
  • DataSourceAuthenticationService for authentication based on a DataSource

You can do the same think with persistence, scheduler, etc... the only thing to do is:

define the objects you need and use interfaces when you need different implementations that depends on platforms

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM