Package com.hazelcast.config
Class AbstractCacheConfig<K,V>
- java.lang.Object
-
- com.hazelcast.config.AbstractCacheConfig<K,V>
-
- Type Parameters:
K
- the key typeV
- the value type
- All Implemented Interfaces:
CacheConfiguration<K,V>
,DataSerializable
,IdentifiedDataSerializable
,java.io.Serializable
,javax.cache.configuration.CompleteConfiguration<K,V>
,javax.cache.configuration.Configuration<K,V>
- Direct Known Subclasses:
CacheConfig
public abstract class AbstractCacheConfig<K,V> extends java.lang.Object implements CacheConfiguration<K,V>, IdentifiedDataSerializable
Base class forCacheConfig
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>>>
cacheLoaderFactory
TheFactory
for theCacheLoader
.protected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>>>
cacheWriterFactory
TheFactory
for theCacheWriter
.protected java.lang.ClassLoader
classLoader
The ClassLoader to be used to resolve key & value types, if setprotected DataPersistenceConfig
dataPersistenceConfig
protected EventJournalConfig
eventJournalConfig
protected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy>>
expiryPolicyFactory
TheFactory
for theExpiryPolicy
.protected HotRestartConfig
hotRestartConfig
protected boolean
isManagementEnabled
Whether management is enabledprotected boolean
isReadThrough
A flag indicating if "read-through" mode is required.protected boolean
isStatisticsEnabled
A flag indicating if statistics gathering is enabled.protected boolean
isStoreByValue
A flag indicating if the cache will be store-by-value or store-by-reference.protected boolean
isWriteThrough
A flag indicating if "write-through" mode is required.protected java.util.Set<com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>>>
listenerConfigurations
TheCacheEntryListenerConfiguration
s for theConfiguration
.protected com.hazelcast.internal.serialization.SerializationService
serializationService
-
Constructor Summary
Constructors Constructor Description AbstractCacheConfig()
AbstractCacheConfig(javax.cache.configuration.CompleteConfiguration<K,V> configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CacheConfiguration<K,V>
addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
Add a configuration for aCacheEntryListener
.protected java.util.Set<com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>>>
createConcurrentSet()
boolean
equals(java.lang.Object o)
java.lang.Iterable<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>>
getCacheEntryListenerConfigurations()
javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>>
getCacheLoaderFactory()
javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>>
getCacheWriterFactory()
DataPersistenceConfig
getDataPersistenceConfig()
Gets thePersistConfig
for thisCacheConfiguration
EventJournalConfig
getEventJournalConfig()
Gets theEventJournalConfig
for thisCacheConfiguration
javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy>
getExpiryPolicyFactory()
int
getFactoryId()
Returns DataSerializableFactory factory ID for this class.HotRestartConfig
getHotRestartConfig()
Gets theHotRestartConfig
for thisCacheConfiguration
java.lang.String
getKeyClassName()
java.lang.Class<K>
getKeyType()
java.util.Set<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>>
getListenerConfigurations()
java.lang.String
getValueClassName()
java.lang.Class<V>
getValueType()
int
hashCode()
protected boolean
hasListenerConfiguration()
boolean
isManagementEnabled()
boolean
isReadThrough()
boolean
isStatisticsEnabled()
boolean
isStoreByValue()
boolean
isWriteThrough()
protected boolean
keyValueTypesEqual(AbstractCacheConfig that)
CacheConfiguration<K,V>
removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
Remove a configuration for aCacheEntryListener
.CacheConfiguration<K,V>
setCacheLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K,V>> cacheLoaderFactory)
Set theCacheLoader
factory.CacheConfiguration<K,V>
setCacheWriterFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K,? super V>> cacheWriterFactory)
Set theCacheWriter
factory.protected void
setClassLoader(java.lang.ClassLoader classLoader)
CacheConfiguration<K,V>
setDataPersistenceConfig(DataPersistenceConfig dataPersistenceConfig)
Sets theDataPersistenceConfig
for thisCacheConfiguration
CacheConfiguration<K,V>
setEventJournalConfig(EventJournalConfig eventJournalConfig)
Sets theEventJournalConfig
for thisCacheConfiguration
CacheConfiguration<K,V>
setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> expiryPolicyFactory)
Set theFactory
for theExpiryPolicy
.CacheConfiguration<K,V>
setHotRestartConfig(HotRestartConfig hotRestartConfig)
Deprecated.since 5.0 usesetDataPersistenceConfig(DataPersistenceConfig)
CacheConfiguration<K,V>
setKeyClassName(java.lang.String keyClassName)
CacheConfiguration<K,V>
setKeyType(java.lang.Class<K> keyType)
CacheConfiguration<K,V>
setListenerConfigurations()
protected CacheConfiguration<K,V>
setListenerConfigurations(java.util.Set<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>> listeners)
CacheConfiguration<K,V>
setManagementEnabled(boolean enabled)
Sets whether or not management is enabled on this cache.CacheConfiguration<K,V>
setReadThrough(boolean isReadThrough)
Set if read-through caching should be used.CacheConfiguration<K,V>
setStatisticsEnabled(boolean enabled)
Sets whether or not statistics gathering is enabled on this cache.CacheConfiguration<K,V>
setStoreByValue(boolean storeByValue)
Set if a configured cache should use store-by-value or store-by-reference semantics.CacheConfiguration<K,V>
setTypes(java.lang.Class<K> keyType, java.lang.Class<V> valueType)
Sets the expected type of keys and values for aCache
configured with thisConfiguration
.CacheConfiguration<K,V>
setValueClassName(java.lang.String valueClassName)
CacheConfiguration<K,V>
setValueType(java.lang.Class<V> valueType)
CacheConfiguration<K,V>
setWriteThrough(boolean isWriteThrough)
Set if write-through caching should be used.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.hazelcast.nio.serialization.DataSerializable
readData, writeData
-
Methods inherited from interface com.hazelcast.nio.serialization.IdentifiedDataSerializable
getClassId
-
-
-
-
Field Detail
-
cacheLoaderFactory
protected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>>> cacheLoaderFactory
TheFactory
for theCacheLoader
.
-
cacheWriterFactory
protected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>>> cacheWriterFactory
TheFactory
for theCacheWriter
.
-
expiryPolicyFactory
protected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy>> expiryPolicyFactory
TheFactory
for theExpiryPolicy
.
-
isReadThrough
protected boolean isReadThrough
A flag indicating if "read-through" mode is required.
-
isWriteThrough
protected boolean isWriteThrough
A flag indicating if "write-through" mode is required.
-
isStatisticsEnabled
protected boolean isStatisticsEnabled
A flag indicating if statistics gathering is enabled.
-
isStoreByValue
protected boolean isStoreByValue
A flag indicating if the cache will be store-by-value or store-by-reference.
-
isManagementEnabled
protected boolean isManagementEnabled
Whether management is enabled
-
hotRestartConfig
protected HotRestartConfig hotRestartConfig
-
dataPersistenceConfig
protected DataPersistenceConfig dataPersistenceConfig
-
eventJournalConfig
protected EventJournalConfig eventJournalConfig
-
classLoader
protected transient java.lang.ClassLoader classLoader
The ClassLoader to be used to resolve key & value types, if set
-
serializationService
protected transient com.hazelcast.internal.serialization.SerializationService serializationService
-
-
Method Detail
-
addCacheEntryListenerConfiguration
public CacheConfiguration<K,V> addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
Add a configuration for aCacheEntryListener
.- Specified by:
addCacheEntryListenerConfiguration
in interfaceCacheConfiguration<K,V>
- Parameters:
cacheEntryListenerConfiguration
- theCacheEntryListenerConfiguration
- Returns:
- the
CacheConfig
- Throws:
java.lang.IllegalArgumentException
- if the same CacheEntryListenerConfiguration is used more than once
-
removeCacheEntryListenerConfiguration
public CacheConfiguration<K,V> removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
Remove a configuration for aCacheEntryListener
.- Specified by:
removeCacheEntryListenerConfiguration
in interfaceCacheConfiguration<K,V>
- Parameters:
cacheEntryListenerConfiguration
- theCacheEntryListenerConfiguration
to remove- Returns:
- the
CacheConfig
-
getCacheEntryListenerConfigurations
public java.lang.Iterable<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>> getCacheEntryListenerConfigurations()
-
isReadThrough
public boolean isReadThrough()
-
setReadThrough
public CacheConfiguration<K,V> setReadThrough(boolean isReadThrough)
Description copied from interface:CacheConfiguration
Set if read-through caching should be used.It is an invalid configuration to set this to
true
without specifying aCacheLoader
Factory
.- Specified by:
setReadThrough
in interfaceCacheConfiguration<K,V>
- Parameters:
isReadThrough
-true
if read-through is required,false
otherwise- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
isWriteThrough
public boolean isWriteThrough()
-
setWriteThrough
public CacheConfiguration<K,V> setWriteThrough(boolean isWriteThrough)
Description copied from interface:CacheConfiguration
Set if write-through caching should be used.It is an invalid configuration to set this to
true
without specifying aCacheWriter
Factory
.- Specified by:
setWriteThrough
in interfaceCacheConfiguration<K,V>
- Parameters:
isWriteThrough
-true
if write-through is required,false
otherwise- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
isStatisticsEnabled
public boolean isStatisticsEnabled()
-
setStatisticsEnabled
public CacheConfiguration<K,V> setStatisticsEnabled(boolean enabled)
Sets whether or not statistics gathering is enabled on this cache.Statistics may be enabled or disabled at runtime via
CacheManager.enableStatistics(String, boolean)
.- Specified by:
setStatisticsEnabled
in interfaceCacheConfiguration<K,V>
- Parameters:
enabled
-true
to enable statistics,false
to disable- Returns:
- the
CacheConfig
-
isManagementEnabled
public boolean isManagementEnabled()
-
setManagementEnabled
public CacheConfiguration<K,V> setManagementEnabled(boolean enabled)
Sets whether or not management is enabled on this cache.Management may be enabled or disabled at runtime via
CacheManager.enableManagement(String, boolean)
.- Specified by:
setManagementEnabled
in interfaceCacheConfiguration<K,V>
- Parameters:
enabled
-true
to enable management,false
to disable- Returns:
- the
CacheConfig
-
getHotRestartConfig
@Nonnull public HotRestartConfig getHotRestartConfig()
Gets theHotRestartConfig
for thisCacheConfiguration
- Returns:
- hot restart config
-
getDataPersistenceConfig
@Nonnull public DataPersistenceConfig getDataPersistenceConfig()
Gets thePersistConfig
for thisCacheConfiguration
- Returns:
- dataPersistenceConfig config
-
setHotRestartConfig
@Deprecated public CacheConfiguration<K,V> setHotRestartConfig(@Nonnull HotRestartConfig hotRestartConfig)
Deprecated.since 5.0 usesetDataPersistenceConfig(DataPersistenceConfig)
Sets theHotRestartConfig
for thisCacheConfiguration
- Parameters:
hotRestartConfig
- hot restart config- Returns:
- this
CacheConfiguration
instance
-
setDataPersistenceConfig
public CacheConfiguration<K,V> setDataPersistenceConfig(@Nonnull DataPersistenceConfig dataPersistenceConfig)
Sets theDataPersistenceConfig
for thisCacheConfiguration
- Parameters:
dataPersistenceConfig
- dataPersistenceConfig config- Returns:
- this
CacheConfiguration
instance
-
getEventJournalConfig
@Nonnull public EventJournalConfig getEventJournalConfig()
Gets theEventJournalConfig
for thisCacheConfiguration
- Returns:
- event journal config
-
setEventJournalConfig
public CacheConfiguration<K,V> setEventJournalConfig(@Nonnull EventJournalConfig eventJournalConfig)
Sets theEventJournalConfig
for thisCacheConfiguration
- Parameters:
eventJournalConfig
- event journal config- Returns:
- this
CacheConfiguration
instance
-
getCacheLoaderFactory
public javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>> getCacheLoaderFactory()
-
setCacheLoaderFactory
public CacheConfiguration<K,V> setCacheLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K,V>> cacheLoaderFactory)
Description copied from interface:CacheConfiguration
Set theCacheLoader
factory.- Specified by:
setCacheLoaderFactory
in interfaceCacheConfiguration<K,V>
- Parameters:
cacheLoaderFactory
- theCacheLoader
Factory
- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
setExpiryPolicyFactory
public CacheConfiguration<K,V> setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> expiryPolicyFactory)
Description copied from interface:CacheConfiguration
Set theFactory
for theExpiryPolicy
. Ifnull
is specified the defaultExpiryPolicy
is used.- Specified by:
setExpiryPolicyFactory
in interfaceCacheConfiguration<K,V>
- Parameters:
expiryPolicyFactory
- theExpiryPolicy
Factory
- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
setCacheWriterFactory
public CacheConfiguration<K,V> setCacheWriterFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K,? super V>> cacheWriterFactory)
Description copied from interface:CacheConfiguration
Set theCacheWriter
factory.- Specified by:
setCacheWriterFactory
in interfaceCacheConfiguration<K,V>
- Parameters:
cacheWriterFactory
- theCacheWriter
Factory
- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
getCacheWriterFactory
public javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>> getCacheWriterFactory()
-
getExpiryPolicyFactory
public javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy> getExpiryPolicyFactory()
-
getKeyType
public java.lang.Class<K> getKeyType()
-
getKeyClassName
public java.lang.String getKeyClassName()
-
setKeyClassName
public CacheConfiguration<K,V> setKeyClassName(java.lang.String keyClassName)
-
getValueType
public java.lang.Class<V> getValueType()
-
getValueClassName
public java.lang.String getValueClassName()
-
setValueClassName
public CacheConfiguration<K,V> setValueClassName(java.lang.String valueClassName)
-
setTypes
public CacheConfiguration<K,V> setTypes(java.lang.Class<K> keyType, java.lang.Class<V> valueType)
Sets the expected type of keys and values for aCache
configured with thisConfiguration
. Setting both toObject.class
means type-safety checks are not required.This is used by
CacheManager
to ensure that the key and value types are the same as those configured for theCache
prior to returning a requested cache from this method.Implementations may further perform type checking on mutative cache operations and throw a
ClassCastException
if these checks fail.- Specified by:
setTypes
in interfaceCacheConfiguration<K,V>
- Parameters:
keyType
- the expected key typevalueType
- the expected value type- Returns:
- the
CacheConfig
- Throws:
java.lang.NullPointerException
- should the key or value type be null- See Also:
CacheManager.getCache(String, Class, Class)
-
isStoreByValue
public boolean isStoreByValue()
-
setStoreByValue
public CacheConfiguration<K,V> setStoreByValue(boolean storeByValue)
Set if a configured cache should use store-by-value or store-by-reference semantics.- Specified by:
setStoreByValue
in interfaceCacheConfiguration<K,V>
- Parameters:
storeByValue
-true
if store-by-value is required,false
for store-by-reference- Returns:
- the
CacheConfig
-
getFactoryId
public int getFactoryId()
Description copied from interface:IdentifiedDataSerializable
Returns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryId
in interfaceIdentifiedDataSerializable
- Returns:
- factory ID
-
createConcurrentSet
protected java.util.Set<com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>>> createConcurrentSet()
-
setKeyType
public CacheConfiguration<K,V> setKeyType(java.lang.Class<K> keyType)
-
setValueType
public CacheConfiguration<K,V> setValueType(java.lang.Class<V> valueType)
-
setListenerConfigurations
public CacheConfiguration<K,V> setListenerConfigurations()
-
setListenerConfigurations
protected CacheConfiguration<K,V> setListenerConfigurations(java.util.Set<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>> listeners)
-
getListenerConfigurations
public java.util.Set<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>> getListenerConfigurations()
-
hasListenerConfiguration
protected boolean hasListenerConfiguration()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
setClassLoader
protected void setClassLoader(java.lang.ClassLoader classLoader)
-
keyValueTypesEqual
protected boolean keyValueTypesEqual(AbstractCacheConfig that)
-
-