Asynchronous Wrapper

44 views
Skip to first unread message

Salomon Brys

unread,
Jul 31, 2012, 11:54:41 AM7/31/12
to objectify...@googlegroups.com
Hi there.

I find myself having an issue which, I think, would mean re-thinking SaverWrapper :
I'm currently developping a very simple library that will allow Objectify entities to be searchable using the new Full Text Search API.

While I'm not going to go into to much detail (I promess I will first release this library on this mailing list), the thing is, 

The problem is that, on save, I need to be able to make an action AFTER the save has been done cause I need the key of the entity.
So, I can :
 - Remove the asynchronicity
 - ???

Please help !

Bien cordialement,
Salomon BRYS

--

     


Jeff Schnitzer

unread,
Aug 7, 2012, 7:04:59 PM8/7/12
to objectify...@googlegroups.com
Sorry, somehow I missed this message.  I hope you found a solution!  You can easily remove asynchrony from the wrapper just by calling now() on the Result before you pass it back.

Jeff

Salomon Brys

unread,
Aug 8, 2012, 4:30:46 AM8/8/12
to objectify...@googlegroups.com
Thanks for noticing ;)

I haven't found a satisfying solution, so maybe you can help me out.
Here are the 2 solutions I'm thinking of :
 - Creating a new filter and requiring users to use it if they don't directly use now().
 - Using ObjectifyFilter. But your filter is using PendingFutures class which uses future, so I'd have to encapsulate the wrapper result into a future, then encapsulate this future into a TriggerFuture to make the tratment only once, then encapsulate this trigger future back into a Result so I can return it. That's a bit... over-encapsulating, is it not ?


Bien cordialement,
Salomon BRYS

--

     




Jeff Schnitzer

unread,
Aug 20, 2012, 10:28:05 PM8/20/12
to objectify...@googlegroups.com
It sounds like what you really want is some sort of event hook inside of Objectify so that you get notification when entities are saved, loaded, etc.  It's a pretty good idea, worth creating a feature request for.  Want to take a stab at implementation?  I picture you register event handlers on the factory at startup time, then they get called whenever some action happens.

Jeff
Reply all
Reply to author
Forward
0 new messages