TurboManage

David Chandler's Journal of Java Web and Mobile Development

Archive for October 15th, 2009

GWT + GAE and the Balm of GILEAD

Posted by David Chandler on October 15, 2009

My domain model is getting real now and I’ve had to use AppEngine’s Key class in one of my domain objects to model a one-to-many relationship:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class PrayerList implements Serializable
{
	...
	@Persistent
	private Key listOwner;
	...
}

As has been discussed in several forums, GWT does not emulate any AppEngine classes, so there are a few possible workarounds:

  1. Create a DTO that does not contain any AppEngine classes for each domain object. DTOs, yuck.
  2. Provide an emulated Key class yourself following Fred Sauer’s fine instructions.
  3. Use the GILEAD project’s Adapter4AppEngine, which supplies GWT with emulated classes for AppEngine’s Key, Text, Blob, and other troublesome types.

Without Adapter4AppEngine:

Removing units with errors
 [ERROR] Errors in 'file:/C:/Users/David/workspace/ROA/src/com/roa/client/domain/PrayerList.java'
 [ERROR] Line 12: The import com.google.appengine cannot be resolved
 [ERROR] Line 30: Key cannot be resolved to a type

With Adapter4AppEngine:

Compiling 6 permutations
 Permutation compile succeeded

According to the GILEAD project’s home page,

Gilead stands for Generic Light Entity Adapter

It permits you to send Persistent entities (and especially the partially loaded ones) outside the JVM (GWT, Flex, Web-Services, Google AppEngine …) without pain.

Adapter4AppEngine is simple to use. Just drop in the jar and add the required <inherits> tag in your gwt.xml.

Nice!

Posted in AppEngine, Google Web Toolkit | 3 Comments »