Event notification mechanism

Another great feature is OOMEGA's incorporated event notification mechanism: you are able to observe every entity object of your choice.

// an observer must only implement the setterCallback() method
public class DemoObserver implements EOObserver
{
  public void setterCallback(EntityObjectTX caller,
    FieldPath field, Object oldValue)
  {
    System.out.println("Entity has been modified in field '" +
      field.syntax(0) + "'");
  }
}

Now, you can attach the observer to entity objects as it is shown below.

// create an entity object
Person person = eocSession.insert(Person());

// create and attach the observer
EOObserver observer = new DemoObserver();
person.attachObserver(observer);

// change the birthday of the observed entity
person.setBirthDay( new java.util.Date() );

This will lead to the following console output.

Entity has been modified in field 'birthDay'
>> Show next feature
>> Back to the feature list