[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7. Event delivery

BeanKeeper generates events for each object modification in a node (a node is a Store object and the associated BeanKeeper context). These events can be captured and processed by user code, by implementing the hu.netmind.beankeeper.event.PersistenceEventListener. This interface has only one method:

 
void handle(PersistenceEvent event);

A listener implementing this interface can be registered into the EventDispatcher to receive events. The delivered events will only come from the local node, so no remote events will be received. What's more, the events will be delivered in the same transaction in which the event occured, which means if the event handler does some database operations, those operations will commit with the original transaction, which generated the event.

It is not advised to do non-database operations in these handlers, because the modification indicated by the event may be rolled back at the end of the transaction. If a non-database operation was made, it may not roll back together with the transaction.

The following events are currently available (see apidoc):

Note, that when the event is delivered, the indicated change has already happened, which is reflected in the database too. The events are generated in save() and remove() operations, so not when the object's attribute changes, but when you try to save the changes, or remove the object,


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Robert Brautigam on November, 21 2009 using texi2html 1.78.