Callback Classes
The callback classes use the interface-implementation and producer-product patterns used in SourcePro DB.
The following four classes provide the callback framework:
*RWDBDatabaseCallback — This is the interface handle class which encapsulates a reference-counted pointer to the RWDBDatabaseCallbackImp implementation class.
*RWDBConnCallback — This is the interface handle class which encapsulates a reference-counted pointer to the RWDBConnCallbackImp implementation class.
*RWDBDatabaseCallbackImp — This is the abstract base class for the database callback. You will need to derive from this class to implement the database callbacks. This is an implementation class and is reference counted.
*RWDBConnCallbackImp — This is the abstract base class for the connection callback. You will need to derive from this class to implement the connection callbacks. This is an implementation class and is reference counted.
The following class diagram shows part of the structure of the implementation classes.
Figure 6 – Callback classes
An instance of the database callback can be supplied in the RWDBDatabase producer method RWDBManager::database(). It accepts an RWDBDatabaseCallback instance and associates the callback with the RWDBDatabase instance produced. The RWDBDatabase object then invokes the callbacks from the RWDBDatabaseCallback instance. When a connection is produced from this RWDBDatabase with no explicit RWDBConnCallback object specified, the connection takes the connection callback produced by the producer method RWDBDatabaseCallback::produceConnCallback().
An instance of the connection callback can be supplied in the RWDBConnection producer method RWDBDatabase::connection(), which takes a custom instance of RWDBConnCallback to associate with this particular connection. This connection will not produce the RWDBConnCallback from the producer method RWDBDatabaseCallback::produceConnCallback(), but instead will use the one supplied. Since this RWDBConnection object has a custom connection callback, the connection will not be fetched from the connection pool nor will it be returned to the connection pool after its use. A new database connection will be produced and it will be destroyed after all references to it go out of scope.
Please refer to the SourcePro API Reference Guide for API details.
The following class diagram explains the relationship between the callback classes and the related database classes.
Figure 7 – Class relationship diagram