Committed callbacks can be used in various scenarios:
This example shows you how to refresh objects on a client on commits.
When several clients are working on the same objects it is possible that the data will be outdated on a client. You can use the committed-event refresh object on each commit.
When a client commit will trigger a committed event on all clients. In order to refresh the object, register for the committed event. In the commit-event-handler, refresh the object which have been modified.
EventRegistry events = EventRegistryFactory.forObjectContainer(container); events.committed().addListener(new EventListener4<CommitEventArgs>() { public void onEvent(Event4<CommitEventArgs> commitEvent, CommitEventArgs commitEventArgs) { for(Iterator4 it = commitEventArgs.updated().iterator();it.moveNext();){ LazyObjectReference reference = (LazyObjectReference) it.current(); Object obj = reference.getObject(); commitEventArgs.objectContainer().ext().refresh(obj,1); } } });
You can register such a event-handler for each client. The committed event is transferred to each client. Note that this requires a lot of network-traffic to notify all clients and transfer the changes.
When working with committed events you should remember that the listener is called on a separate thread, which needs to be synchronized with the rest of the application.