Events

Home > Object Persistency API > API Reference > Events

OOMEGA supports the event-driven control flow of modern object-oriented applications. We are committed to the model-view-controller architecture which is best practice in modern applications and user interface toolkits.

Therefore every entity class implements the so called ObservableEO interface with the following two methods:

package org.oomega.persistence;

public interface ObservableEO {
    public void attachObserver(EOObserver observer);
    public void detachObserver(EOObserver observer);
}

So you can register observer objects of type EOObserver with your entities. Just implement the setterCallback method of the EOObserver interface and attach an instance of your observer class to one or more entities.

package org.oomega.persistence;

public interface EOObserver {
    public <T> void setterCallback(EntityObjectTX caller, Property<T> changedField, Collection<T> oldValue);
}

Whenever an entity is changed or deleted all registered EOObserver objects are informed via the automatic execution of the setterCallback method. Observers receive quite accurate information:

  • caller is the source entity of the event: it has been changed or deleted. In the latter case the parameters changedField and oldValue are null.
  • changedField indicates which field, i.e. attribute or navigable association, has been changed.
  • oldValue tells about the field's old value before the change.

Next chapter: Dynamic Access

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.