Public Member Functions | Protected Member Functions | Friends

atscppapi::TransactionPlugin Class Reference

The interface used when creating a TransactionPlugin. More...

#include <TransactionPlugin.h>

Inherits atscppapi::Plugin.

Inherited by atscppapi::InterceptPlugin, and atscppapi::TransformationPlugin.

Collaboration diagram for atscppapi::TransactionPlugin:
Collaboration graph
[legend]

Public Member Functions

void registerHook (Plugin::HookType hook_type)
 registerHook is the mechanism used to attach a transaction hook.
virtual ~TransactionPlugin ()

Protected Member Functions

 TransactionPlugin (Transaction &transaction)
shared_ptr< MutexgetMutex ()
 This method will return a shared_ptr to a Mutex that can be used for AsyncProvider and AsyncReceiver operations.

Friends

class utils::internal

Detailed Description

The interface used when creating a TransactionPlugin.

A Transaction Plugin is a plugin that will fire only for the specific Transaction it was bound to. When you create a TransactionPlugin you call the parent constructor with the associated Transaction and it will become automatically bound. This means that your TransactionPlugin will automatically be destroyed when the Transaction dies.

Implications of this are that you can easily add Transaction scoped storage by adding a member to a TransactionPlugin since the destructor will be called of your TransactionPlugin any cleanup that needs to happen can happen in your destructor as you normally would.

You must always be sure to implement the appropriate callback for the type of hook you register.

 // For a more detailed example see examples/transactionhook/
 class TransactionHookPlugin : publicTransactionPlugin {
 public:
   TransactionHookPlugin(Transaction &transaction) : TransactionPlugin(transaction) {
     char_ptr_ = new char[100]; // Transaction scoped storage
     registerHook(HOOK_SEND_RESPONSE_HEADERS);
   }
   virtual ~TransactionHookPlugin() {
     delete[] char_ptr_; // cleanup
   }
   void handleSendResponseHeaders(Transaction &transaction) {
     transaction.resume();
   }
 private:
   char *char_ptr_;
 };
See also:
Plugin
HookType

Definition at line 79 of file TransactionPlugin.h.


Constructor & Destructor Documentation

virtual atscppapi::TransactionPlugin::~TransactionPlugin (  )  [virtual]
atscppapi::TransactionPlugin::TransactionPlugin ( Transaction transaction  )  [protected]

Member Function Documentation

shared_ptr<Mutex> atscppapi::TransactionPlugin::getMutex (  )  [protected]

This method will return a shared_ptr to a Mutex that can be used for AsyncProvider and AsyncReceiver operations.

If another thread wanted to stop this transaction from dispatching an event it could be passed this mutex and it would be able to lock it and prevent another thread from dispatching back into this TransactionPlugin.

void atscppapi::TransactionPlugin::registerHook ( Plugin::HookType  hook_type  ) 

registerHook is the mechanism used to attach a transaction hook.

Note:
Whenever you register a hook you must have the appropriate callback definied in your TransactionPlugin see HookType and Plugin for the correspond HookTypes and callback methods. If you fail to implement the callback, a default implmentation will be used that will only resume the Transaction.
Parameters:
HookType the type of hook you wish to register
See also:
HookType
Plugin

Friends And Related Function Documentation

friend class utils::internal [friend]

Reimplemented in atscppapi::InterceptPlugin.

Definition at line 107 of file TransactionPlugin.h.


The documentation for this class was generated from the following file: