blob: b9621e2a19777e4c95f5ba104082c3c5261fd20e [file] [log] [blame]
Title: DataContextDelegate
<P>DataContext supports runtime customization via a DataContextDelegate interface. A user can assign a custom delegate instance to a DataContext by calling DataContext.setDelegate(..). Delegate is optional, and if it is not set, DataContext would go on with its default behavior. If a delegate is set, DataContext consults with it at some critical points in the normal flow execution. A delegate can modify the flow, abort an operation, modify objects participating in an operation, or perform any other tasks it deems necessary.</P>
<P>DataContextDelegate currently has two groups of methods - method to filter select queries, and methods to react to external updates of the ObjectStore:</P>
<UL>
<LI><TT>public Query willPerformQuery(DataContext context, Query query)</TT></LI>
</UL>
<P>Called from DataContext.performQuery(...) before running any select query, including prefetch queries. Implementation has a choice to modify an original query, replace it with alternative one, or return NULL, blocking query execution alltogether.</P>
<UL>
<LI><TT>public boolean shouldMergeChanges(DataObject object, DataRow snapshotInStore)</TT><BR>
<TT>public boolean shouldProcessDelete(DataObject object)</TT><BR>
<TT>public void finishedMergeChanges(DataObject object)</TT><BR>
<TT>public void finishedProcessDelete(DataObject object)</TT></LI>
</UL>
<P>These methods are called by the ObjectStore whenever it performs an update of its state triggered by external events. Default ObjectStore behavior is to merge all changes to the existing objects, and change deleted objects state to TRANSIENT, removing them from the store. Delegate has an option to abort standard processing by returning &quot;false&quot; from &quot;should*&quot; methods.</P>