In fact I got inspired by objectify project which gave lots of ideas (If you look at the code, I tell it in a few classes ;) ).
At the beginning, I wanted to provide a simple Future but this interface from Java has the very bad idea to return checked exceptions!!!!!!
so your code ends with lots of try/catch everywhere and this is exactly what we try to prevent in Siena.
That's why, as Objectify proposed, the SienaFuture is just a Future without the Exception problem. It's a simple domain converter class catching chekced exceptions and translating them in Siena Runtime Exceptions.
The other reason also is that GAE functions return a Future object. But then when you call the Future.get() function on it, it returns a GAE entity and not a Siena Entity.
What we want when we call .get() is to retrieve a Siena Model.
So we need to do the mapping to Siena Model also when calling the .get().
That's why I encapsulate the GAE Future into a SienaFutureWrapper (directly inherited from Google FutureWrapper) which provides the mapping feature. Look at the GaeAsyncPersistenceManager to see how it is used.
This wrapper is itself encapsulated into a SienaFutureContainer which allows to hide the Java Future Exception problem.
Concerning the other functions of the Future interface, they are not provided in the SienaFuture but this is only because I didn't use them until now. In fact, I don't really see any problem providing them as the SienaFutureContainer just call the encapsulated Future.
I've just discovered after a few weeks without looking at my code that SienaFutureWrapper directly inherit Google FutureWrapper so for another DB, it shouldn't be very good :D... anyway, this is a first draft and it will need some enhancements IMO.
That's for your comments, it helps me reconsider things ;)
pascal
Hi,
AFAIK, GAE async calls (both datastore and urlfetch) will return their implementation of java.util.concurrent.Future. Any reason why SienaFuture not using it? Is that because to integrate with other DBs? Also, what it's SienaFuture equivalent of cancel / isCancelled / isDone / get(long timeout, TimeUnit unit) ?