Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47891-01

coherence/net/cache/BundlingNamedCache.hpp

00001 /*
00002 * BundlingNamedCache.hpp
00003 *
00004 * Copyright (c) 2000, 2014, 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_BUNDLING_NAMED_CACHE_HPP
00017 #define COH_BUNDLING_NAMED_CACHE_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/net/NamedCache.hpp"
00022 #include "coherence/net/cache/AbstractBundler.hpp"
00023 #include "coherence/net/cache/AbstractEntryBundler.hpp"
00024 #include "coherence/net/cache/AbstractKeyBundler.hpp"
00025 #include "coherence/net/cache/WrapperNamedCache.hpp"
00026 #include "coherence/util/Collection.hpp"
00027 #include "coherence/util/Collections.hpp"
00028 #include "coherence/util/Map.hpp"
00029 
00030 COH_OPEN_NAMESPACE3(coherence,net,cache)
00031 
00032 using coherence::net::NamedCache;
00033 using coherence::util::Collection;
00034 using coherence::util::Collections;
00035 using coherence::util::Map;
00036 
00037 /**
00038  * Bundling NamedCache implementation.
00039  *
00040  * @see AbstractBundler
00041  * @author gg 2007.02.13
00042  * @author lh 2012.06.05
00043  * @since Coherence 12.1.2
00044  */
00045 class COH_EXPORT BundlingNamedCache
00046     : public class_spec<BundlingNamedCache,
00047         extends<WrapperNamedCache> >
00048     {
00049     friend class factory<BundlingNamedCache>;
00050 
00051     // ----- handle definitions (needed for nested classes) -----------------
00052 
00053     public:
00054         typedef this_spec::Handle Handle;
00055         typedef this_spec::View   View;
00056         typedef this_spec::Holder Holder;
00057 
00058     // ----- constructors ---------------------------------------------------
00059 
00060     protected:
00061         /**
00062          * Construct a BundlingNamedCache based on the specified NamedCache.
00063          *
00064          * @param hCache  the NamedCache that will be wrapped by this 
00065          *                BundlingNamedCache
00066          */
00067         BundlingNamedCache(NamedCache::Handle hCache);
00068 
00069     private:
00070         /**
00071          * Blocked copy constructor.
00072          */
00073         BundlingNamedCache(const BundlingNamedCache&);
00074 
00075     // ----- initiators ------------------------------------------------------
00076 
00077     public:
00078         /**
00079          * Configure the bundler for the "get" operations. If the bundler does
00080          * not exist and bundling is enabled, it will be instantiated.
00081          *
00082          * @param cBundleThreshold  the bundle size threshold; pass zero to
00083          *                          disable "get" operation bundling
00084          *
00085          * @return the "get" bundler or NULL if bundling is disabled
00086          */
00087         virtual AbstractBundler::Handle ensureGetBundler(int32_t cBundleThreshold);
00088 
00089         /**
00090          * Configure the bundler for the "put" operations. If the bundler does
00091          * not exist and bundling is enabled, it will be instantiated.
00092          *
00093          * @param cBundleThreshold  the bundle size threshold; pass zero to
00094          *                          disable "put" operation bundling
00095          *
00096          * @return the "put" bundler or NULL if bundling is disabled
00097          */
00098         virtual AbstractBundler::Handle ensurePutBundler(int32_t cBundleThreshold);
00099 
00100         /**
00101          * Configure the bundler for the "remove" operations. If the bundler
00102          * does not exist and bundling is enabled, it will be instantiated.
00103          *
00104          * @param cBundleThreshold  the bundle size threshold; pass zero to
00105          *                          disable "remove" operation bundling
00106          *
00107          * @return the "remove" bundler or NULL if bundling is disabled
00108          */
00109         virtual AbstractBundler::Handle ensureRemoveBundler(int32_t cBundleThreshold);
00110 
00111     // ----- accessors -------------------------------------------------------
00112 
00113     public:
00114         /**
00115          * Obtain the bundler for the "get" operations.
00116          *
00117          * @return the "get" bundler
00118          */
00119         virtual AbstractBundler::Handle getGetBundler();
00120 
00121         /**
00122          * Obtain the bundler for the "put" operations.
00123          *
00124          * @return the "put" bundler
00125          */
00126         virtual AbstractBundler::Handle getPutBundler();
00127 
00128         /**
00129          * Obtain the bundler for the "remove" operations.
00130          *
00131          * @return the "remove" bundler
00132          */
00133         virtual AbstractBundler::Handle getRemoveBundler();
00134         
00135     // ----- various bundleable NamedCache methods ---------------------------
00136 
00137     public:
00138         using WrapperNamedCache::get;
00139         using WrapperNamedCache::getAll;
00140         using WrapperNamedCache::put;
00141 
00142         /**
00143          * {@inheritDoc}
00144          */
00145         virtual Object::Holder get(Object::View vKey);
00146 
00147         /**
00148          * {@inheritDoc}
00149          */
00150         virtual Map::View getAll(Collection::View vColKeys);
00151 
00152         /**
00153          * {@inheritDoc}
00154          *
00155          * <b>Note:</b> this method always returns NULL.
00156          */
00157         virtual Object::Holder put(Object::View vKey, Object::Holder ohValue);
00158 
00159         /**
00160          * {@inheritDoc}
00161          */
00162         virtual void putAll(Map::View vMap);
00163 
00164         /**
00165          * {@inheritDoc}
00166          *
00167          * <b>Note:</b> this method always returns NULL.
00168          */
00169         virtual Object::Holder remove(Object::View vKey);
00170 
00171     // ----- NamedCache interface --------------------------------------------
00172 
00173         /**
00174          * {@inheritDoc}
00175          */
00176         virtual void release();
00177 
00178         /**
00179          * {@inheritDoc}
00180          */
00181         virtual void destroy();
00182 
00183     // ----- inner classes ---------------------------------------------------
00184 
00185     public:
00186         class COH_EXPORT GetBundler
00187             : public class_spec<GetBundler,
00188                 extends<AbstractKeyBundler> >
00189             {
00190             friend class factory<GetBundler>;
00191             
00192             // ----- constructors ---------------------------------------
00193 
00194             protected:
00195                 /**
00196                  * @param hBundlingNamedCache  the BundlingNamedCache this 
00197                  *                             bundler is associated with
00198                  */
00199                 GetBundler(BundlingNamedCache::Handle hBundlingNamedCache);
00200 
00201             // ----- bundle operations --------------------------------------
00202 
00203             protected:
00204                 /**
00205                  * A pass through the underlying "getAll" operation.
00206                  *
00207                  * @param vColKeys  a collection of keys for the "getAll"
00208                  *                  operation
00209                  *
00210                  * @return the results.
00211                  */
00212                 virtual Map::View bundle(Collection::View vColKeys);
00213 
00214                 /**
00215                  * A pass through the underlying "get" operation.
00216                  *
00217                  * @param vKey  the entry key
00218                  */
00219                 virtual Object::Holder unbundle(Object::View vKey) const;
00220 
00221                 /**
00222                  * A pass through the underlying "get" operation.
00223                  *
00224                  * @param vKey  the entry key
00225                  */
00226                 virtual Object::Holder unbundle(Object::View vKey);
00227 
00228             // ----- accessors ------------------------------------------
00229 
00230             public:
00231                 /**
00232                  * Obtain the BundlingNamedCache for this bundler.
00233                  *
00234                  * @return the BundlingNamedCache
00235                  */
00236                 virtual BundlingNamedCache::Handle getBundlingNamedCache();
00237 
00238                 /**
00239                  * Obtain the BundlingNamedCache for this bundler.
00240                  *
00241                  * @return the BundlingNamedCache
00242                  */
00243                 virtual BundlingNamedCache::View getBundlingNamedCache() const;
00244 
00245             // ----- data fields ----------------------------------------
00246 
00247             private:
00248                 /**
00249                  * The BundlingNamedCache for this bundler.
00250                  */
00251                 FinalHandle<BundlingNamedCache> f_hBundlingNamedCache;
00252             };
00253 
00254         class COH_EXPORT PutBundler
00255             : public class_spec<PutBundler,
00256                 extends<AbstractEntryBundler> >
00257             {
00258             friend class factory<PutBundler>;
00259 
00260             // ----- constructors ---------------------------------------
00261 
00262             protected:
00263                 /**
00264                  * @param hBundlingNamedCache  the BundlingNamedCache this 
00265                  *                             bundler is associated with
00266                  */
00267                 PutBundler(BundlingNamedCache::Handle hBundlingNamedCache);
00268 
00269             // ----- bundle operations ----------------------------------
00270 
00271             protected:
00272                 /**
00273                  * A pass through the underlying "putAll" operation.
00274                  *
00275                  * @param vMap  the collection of entries
00276                  */
00277                 virtual void bundle(Map::View vMap);
00278 
00279             // ----- accessors ------------------------------------------
00280 
00281             public:
00282                 /**
00283                  * Obtain the BundlingNamedCache for this bundler.
00284                  *
00285                  * @return the BundlingNamedCache
00286                  */
00287                 virtual BundlingNamedCache::Handle getBundlingNamedCache();
00288 
00289                 /**
00290                  * Obtain the BundlingNamedCache for this bundler.
00291                  *
00292                  * @return the BundlingNamedCache
00293                  */
00294                 virtual BundlingNamedCache::View getBundlingNamedCache() const;
00295 
00296             // ----- data fields ----------------------------------------
00297 
00298             private:
00299                 /**
00300                  * The BundlingNamedCache for this bundler.
00301                  */
00302                 FinalHandle<BundlingNamedCache> f_hBundlingNamedCache;
00303             };
00304 
00305         class COH_EXPORT RemoveBundler
00306             : public class_spec<RemoveBundler,
00307                 extends<AbstractKeyBundler> >
00308             {
00309             friend class factory<RemoveBundler>;
00310 
00311             // ----- constructors ---------------------------------------
00312 
00313             protected:
00314                 /**
00315                  * @param hBundlingNamedCache  the BundlingNamedCache this 
00316                  *                             bundler is associated with
00317                  */
00318                 RemoveBundler(BundlingNamedCache::Handle hBundlingNamedCache);
00319 
00320             // ----- bundle operations ----------------------------------
00321 
00322             protected:
00323                 /**
00324                  * A pass through the underlying keySet()->removeAll() operation.
00325                  *
00326                  * @param vColKeys  the collection of keys to perform the
00327                  *                  bundled operation for
00328                  */
00329                 virtual Map::View bundle(Collection::View vColKeys);
00330 
00331                 /**
00332                  * A pass through the underlying "remove" operation.
00333                  *
00334                  * @param vKey  the entry key
00335                  */
00336                 virtual Object::Holder unbundle(Object::View vKey);
00337 
00338             // ----- accessors ------------------------------------------
00339 
00340             public:
00341                 /**
00342                  * Obtain the BundlingNamedCache for this bundler.
00343                  *
00344                  * @return the BundlingNamedCache
00345                  */
00346                 virtual BundlingNamedCache::Handle getBundlingNamedCache();
00347 
00348                 /**
00349                  * Obtain the BundlingNamedCache for this bundler.
00350                  *
00351                  * @return the BundlingNamedCache
00352                  */
00353                 virtual BundlingNamedCache::View getBundlingNamedCache() const;
00354 
00355             // ----- data fields ----------------------------------------
00356 
00357             private:
00358                 /**
00359                  * The BundlingNamedCache for this bundler.
00360                  */
00361                 FinalHandle<BundlingNamedCache> f_hBundlingNamedCache;
00362             };
00363 
00364     // ----- data fields -----------------------------------------------------
00365 
00366     private:
00367         /**
00368          * The bundler for get() operations.
00369          */
00370         MemberHandle<GetBundler> m_hGetBundler;
00371 
00372         /**
00373          * The bundler for put() operations.
00374          */
00375         MemberHandle<PutBundler> m_hPutBundler;
00376 
00377         /**
00378          * The bundler for remove() operations.
00379          */
00380         MemberHandle<RemoveBundler> m_hRemoveBundler;
00381     };
00382     
00383 COH_CLOSE_NAMESPACE3
00384 
00385 #endif // COH_BUNDLING_NAMED_CACHE_HPP
Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.