Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
14c (14.1.1.0.0)

F23533-01

coherence/net/cache/CacheEvent.hpp

00001 /*
00002 * CacheEvent.hpp
00003 *
00004 * Copyright (c) 2000, 2020, 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/MapListener.hpp"
00023 #include "coherence/util/ObservableMap.hpp"
00024 
00025 COH_OPEN_NAMESPACE3(coherence,net,cache)
00026 
00027 using coherence::util::MapEvent;
00028 using coherence::util::MapListener;
00029 using coherence::util::ObservableMap;
00030 
00031 
00032 /**
00033 * An extension of the MapEvent which allows to differentiate between client
00034 * driven (natural) events and cache internal (synthetic) events.
00035 *
00036 * Consider a client code calling a remove() method for a cache. Quite
00037 * naturally it causes a corresponding entry_deleted event. However, the same
00038 * event could be as well caused by the client code calling put() forcing an
00039 * entry eviction.  Alternatively, the put() method called by client code
00040 * naturally causes either entry_inserted or entry_updated event. However, the
00041 * same event could be as well caused by a client call to a get() method that
00042 * in turn forces an entry insertion by a cache loader.
00043 *
00044 * @author js  2008.06.06
00045 */
00046 class COH_EXPORT CacheEvent
00047     : public class_spec<CacheEvent,
00048         extends<MapEvent> >
00049     {
00050     friend class factory<CacheEvent>;
00051 
00052 
00053     // ----- TransformationState enum ---------------------------------------
00054 
00055     public:
00056         /**
00057         * Transformation state constants.
00058         * TransformationState describes how a CacheEvent has been or should be
00059         * transformed.
00060         */
00061         enum TransformationState
00062             {
00063             /**
00064             * Value used to indicate that an event is non-transformable and should
00065             * not be passed to any transformer-based listeners.
00066             */
00067             non_transformable,
00068 
00069             /**
00070             * Value used to indicate that an event is transformable and could be
00071             * passed to transformer-based listeners.
00072             */
00073             transformable,
00074 
00075             /**
00076             * Value used to indicate that an event has been transformed, and should
00077             * only be passed to transformer-based listeners.
00078             */
00079             transformed
00080             };
00081 
00082 
00083     // ----- constructors ---------------------------------------------------
00084 
00085     protected:
00086         /**
00087         * Create a new CacheEvent.
00088         *
00089         * @param hMap             the map on which the Event initially
00090         * @param nId              occurred the events id (entry_inserted |
00091         *                         entry_updated | entry_deleted)
00092         * @param voKey            the key into the map
00093         * @param voValueOld       the old value (for update and delete events)
00094         * @param voValueNew       the new value (for insert and update events)
00095         * @param fSynthetic       true iff the event is caused by internal
00096         *                         cache processing such as eviction or loading
00097         */
00098         CacheEvent(ObservableMap::Handle hMap, int32_t nId,
00099                 Object::View voKey, Object::View voValueOld,
00100                 Object::View voValueNew, bool fSynthetic);
00101 
00102         /**
00103         * Create a new CacheEvent.
00104         *
00105         * @param hMap             the map on which the Event initially
00106         * @param nId              occurred the events id (entry_inserted |
00107         *                         entry_updated | entry_deleted)
00108         * @param voKey            the key into the map
00109         * @param voValueOld       the old value (for update and delete events)
00110         * @param voValueNew       the new value (for insert and update events)
00111         * @param fSynthetic       true iff the event is caused by internal
00112         *                         cache processing such as eviction or loading
00113         * @param fPriming         a flag indicating whether or not the event
00114         *                         is a priming event
00115         */
00116         CacheEvent(ObservableMap::Handle hMap, int32_t nId,
00117                 Object::View voKey, Object::View voValueOld,
00118                 Object::View voValueNew, bool fSynthetic, bool fPriming);
00119 
00120         /**
00121         * Create a new CacheEvent.
00122         *
00123         * @param hMap             the map on which the Event initially
00124         * @param nId              occurred the events id (entry_inserted |
00125         *                         entry_updated | entry_deleted)
00126         * @param voKey            the key into the map
00127         * @param voValueOld       the old value (for update and delete events)
00128         * @param voValueNew       the new value (for insert and update events)
00129         * @param fSynthetic       true iff the event is caused by internal
00130         *                         cache processing such as eviction or loading
00131         * @param nTransformState  the TransformationState describing how
00132         *                         this event has been or should be transformed
00133         * @since Coherence 3.7.1.9
00134         */
00135         CacheEvent(ObservableMap::Handle hMap, int32_t nId,
00136                 Object::View voKey, Object::View voValueOld,
00137                 Object::View voValueNew, bool fSynthetic, 
00138                 TransformationState nTransformState);
00139 
00140         /**
00141         * Create a new CacheEvent.
00142         *
00143         * @param hMap             the map on which the Event initially
00144         * @param nId              occurred the events id (entry_inserted |
00145         *                         entry_updated | entry_deleted)
00146         * @param voKey            the key into the map
00147         * @param voValueOld       the old value (for update and delete events)
00148         * @param voValueNew       the new value (for insert and update events)
00149         * @param fSynthetic       true iff the event is caused by internal
00150         *                         cache processing such as eviction or loading
00151         * @param nTransformState  the TransformationState describing how
00152         *                         this event has been or should be transformed
00153         * @param fPriming         a flag indicating whether or not the event
00154         *                         is a priming event
00155         * @since 12.2.1.3.2
00156         */
00157         CacheEvent(ObservableMap::Handle hMap, int32_t nId,
00158                 Object::View voKey, Object::View voValueOld,
00159                 Object::View voValueNew, bool fSynthetic,
00160                 TransformationState nTransformState, bool fPriming);
00161 
00162     private:
00163         /**
00164         * Blocked copy constructor.
00165         */
00166         CacheEvent(const CacheEvent&);
00167 
00168         
00169     // ----- CacheEvent interface -------------------------------------------
00170 
00171     public:
00172         /**
00173         * Return true iff this event is caused by internal cache processing
00174         * such as eviction or loading.
00175         *
00176         * @return true iff this event is caused by internal cache processing
00177         */
00178         virtual bool isSynthetic() const;
00179 
00180         /**
00181         * Return transformation state of this event.
00182         * Non-transformable events will not be delivered to MapEventTransformer
00183         * MapEventTransformer listeners.
00184         *
00185         * @return the TransformationState for this event
00186         */
00187         virtual TransformationState getTransformState() const;
00188 
00189         /**
00190         * Return true iff this event is caused by a priming listener registration.
00191         *
00192         * @return true iff this event is caused by a priming listener registration
00193         * @since 12.2.1.3.2
00194         */
00195         virtual bool isPriming() const;
00196 
00197     protected:
00198         /**
00199         * {@inheritDoc}
00200         */
00201         virtual bool shouldDispatch(TypedHandle<const MapListener> vListener) const;
00202 
00203 
00204     // ----- Describable interface ------------------------------------------
00205 
00206     public:
00207         /**
00208         * {@inheritDoc}
00209         */
00210         virtual String::View getDescription() const;
00211 
00212 
00213     // ----- data members ---------------------------------------------------
00214 
00215     protected:
00216         /**
00217         * Event cause flag.
00218         */
00219         bool m_fSynthetic;
00220 
00221         /**
00222         * The TransformationState for this event.
00223         */
00224         TransformationState m_nTransformState;
00225 
00226         /**
00227         * Flag indicating whether or not the event is a priming event (NearCache).
00228         * @since 12.2.1.3.2
00229         */
00230         bool m_fPriming;
00231     };
00232 
00233 COH_CLOSE_NAMESPACE3
00234 
00235 #endif // COH_CACHE_EVENT_HPP
00236 
Copyright © 2000, 2020, Oracle and/or its affiliates. All rights reserved.