Tuesday, 24 April 2012

How to use Force.com Database SDK on Google APP Engine

It has been a couple of months I’ve started to work on a cloud project. To reduce costs, I’ve then decided to host the app on GAE while the database should be host on database.com. By these days, I just know that GAE support JPA with datanucleus API, and that database.com provides an extension of datanucleus that could be used to work with its database: it was quite fine for me. But the thing I didn’t figure is that GAE only support version 1 of datanucleus while database.com supports version 2, and moreover these two versions were incompatibles. I was then stuck with a problem: How to access my database hosted of Force.com from my application hosted on GAE? It’s true I’d a choice, the one of using web services, but it will break my architecture since I wanted all my business code to be hosted on GAE, and I also like working with JPA. I’ve then started to find if someone faced the same problem and how it’s been overcome, but I’ve not been satisfied. Therefore, when in January Google decided to provide an implementation of datanucleus 3, I thought it was time to modify Force.com SDK to let it work with datanucleus 3 and therefore to be compatible with GAE.
I then downloaded Force.com SDK source code and started to work on it, and after few weeks I ended with a first version that supports datanucleus 3.0.6, and I integrated this version in my app, and it worked quite fine. However this version suffers of two problems: 
  1. You can’t use it to enhance your classes: Since each entity class need to be enhanced before used, I’ve used existent version of Force.com SDK API to enhance my classes (in a separate project) before integrating them in my final project. 
  2. This version only works with datanucleus 3.0.6: I plan to upgrade it to make it work with the recent versions of datanucleus. 
I have created an open source GIT repository where I’ve put sources, and then changes could be added as measure as it is needed. However, you could find attached to this document the libraries modified you could use within yours GAE Projects. I hope it will be helpful for you...

No comments:

Post a Comment

Post a Comment