Sunday, June 23, 2013

Setting up Dagger on Eclipse for Google App Engine

Dagger is a dependency injection framework similar to Guice, but code can be generated at compile time to wire together dependencies instead of using reflection at run time.  It's written by some of the same guys who created Guice and had problems with its speed when it runs on Android.

I also have problems with the start-up time of Guice on Google App Engine where "loading requests" can keep a user waiting for your app to get itself up and running.

Dagger promises to shave some precious seconds off this app startup time and probably also make each request faster.  Reflective calls on App Engine can be slow - I don't know how slow but will eventually run some tests to see how much difference Dagger makes.

To get it running in Eclipse you need to modify your projects settings under Java Compiler > Annotation Processing > Factory Path and add the following 4 jar files: dagger-x.x.x.jar, dagger-compiler-x.x.x.jar, javax.inject.jar and javawriter-x.x.x.jar

You also need to tick the "Enable project specific settings" in the parent configuration page" for these settings to take effect.