The interface used when creating a TransactionPlugin. More...
#include <TransactionPlugin.h>
Inherits atscppapi::Plugin.
Inherited by atscppapi::InterceptPlugin, and atscppapi::TransformationPlugin.
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< Mutex > | getMutex () |
This method will return a shared_ptr to a Mutex that can be used for AsyncProvider and AsyncReceiver operations. | |
Friends | |
class | utils::internal |
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_; };
Definition at line 79 of file TransactionPlugin.h.
virtual atscppapi::TransactionPlugin::~TransactionPlugin | ( | ) | [virtual] |
atscppapi::TransactionPlugin::TransactionPlugin | ( | Transaction & | transaction | ) | [protected] |
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.
HookType | the type of hook you wish to register |
friend class utils::internal [friend] |
Reimplemented in atscppapi::InterceptPlugin.
Definition at line 107 of file TransactionPlugin.h.