00001 /* 00002 * CacheEvent.hpp 00003 * 00004 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 00005 * 00006 * Oracle is a registered trademarks of Oracle Corporation and/or its 00007 * affiliates. 00008 * 00009 * This software is the confidential and proprietary information of Oracle 00010 * Corporation. You shall not disclose such confidential and proprietary 00011 * information and shall use it only in accordance with the terms of the 00012 * license agreement you entered into with Oracle. 00013 * 00014 * This notice may not be removed or altered. 00015 */ 00016 #ifndef COH_CACHE_EVENT_HPP 00017 #define COH_CACHE_EVENT_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/util/MapEvent.hpp" 00022 #include "coherence/util/ObservableMap.hpp" 00023 00024 COH_OPEN_NAMESPACE3(coherence,net,cache) 00025 00026 using coherence::util::MapEvent; 00027 using coherence::util::ObservableMap; 00028 00029 00030 /** 00031 * An extension of the MapEvent which allows to differentiate between client 00032 * driven (natural) events and cache internal (synthetic) events. 00033 * 00034 * Consider a client code calling a remove() method for a cache. Quite 00035 * naturally it causes a corresponding entry_deleted event. However, the same 00036 * event could be as well caused by the client code calling put() forcing an 00037 * entry eviction. Alternatively, the put() method called by client code 00038 * naturally causes either entry_inserted or entry_updated event. However, the 00039 * same event could be as well caused by a client call to a get() method that 00040 * in turn forces an entry insertion by a cache loader. 00041 * 00042 * @author js 2008.06.06 00043 */ 00044 class COH_EXPORT CacheEvent 00045 : public class_spec<CacheEvent, 00046 extends<MapEvent> > 00047 { 00048 friend class factory<CacheEvent>; 00049 00050 00051 // ----- TransformationState enum --------------------------------------- 00052 00053 public: 00054 /** 00055 * Transformation state constants. 00056 * TransformationState describes how a CacheEvent has been or should be 00057 * transformed. 00058 */ 00059 enum TransformationState 00060 { 00061 /** 00062 * Value used to indicate that an event is non-transformable and should 00063 * not be passed to any transformer-based listeners. 00064 */ 00065 non_transformable, 00066 00067 /** 00068 * Value used to indicate that an event is transformable and could be 00069 * passed to transformer-based listeners. 00070 */ 00071 transformable, 00072 00073 /** 00074 * Value used to indicate that an event has been transformed, and should 00075 * only be passed to transformer-based listeners. 00076 */ 00077 transformed 00078 }; 00079 00080 00081 // ----- constructors --------------------------------------------------- 00082 00083 protected: 00084 /** 00085 * Create a new CacheEvent. 00086 * 00087 * @param hMap the map on which the Event initially 00088 * @param nId occurred the events id (entry_inserted | 00089 * entry_updated | entry_deleted) 00090 * @param voKey the key into the map 00091 * @param voValueOld the old value (for update and delete events) 00092 * @param voValueNew the new value (for insert and update events) 00093 * @param fSynthetic true iff the event is caused by internal 00094 * cache processing such as eviction or loading 00095 */ 00096 CacheEvent(ObservableMap::Handle hMap, int32_t nId, 00097 Object::View voKey, Object::View voValueOld, 00098 Object::View voValueNew, bool fSynthetic); 00099 00100 /** 00101 * Create a new CacheEvent. 00102 * 00103 * @param hMap the map on which the Event initially 00104 * @param nId occurred the events id (entry_inserted | 00105 * entry_updated | entry_deleted) 00106 * @param voKey the key into the map 00107 * @param voValueOld the old value (for update and delete events) 00108 * @param voValueNew the new value (for insert and update events) 00109 * @param fSynthetic true iff the event is caused by internal 00110 * cache processing such as eviction or loading 00111 * @param nTransformState the TransformationState describing how 00112 * this event has been or should be transformed 00113 * @since Coherence 3.7.1.9 00114 */ 00115 CacheEvent(ObservableMap::Handle hMap, int32_t nId, 00116 Object::View voKey, Object::View voValueOld, 00117 Object::View voValueNew, bool fSynthetic, 00118 TransformationState nTransformState); 00119 00120 private: 00121 /** 00122 * Blocked copy constructor. 00123 */ 00124 CacheEvent(const CacheEvent&); 00125 00126 00127 // ----- CacheEvent interface ------------------------------------------- 00128 00129 public: 00130 /** 00131 * Return true iff this event is caused by internal cache processing 00132 * such as eviction or loading. 00133 * 00134 * @return true iff this event is caused by internal cache processing 00135 */ 00136 virtual bool isSynthetic() const; 00137 00138 /** 00139 * Return transformation state of this event. 00140 * Non-transformable events will not be delivered to MapEventTransformer 00141 * MapEventTransformer listeners. 00142 * 00143 * @return the TransformationState for this event 00144 */ 00145 virtual TransformationState getTransformState() const; 00146 00147 00148 // ----- Describable interface ------------------------------------------ 00149 00150 public: 00151 /** 00152 * {@inheritDoc} 00153 */ 00154 virtual void outputDescription(std::ostream& out) const; 00155 00156 00157 // ----- data members --------------------------------------------------- 00158 00159 protected: 00160 /** 00161 * Event cause flag. 00162 */ 00163 bool m_fSynthetic; 00164 00165 /** 00166 * The TransformationState for this event. 00167 */ 00168 TransformationState m_nTransformState; 00169 }; 00170 00171 COH_CLOSE_NAMESPACE3 00172 00173 #endif // COH_CACHE_EVENT_HPP 00174