00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef COH_NEAR_CACHE_HPP
00017 #define COH_NEAR_CACHE_HPP
00018
00019 #include "coherence/lang.ns"
00020
00021 #include "coherence/net/CacheService.hpp"
00022 #include "coherence/net/MemberListener.hpp"
00023 #include "coherence/net/NamedCache.hpp"
00024
00025 #include "coherence/net/cache/CacheMap.hpp"
00026 #include "coherence/net/cache/CachingMap.hpp"
00027
00028 #include "coherence/util/Comparator.hpp"
00029 #include "coherence/util/ValueExtractor.hpp"
00030
00031 COH_OPEN_NAMESPACE3(coherence,net,cache)
00032
00033 using coherence::net::CacheService;
00034 using coherence::net::MemberListener;
00035 using coherence::net::NamedCache;
00036 using coherence::util::Comparator;
00037 using coherence::util::ValueExtractor;
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 class COH_EXPORT NearCache
00051 : public class_spec<NearCache,
00052 extends<CachingMap>,
00053 implements<NamedCache> >
00054 {
00055 friend class factory<NearCache>;
00056
00057
00058
00059 protected:
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 NearCache(CacheMap::Handle hMapFront, CacheMap::Handle hMapBack,
00072 CachingMap::InvalidationStrategy strategy = listen_auto,
00073 ConcurrentMap::Handle hMapControl = NULL);
00074
00075
00076
00077
00078 public:
00079
00080
00081
00082
00083
00084
00085
00086
00087 virtual NamedCache::Handle getBackCache();
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 virtual NamedCache::View getBackCache() const;
00098
00099
00100
00101
00102 public:
00103
00104
00105
00106 using CachingMap::put;
00107
00108
00109
00110
00111 using CachingMap::keySet;
00112
00113
00114
00115
00116 using CachingMap::entrySet;
00117
00118
00119
00120
00121 public:
00122
00123
00124
00125 virtual String::View getCacheName() const;
00126
00127
00128
00129
00130 virtual NamedCache::CacheServiceHandle getCacheService();
00131
00132
00133
00134
00135 virtual NamedCache::CacheServiceView getCacheService() const;
00136
00137
00138
00139
00140 virtual bool isActive() const;
00141
00142
00143
00144
00145 virtual void release();
00146
00147
00148
00149
00150 virtual void destroy();
00151
00152
00153
00154
00155 public:
00156
00157
00158
00159 virtual void addKeyListener(MapListener::Handle hListener,
00160 Object::View vKey, bool fLite);
00161
00162
00163
00164
00165 virtual void removeKeyListener(MapListener::Handle hListener,
00166 Object::View vKey);
00167
00168
00169
00170
00171 virtual void addMapListener(MapListener::Handle hListener);
00172
00173
00174
00175
00176 virtual void removeMapListener(MapListener::Handle hListener);
00177
00178
00179
00180
00181 virtual void addFilterListener(MapListener::Handle hListener,
00182 Filter::View vFilter = NULL, bool fLite = false);
00183
00184
00185
00186
00187 virtual void removeFilterListener(MapListener::Handle hListener,
00188 Filter::View vFilter = NULL);
00189
00190
00191
00192
00193 public:
00194
00195
00196
00197 virtual Map::View getAll(Collection::View vColKeys) const;
00198
00199
00200
00201
00202 virtual Object::Holder put(Object::View vKey,
00203 Object::Holder ohValue, int64_t cMillis);
00204
00205
00206
00207
00208 public:
00209
00210
00211
00212 virtual bool lock(Object::View vKey, int64_t cWait) const;
00213
00214
00215
00216
00217 virtual bool lock(Object::View vKey) const;
00218
00219
00220
00221
00222 virtual bool unlock(Object::View vKey) const;
00223
00224
00225
00226
00227 public:
00228
00229
00230
00231 virtual Set::View keySet(Filter::View vFilter) const;
00232
00233
00234
00235
00236 virtual Set::View entrySet(Filter::View vFilter) const;
00237
00238
00239
00240
00241 virtual Set::View entrySet(Filter::View vFilter,
00242 Comparator::View vComparator) const;
00243
00244
00245
00246
00247 virtual void addIndex(ValueExtractor::View vExtractor, bool fOrdered,
00248 Comparator::View vComparator);
00249
00250
00251
00252
00253 virtual void removeIndex(ValueExtractor::View vExtractor);
00254
00255
00256
00257
00258 public:
00259
00260
00261
00262 virtual Object::Holder invoke(Object::View vKey,
00263 EntryProcessor::Handle hAgent);
00264
00265
00266
00267
00268 virtual Map::View invokeAll(Collection::View vCollKeys,
00269 EntryProcessor::Handle hAgent);
00270
00271
00272
00273
00274 virtual Map::View invokeAll(Filter::View vFilter,
00275 EntryProcessor::Handle hAgent);
00276
00277
00278
00279
00280 virtual Object::Holder aggregate(Collection::View vCollKeys,
00281 EntryAggregator::Handle hAgent) const;
00282
00283
00284
00285
00286 virtual Object::Holder aggregate(Filter::View vFilter,
00287 EntryAggregator::Handle hAgent) const;
00288
00289
00290
00291
00292 protected:
00293
00294
00295
00296 virtual void onInit();
00297
00298
00299
00300
00301 protected:
00302
00303
00304
00305
00306
00307 virtual void release(bool fDestroy);
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 virtual MemberListener::Handle registerBackServiceListener();
00319
00320
00321
00322
00323 virtual void unregisterBackServiceListener();
00324
00325
00326
00327
00328 protected:
00329
00330
00331
00332 FinalView<String> f_vsName;
00333
00334
00335
00336
00337 FinalHandle<CacheService> f_hService;
00338
00339
00340
00341
00342 FinalHandle<MemberListener> f_hListenerBackService;
00343 };
00344
00345 COH_CLOSE_NAMESPACE3
00346
00347 #endif // COH_NEAR_CACHE_HPP