In an attempt to be a recession proof Java programmer, I created a new niche microblogging service, http://m.TwoKnobbyTires.com, for outdoor enthusiasts, fans of pro sports, and fans of college sports. It runs on Google App Engine for Java and I hope that someday it will warrant the scalable infrastructure that App Engine provides ;). My microblogging service uses Google Accounts for authentication, App Engine's email service, and the default open source JDO implementation provided by DataNucleus. The following is a getting started guide for programmers considering Google App Engine for Java. For more details about Google App Engine, read Google App Engine For Java - A Microblogging Case Study.
- Start with a new application - App Engine for Java does not support the full Java specification nor all of the frameworks that run on the Java platform. For example, it supports JSTL (allegedly), Java Servlets, and JSPs but does not fully support Struts 2, JDBC, JSF, Hibernate, and EJB. Thus, it is best to start with a new application rather than attempt to port over an existing application that may have compatibility issues. My service runs using plain old Servlets and JSPs; plus Servlet Filters are employed for site wide tasks like pre-loading user data and closing database connections.
- Acclimate to Google's non-relational data store - Google's database is non-relational which was a challenge for me since I have only worked with relational databases (e.g., Oracle, MySQL) . Specifically, Google's database is an object datastore without a schema which means that join queries are not supported and the responsibility for data integrity lies within your code. Some of the data integrity responsibility can be managed by JDO or JPA in the form of one-to-one, one-to-many, and many-to-many relationships. However, I needed to manage some of my object relationships and queries outside of JDO because the JDO annotations plus Google datastore limit the number of relationships an object can have. My application is still experiencing random DatastoreTimeoutExceptions and I have not figured out whether my database is poorly designed or if Google's datastore has been experiencing hiccups in service.
- Automate tests - I used Fitnesse to automate HTML tests for web pages and XML tests for RSS feeds. Automated tests are a good idea regardless of your hosting service but in the case of Google App Engine for Java, there are two good reasons to automate tests:
- Auto generate the datastore index file - Your App Engine database on Google's servers requires a datastore index for every query your application needs to run. The easiest way to generate a datastore index file is to let the Eclipse plugin do it for you. Specifically, run every query in your development environment by using automated tests to trigger them and the Eclipse plugin will update the datastore index file after each query execution. Letting the Eclipse plugin generate the datastore index file is easier and less error prone than writing a datastore index file by hand.
- Quickly adapt to internal redesigns and platform changes - I redesigned the internals of my application several times during the process of adjusting to Google's non-relational datastore. In addition, the Google App Engine for Java platform and service are still under active development. Thus, it is important to create an automated testing suite that can provide rapid feedback on the health of your software so you can quickly and confidently adapt to both internal changes (i.e., your need to redesign to support new features) and external changes (i.e., Google's updating of the App Engine platform).
- Auto generate the datastore index file - Your App Engine database on Google's servers requires a datastore index for every query your application needs to run. The easiest way to generate a datastore index file is to let the Eclipse plugin do it for you. Specifically, run every query in your development environment by using automated tests to trigger them and the Eclipse plugin will update the datastore index file after each query execution. Letting the Eclipse plugin generate the datastore index file is easier and less error prone than writing a datastore index file by hand.
In the past, I compared Java vs. Ruby on Rails and my analysis ended in a tie. I believe that Google App Engine for Java tips the scales back in Java's favor because it solves Java's biggest long-term problem: a lack of affordable, scalable hosting for entrepreneurs. However, I am not convinced that Google App Engine for Java is enterprise ready because there are still too many unsupported Java APIs and frameworks.




