com.hazelcast.cache.impl
Class AbstractHazelcastCacheManager

java.lang.Object
  extended by com.hazelcast.cache.impl.AbstractHazelcastCacheManager
All Implemented Interfaces:
HazelcastCacheManager, Closeable, javax.cache.CacheManager
Direct Known Subclasses:
HazelcastClientCacheManager, HazelcastServerCacheManager

public abstract class AbstractHazelcastCacheManager
extends Object
implements HazelcastCacheManager

Abstract HazelcastCacheManager (also CacheManager as indirect) implementation provides shared functionality to server and client cache managers. There are two cache managers which can be accessed via their providers.

AbstractHazelcastCacheManager manages the lifecycle of the caches created or accessed through itself.

See Also:
HazelcastCacheManager, CacheManager

Field Summary
protected  String cacheNamePrefix
           
protected  ConcurrentMap<String,ICache<?,?>> caches
           
protected  javax.cache.spi.CachingProvider cachingProvider
           
protected  WeakReference<ClassLoader> classLoaderReference
           
protected  HazelcastInstance hazelcastInstance
           
protected  boolean isDefaultClassLoader
           
protected  boolean isDefaultURI
           
protected  Properties properties
           
protected  URI uri
           
 
Constructor Summary
AbstractHazelcastCacheManager(javax.cache.spi.CachingProvider cachingProvider, HazelcastInstance hazelcastInstance, URI uri, ClassLoader classLoader, Properties properties)
           
 
Method Summary
protected abstract
<K,V> void
addCacheConfigIfAbsent(CacheConfig<K,V> cacheConfig)
           
protected  String cacheNamePrefix()
          This method calculates a fixed string based on the URI and classloader using the formula:
protected  void checkIfManagerNotClosed()
           
 void close()
           
<K,V,C extends javax.cache.configuration.Configuration<K,V>>
ICache<K,V>
createCache(String cacheName, C configuration)
           
protected
<K,V,C extends javax.cache.configuration.Configuration<K,V>>
CacheConfig<K,V>
createCacheConfig(String cacheName, C configuration)
           
protected abstract
<K,V> ICache<K,V>
createCacheProxy(CacheConfig<K,V> cacheConfig)
           
protected abstract
<K,V> CacheConfig<K,V>
createConfig(String cacheName, CacheConfig<K,V> config, boolean createAlsoOnOthers, boolean syncCreate)
           
protected abstract
<K,V> CacheConfig<K,V>
createConfigOnPartition(CacheConfig<K,V> cacheConfig)
           
 void destroy()
          Destroy all managed caches.
 void destroyCache(String cacheName)
           
protected abstract
<K,V> CacheConfig<K,V>
findConfig(String cacheName, String simpleCacheName, boolean createAlsoOnOthers, boolean syncCreate)
           
<K,V> ICache<K,V>
getCache(String cacheName)
           
<K,V> ICache<K,V>
getCache(String cacheName, Class<K> keyType, Class<V> valueType)
           
protected abstract
<K,V> CacheConfig<K,V>
getCacheConfigFromPartition(String cacheName, String simpleCacheName)
           
protected abstract
<K,V> CacheConfig<K,V>
getCacheConfigLocal(String cacheName)
           
 Iterable<String> getCacheNames()
           
protected  String getCacheNameWithPrefix(String name)
           
protected
<K,V> ICache<?,?>
getCacheUnchecked(String cacheName)
           
 javax.cache.spi.CachingProvider getCachingProvider()
           
 ClassLoader getClassLoader()
           
 Properties getProperties()
           
 URI getURI()
           
 boolean isClosed()
           
protected abstract  void postClose()
           
protected
<K,V> void
registerListeners(CacheConfig<K,V> cacheConfig, ICache<K,V> source)
           
protected  void removeCacheConfigFromLocal(String cacheName)
          Removes the local copy of the cache configuration if one exists.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.cache.CacheManager
enableManagement, enableStatistics, unwrap
 

Field Detail

caches

protected final ConcurrentMap<String,ICache<?,?>> caches

uri

protected final URI uri

classLoaderReference

protected final WeakReference<ClassLoader> classLoaderReference

properties

protected final Properties properties

cacheNamePrefix

protected final String cacheNamePrefix

isDefaultURI

protected final boolean isDefaultURI

isDefaultClassLoader

protected final boolean isDefaultClassLoader

cachingProvider

protected final javax.cache.spi.CachingProvider cachingProvider

hazelcastInstance

protected final HazelcastInstance hazelcastInstance
Constructor Detail

AbstractHazelcastCacheManager

public AbstractHazelcastCacheManager(javax.cache.spi.CachingProvider cachingProvider,
                                     HazelcastInstance hazelcastInstance,
                                     URI uri,
                                     ClassLoader classLoader,
                                     Properties properties)
Method Detail

createCache

public <K,V,C extends javax.cache.configuration.Configuration<K,V>> ICache<K,V> createCache(String cacheName,
                                                                                            C configuration)
                        throws IllegalArgumentException
Specified by:
createCache in interface javax.cache.CacheManager
Throws:
IllegalArgumentException

getCachingProvider

public javax.cache.spi.CachingProvider getCachingProvider()
Specified by:
getCachingProvider in interface javax.cache.CacheManager

getURI

public URI getURI()
Specified by:
getURI in interface javax.cache.CacheManager

getClassLoader

public ClassLoader getClassLoader()
Specified by:
getClassLoader in interface javax.cache.CacheManager

getProperties

public Properties getProperties()
Specified by:
getProperties in interface javax.cache.CacheManager

getCache

public <K,V> ICache<K,V> getCache(String cacheName,
                                  Class<K> keyType,
                                  Class<V> valueType)
Specified by:
getCache in interface javax.cache.CacheManager

getCache

public <K,V> ICache<K,V> getCache(String cacheName)
Specified by:
getCache in interface javax.cache.CacheManager

getCacheUnchecked

protected <K,V> ICache<?,?> getCacheUnchecked(String cacheName)

getCacheNames

public Iterable<String> getCacheNames()
Specified by:
getCacheNames in interface javax.cache.CacheManager

destroyCache

public void destroyCache(String cacheName)
Specified by:
destroyCache in interface javax.cache.CacheManager

removeCacheConfigFromLocal

protected void removeCacheConfigFromLocal(String cacheName)
Removes the local copy of the cache configuration if one exists. Default implementation does not require it. But client implementation overrides this to track a local copy of the config.

Parameters:
cacheName - cache name.

close

public void close()
Specified by:
close in interface Closeable
Specified by:
close in interface javax.cache.CacheManager

destroy

public void destroy()
Destroy all managed caches.

Specified by:
destroy in interface HazelcastCacheManager

isClosed

public boolean isClosed()
Specified by:
isClosed in interface javax.cache.CacheManager

checkIfManagerNotClosed

protected void checkIfManagerNotClosed()

cacheNamePrefix

protected String cacheNamePrefix()
This method calculates a fixed string based on the URI and classloader using the formula:

/hz[/uri][/classloader]/

URI and classloader are dropped if they have default values.

Returns:
the calculated cache prefix.

getCacheNameWithPrefix

protected String getCacheNameWithPrefix(String name)

createCacheConfig

protected <K,V,C extends javax.cache.configuration.Configuration<K,V>> CacheConfig<K,V> createCacheConfig(String cacheName,
                                                                                                          C configuration)

registerListeners

protected <K,V> void registerListeners(CacheConfig<K,V> cacheConfig,
                                       ICache<K,V> source)

toString

public String toString()
Overrides:
toString in class Object

addCacheConfigIfAbsent

protected abstract <K,V> void addCacheConfigIfAbsent(CacheConfig<K,V> cacheConfig)

createCacheProxy

protected abstract <K,V> ICache<K,V> createCacheProxy(CacheConfig<K,V> cacheConfig)

findConfig

protected abstract <K,V> CacheConfig<K,V> findConfig(String cacheName,
                                                     String simpleCacheName,
                                                     boolean createAlsoOnOthers,
                                                     boolean syncCreate)

createConfig

protected abstract <K,V> CacheConfig<K,V> createConfig(String cacheName,
                                                       CacheConfig<K,V> config,
                                                       boolean createAlsoOnOthers,
                                                       boolean syncCreate)

getCacheConfigLocal

protected abstract <K,V> CacheConfig<K,V> getCacheConfigLocal(String cacheName)

createConfigOnPartition

protected abstract <K,V> CacheConfig<K,V> createConfigOnPartition(CacheConfig<K,V> cacheConfig)

getCacheConfigFromPartition

protected abstract <K,V> CacheConfig<K,V> getCacheConfigFromPartition(String cacheName,
                                                                      String simpleCacheName)

postClose

protected abstract void postClose()


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.