00001 /* 00002 * CacheService.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_CACHE_SERVICE_HPP 00017 #define COH_CACHE_SERVICE_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/net/NamedCache.hpp" 00022 #include "coherence/net/Service.hpp" 00023 #include "coherence/util/Collection.hpp" 00024 00025 COH_OPEN_NAMESPACE2(coherence,net) 00026 00027 using coherence::util::Collection; 00028 00029 00030 /** 00031 * A CacheService is a clustered service providing a collection of named Maps 00032 * that hold resources shared among members of a cluster. These resources are 00033 * expected to be managed in memory, and are typically composed of data that 00034 * are also stored persistently in a database, or data that have been 00035 * assembled or calculated at some significant cost, thus these resources are 00036 * referred to as <i>cached</i>. 00037 * 00038 * @author jh 2007.12.21 00039 */ 00040 class COH_EXPORT CacheService 00041 : public interface_spec<CacheService, 00042 implements<Service> > 00043 { 00044 // ----- CacheService interface ----------------------------------------- 00045 00046 public: 00047 /** 00048 * Obtain a NamedCache interface that provides a view of resources 00049 * shared among members of a cluster. The view is identified by name 00050 * within this CacheService. Typically, repeated calls to this method 00051 * with the same view name and class loader instance will result in 00052 * the same view reference being returned. 00053 * 00054 * @param vsName the name, within this CacheService, that uniquely 00055 * identifies a view; null is legal, and may imply a 00056 * default name 00057 * 00058 * @return a NamedCache interface which can be used to access the 00059 * resources of the specified view 00060 * 00061 * @throws IllegalStateException thrown if the service is not 00062 * running 00063 */ 00064 virtual NamedCache::Handle ensureCache(String::View vsName) = 0; 00065 00066 /** 00067 * Returns a Collection of String objects, one for each cache name 00068 * that has been previously registered with this CacheService. 00069 * 00070 * @return a Collection of cache names 00071 * 00072 * @throws IllegalStateException thrown if the CacheService 00073 * is not running or has stopped 00074 */ 00075 virtual Collection::View getCacheNames() const = 0; 00076 00077 /** 00078 * Release local resources associated with the specified instance of 00079 * the cache. This invalidates a reference obtained by using the 00080 * {@link #ensureCache(String::View)} method. 00081 * 00082 * Releasing a Map reference to a cache makes the Map reference no 00083 * longer usable, but does not affect the cache itself. In other 00084 * words, all other references to the cache will still be valid, and 00085 * the cache data is not affected by releasing the reference. 00086 * 00087 * The reference that is released using this method can no longer be 00088 * used; any attempt to use the reference will result in an exception. 00089 * 00090 * The purpose for releasing a cache reference is to allow the cache 00091 * implementation to release resources. 00092 * 00093 * @param hMap the cache object to be released 00094 * 00095 * @see NamedCache#release() 00096 */ 00097 virtual void releaseCache(NamedCache::Handle hMap) = 0; 00098 00099 /** 00100 * Release and destroy the specified cache. 00101 * 00102 * <b>Warning:</b> This method is used to completely destroy the 00103 * specified cache across the cluster. All references in the entire 00104 * cluster to this cache will be invalidated, the cached data will be 00105 * cleared, and all resources will be released. 00106 * 00107 * @param hMap the cache object to be released 00108 * 00109 * @see NamedCache#destroy() 00110 */ 00111 virtual void destroyCache(NamedCache::Handle hMap) = 0; 00112 }; 00113 00114 COH_CLOSE_NAMESPACE2 00115 00116 #endif // COH_CACHE_SERVICE_HPP