h1. Google App Engine support

The GAE module enables Google App Engine support for your application. It wraps commons GAE services in play basic services whenever possible (Logging, Mail, Cache...) and expose directly other Google specifics services (User services, Datastore...)

Moreover, this module sets up a GAE development environment directly in the play development server, so you don't need to develop directly in the Google App Engine SDK (but it's supported too).

h2. <a>What is supported?</a>

* The application layout is totally standard.
* Auto reload works as expected.
* Logging is correctly dispatched to java.util.logging when the module is enabled.
* tmp folder is disabled because you can't write to the filesystem in GAE.
* Direct datastore access is fully supported.
* JPA support can be enabled but you still depends on GAE JPA limitations and you cannot extend play JPASupport.
* Cache is correctly wrapped to the GAE memcached instance.
* Mail is correctly wrapped to the GAE mail service.
* Users services is available with a 'sign in' page simulation in the development server.
* You can still break out your application into several modules.
* PROD mode is forced when the application is running on the GAE production environment.

h2. <a>Setting up the GAE module</a>

Start to create a new application in the classical way.

bc. # play new test-gae

Then edit the **conf/application.conf** file to enable the GAE module:

bc. # Additional modules
# ~~~~~
# A module is another play! application. Add a line for each module you want
# to add to your application. Module paths are either absolutes or relative to
# the application root.
#
module.gae=${play.path}/modules/gae

Now you can start your application, and play will start a GAE development environment:

bc. # play run test-gae
 
~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.1 http://www.playframework.org
~
~ Ctrl+C to stop
~ 
11:37:02,228 INFO  ~ Starting /Volumes/Data/Desktop/test-gae
11:37:02,240 INFO  ~ Module gae is available (/Volumes/Data/Desktop/play/modules/gae)
11:37:02,350 WARN  ~ 
11:37:02,351 WARN  ~ Google App Engine module
11:37:02,351 WARN  ~ ~~~~~~~~~~~~~~~~~~~~~~~
11:37:02,351 WARN  ~ No Google App Engine environment found. Setting up a development environment
11:37:02,379 WARN  ~ Don't forget to define your GAE application id in the 'war/WEB-INF/appengine-web.xml' file
11:37:02,379 WARN  ~ 
11:37:02,380 WARN  ~ You're running play in DEV mode
11:37:02,381 INFO  ~ Application 'Test of GAE' is ready !
11:37:02,529 INFO  ~ Listening for HTTP on port 9000 ...
11:37:02,529 INFO  ~ 

A blank **appengine-web.xml** file has been created in the **war/WEB-INF** directory. Don't forget to set up a correct GAE application id before running it into the GAE SDK.

p(note). **Note**
 
Content of the **war** directory will be merged during the war export command. It's not specific to the GAE module.

h2. <a>Deployment</a>

To deploy your application to Google's cloud, you can use the **gae:deploy** command. You need to specify the location of the GAE sdk using the **--gae** option:

bc. # play gae:deploy --gae=/Users/guillaume/Desktop/appengine-sdk-1.4.0

Make sure to specify your GAE application id in the 'war/WEB-INF/appengine-web.xml' file.

h2. <a>About JPA</a>

Play offers a cool abstraction of JPA through the JPASupport/Model classes. But when you use these classes on GAE a lot of problems occur. This is because the JPA support in GAE is very different of Hibernate + a relational database.

There are two reasons you would like use JPA on Google App Engine :

* To be able to transparently move your application in/out of GAE
* Because you already know the JPA API very well, and you want reuse this knowledge.

But these 2 reasons fail. The JPA support is so different in GAE that you just can't use it in a transparent way. It will work only for a single simple entity without relations. But even with a simple relation, you'll have to rely on special Google classes. And because the JPA support is very different,
you can't do things the way you are used to.

That's why our advice is to not use JPA on Google App Engine. If you really want to use JPA, you should avoid using the JPASupport/Model helpers and just rely on simple JPA examples that Google provides.

We provide an alternative persistence manager module called "Siena":http://www.playframework.org/modules/siena. It's a better match and your application code should be even simpler than if you used JPA.

h2. <a>Sample application</a>

You can take a look at the **samples-and-tests/lists-with-gae** as a sample of a real Google App Engine application.

p(note). **This app is available online** at "http://play-lists.appspot.com":http://play-lists.appspot.com.
