Documentation Archive Developer
Search
PATH  WebObjects 4.5 Documentation > EOAdaptor Reference

Table of Contents

EOAdaptorContext



Controlling Transactions

EOAdaptorContext defines a simple set of methods for explicitly controlling transactions: beginTransaction, commitTransaction, and rollbackTransaction. Each of these messages confirms the requested action with the adaptor context's delegate, then performs the action if possible.

There's also a set of methods for notifying an adaptor context that a transaction has been started, committed, or rolled back without using the beginTransaction, commitTransaction, or rollbackTransaction methods. For example, if you invoke a stored procedure in the server that begins a transaction, you need to notify the adaptor context that a transaction has been started. Use the following methods to keep an adaptor context synchronized with the state of the database server: transactionDidBegin, transactionDidCommit, and transactionDidRollback. These methods post notifications.


The Adaptor Context's Delegate and Notifications

You can assign a delegate to an adaptor context. The delegate responds to certain messages on behalf of the context. An EOAdaptorContext sends these messages directly to its delegate. The transaction-controlling methods- beginTransaction, commitTransaction, and rollbackTransaction-notify the adaptor context's delegate before and after a transaction operation is performed. Some delegate methods, such as adaptorContextShouldBegin, let the delegate determine whether the context should perform an operation. Others, such as adaptorContextDidBegin, are simply notifications that an operation has occurred. The delegate has an opportunity to respond by implementing the delegate methods. If the delegate wants to intervene, it implements adaptorContextShouldBegin. If it simply wants notification when a transaction has begun, it implements adaptorContextDidBegin.

EOAdaptorContext also posts notifications to the application's default notification center. Any object may register to receive one or more of the notifications posted by an adaptor context by registering as an observer with the default notification center (an instance of the NSNotificationCenter class). For more information on notifications, see the NSNotificationCenter class specification in the Foundation Framework Reference.


Creating an EOAdaptorContext Subclass

EOAdaptorContext provides many default method implementations that are sufficient for concrete subclasses. The following methods establish structure and conventions that other Enterprise Objects Framework classes depend on and should be overridden with caution:

If you override any of the above methods, your implementations should incorporate the superclass's implementation through a message to super.

Other methods require database-specific implementations that can be provided only by a concrete adaptor context subclass. A subclass must override the following methods in terms of the persistent storage system to which it interacts:


Table of Contents