• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Plugin.h

Go to the documentation of this file.
00001 /**
00002   Licensed to the Apache Software Foundation (ASF) under one
00003   or more contributor license agreements.  See the NOTICE file
00004   distributed with this work for additional information
00005   regarding copyright ownership.  The ASF licenses this file
00006   to you under the Apache License, Version 2.0 (the
00007   "License"); you may not use this file except in compliance
00008   with the License.  You may obtain a copy of the License at
00009 
00010       http://www.apache.org/licenses/LICENSE-2.0
00011 
00012   Unless required by applicable law or agreed to in writing, software
00013   distributed under the License is distributed on an "AS IS" BASIS,
00014   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015   See the License for the specific language governing permissions and
00016   limitations under the License.
00017  */
00018 /**
00019  * @file Plugin.h
00020  *
00021  * @brief Contains the base interface used in creating Global and Transaciton plugins.
00022  * \note This interface can never be implemented directly, it should be implemented
00023  *   through extending GlobalPlugin, TransactionPlugin, or TransformationPlugin.
00024  */
00025 
00026 #pragma once
00027 #ifndef ATSCPPAPI_PLUGIN_H_
00028 #define ATSCPPAPI_PLUGIN_H_
00029 
00030 #include <atscppapi/Transaction.h>
00031 #include <atscppapi/noncopyable.h>
00032 
00033 namespace atscppapi {
00034 
00035 /**
00036  * @brief The base interface used when creating a Plugin.
00037  *
00038  * \note This interface can never be implemented directly, it should be implemented
00039  *   through extending GlobalPlugin, TransactionPlugin, or TransformationPlugin.
00040  *
00041  * @see TransactionPlugin
00042  * @see GlobalPlugin
00043  * @see TransformationPlugin
00044  */
00045 class Plugin: noncopyable {
00046 public:
00047   /**
00048    * A enumeration of the available types of Hooks. These are used with GlobalPlugin::registerHook()
00049    * and TransactionPlugin::registerHook().
00050    */
00051   enum HookType {
00052     HOOK_READ_REQUEST_HEADERS_PRE_REMAP = 0, /**< This hook will be fired before remap has occured. */
00053     HOOK_READ_REQUEST_HEADERS_POST_REMAP, /**< This hook will be fired directly after remap has occured. */
00054     HOOK_SEND_REQUEST_HEADERS, /**< This hook will be fired right before request headers are sent to the origin */
00055     HOOK_READ_RESPONSE_HEADERS, /**< This hook will be fired right after response headers have been read from the origin */
00056     HOOK_SEND_RESPONSE_HEADERS, /**< This hook will be fired right before the response headers are sent to the client */
00057     HOOK_OS_DNS /**< This hook will be fired right after the OS DNS lookup */
00058   };
00059 
00060   /**
00061    * This method must be implemented when you hook HOOK_READ_REQUEST_HEADERS_PRE_REMAP
00062    */
00063   virtual void handleReadRequestHeadersPreRemap(Transaction &transaction) { transaction.resume(); };
00064 
00065   /**
00066    * This method must be implemented when you hook HOOK_READ_REQUEST_HEADERS_POST_REMAP
00067    */
00068   virtual void handleReadRequestHeadersPostRemap(Transaction &transaction) { transaction.resume(); };
00069 
00070   /**
00071    * This method must be implemented when you hook HOOK_SEND_REQUEST_HEADERS
00072    */
00073   virtual void handleSendRequestHeaders(Transaction &transaction) { transaction.resume(); };
00074 
00075   /**
00076    * This method must be implemented when you hook HOOK_READ_RESPONSE_HEADERS
00077    */
00078   virtual void handleReadResponseHeaders(Transaction &transaction) { transaction.resume(); };
00079 
00080   /**
00081    * This method must be implemented when you hook HOOK_SEND_RESPONSE_HEADERS
00082    */
00083   virtual void handleSendResponseHeaders(Transaction &transaction) { transaction.resume(); };
00084 
00085   /**
00086    * This method must be implemented when you hook HOOK_OS_DNS
00087    */
00088   virtual void handleOsDns(Transaction &transaction) { transaction.resume(); };
00089 
00090   virtual ~Plugin() { };
00091 protected:
00092   /**
00093   * \note This interface can never be implemented directly, it should be implemented
00094   *   through extending GlobalPlugin, TransactionPlugin, or TransformationPlugin.
00095   *
00096   * @private
00097   */
00098   Plugin() { };
00099 };
00100 
00101 /**< Human readable strings for each HookType, you can access them as HOOK_TYPE_STRINGS[HOOK_OS_DNS] for example. */
00102 extern const std::string HOOK_TYPE_STRINGS[];
00103 
00104 } /* atscppapi */
00105 
00106 #endif /* ATSCPPAPI_GLOBALPLUGIN_H_ */

Generated by  doxygen 1.7.1