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,Serializable,javax.cache.configuration.CompleteConfiguration<K,,V> javax.cache.configuration.Configuration<K,V>
- Direct Known Subclasses:
CacheConfig
public abstract class AbstractCacheConfig<K,V>
extends Object
implements CacheConfiguration<K,V>, IdentifiedDataSerializable
Base class for
CacheConfig- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>>> TheFactoryfor theCacheLoader.protected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>>> TheFactoryfor theCacheWriter.protected ClassLoaderThe ClassLoader to be used to resolve key & value types, if setprotected DataPersistenceConfigprotected EventJournalConfigprotected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy>>TheFactoryfor theExpiryPolicy.protected HotRestartConfigprotected booleanWhether management is enabledprotected booleanA flag indicating if "read-through" mode is required.protected booleanA flag indicating if statistics gathering is enabled.protected booleanA flag indicating if the cache will be store-by-value or store-by-reference.protected booleanA flag indicating if "write-through" mode is required.protected Set<com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>>> TheCacheEntryListenerConfigurations for theConfiguration.protected com.hazelcast.internal.serialization.SerializationService -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCacheConfig(javax.cache.configuration.CompleteConfiguration<K, V> configuration) -
Method Summary
Modifier and TypeMethodDescriptionaddCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) Add a configuration for aCacheEntryListener.protected Set<com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>>> booleanGets thePersistConfigfor thisCacheConfigurationGets theEventJournalConfigfor thisCacheConfigurationjavax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy>intReturns DataSerializableFactory factory ID for this class.Gets theHotRestartConfigfor thisCacheConfigurationinthashCode()protected booleanbooleanbooleanbooleanbooleanbooleanprotected booleanremoveCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) Remove a configuration for aCacheEntryListener.setCacheLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K, V>> cacheLoaderFactory) Set theCacheLoaderfactory.setCacheWriterFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K, ? super V>> cacheWriterFactory) Set theCacheWriterfactory.protected voidsetClassLoader(ClassLoader classLoader) setDataPersistenceConfig(DataPersistenceConfig dataPersistenceConfig) Sets theDataPersistenceConfigfor thisCacheConfigurationsetEventJournalConfig(EventJournalConfig eventJournalConfig) Sets theEventJournalConfigfor thisCacheConfigurationsetExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> expiryPolicyFactory) Set theFactoryfor theExpiryPolicy.setHotRestartConfig(HotRestartConfig hotRestartConfig) Deprecated.setKeyClassName(String keyClassName) setKeyType(Class<K> keyType) protected CacheConfiguration<K,V> setListenerConfigurations(Set<javax.cache.configuration.CacheEntryListenerConfiguration<K, V>> listeners) setManagementEnabled(boolean enabled) Sets whether management is enabled on this cache.setReadThrough(boolean isReadThrough) Set if read-through caching should be used.setStatisticsEnabled(boolean enabled) Sets whether statistics gathering is enabled on this cache.setStoreByValue(boolean storeByValue) Set if a configured cache should use store-by-value or store-by-reference semantics.Sets the expected type of keys and values for aCacheconfigured with thisConfiguration.setValueClassName(String valueClassName) setValueType(Class<V> valueType) 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, waitMethods inherited from interface com.hazelcast.nio.serialization.DataSerializable
readData, writeDataMethods inherited from interface com.hazelcast.nio.serialization.IdentifiedDataSerializable
getClassId
-
Field Details
-
cacheLoaderFactory
protected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>>> cacheLoaderFactoryTheFactoryfor theCacheLoader. -
cacheWriterFactory
protected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>>> cacheWriterFactoryTheFactoryfor theCacheWriter. -
expiryPolicyFactory
protected com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy>> expiryPolicyFactoryTheFactoryfor theExpiryPolicy. -
isReadThrough
protected boolean isReadThroughA flag indicating if "read-through" mode is required. -
isWriteThrough
protected boolean isWriteThroughA flag indicating if "write-through" mode is required. -
isStatisticsEnabled
protected boolean isStatisticsEnabledA flag indicating if statistics gathering is enabled. -
isStoreByValue
protected boolean isStoreByValueA flag indicating if the cache will be store-by-value or store-by-reference. -
isManagementEnabled
protected boolean isManagementEnabledWhether management is enabled -
hotRestartConfig
-
dataPersistenceConfig
-
eventJournalConfig
-
classLoader
The ClassLoader to be used to resolve key & value types, if set -
serializationService
protected transient com.hazelcast.internal.serialization.SerializationService serializationService -
listenerConfigurations
protected Set<com.hazelcast.cache.impl.DeferredValue<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>>> listenerConfigurationsTheCacheEntryListenerConfigurations for theConfiguration.
-
-
Constructor Details
-
AbstractCacheConfig
public AbstractCacheConfig() -
AbstractCacheConfig
-
-
Method Details
-
addCacheEntryListenerConfiguration
public CacheConfiguration<K,V> addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) Add a configuration for aCacheEntryListener.- Specified by:
addCacheEntryListenerConfigurationin interfaceCacheConfiguration<K,V> - Parameters:
cacheEntryListenerConfiguration- theCacheEntryListenerConfiguration- Returns:
- the
CacheConfig - Throws:
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:
removeCacheEntryListenerConfigurationin interfaceCacheConfiguration<K,V> - Parameters:
cacheEntryListenerConfiguration- theCacheEntryListenerConfigurationto remove- Returns:
- the
CacheConfig
-
getCacheEntryListenerConfigurations
-
isReadThrough
public boolean isReadThrough() -
setReadThrough
Description copied from interface:CacheConfigurationSet if read-through caching should be used.It is an invalid configuration to set this to
truewithout specifying aCacheLoaderFactory.- Specified by:
setReadThroughin interfaceCacheConfiguration<K,V> - Parameters:
isReadThrough-trueif read-through is required,falseotherwise- Returns:
- the
CacheConfigurationto permit fluent-style method calls
-
isWriteThrough
public boolean isWriteThrough() -
setWriteThrough
Description copied from interface:CacheConfigurationSet if write-through caching should be used.It is an invalid configuration to set this to
truewithout specifying aCacheWriterFactory.- Specified by:
setWriteThroughin interfaceCacheConfiguration<K,V> - Parameters:
isWriteThrough-trueif write-through is required,falseotherwise- Returns:
- the
CacheConfigurationto permit fluent-style method calls
-
isStatisticsEnabled
public boolean isStatisticsEnabled() -
setStatisticsEnabled
Sets whether statistics gathering is enabled on this cache.Statistics may be enabled or disabled at runtime via
CacheManager.enableStatistics(String, boolean).- Specified by:
setStatisticsEnabledin interfaceCacheConfiguration<K,V> - Parameters:
enabled-trueto enable statistics,falseto disable- Returns:
- the
CacheConfig
-
isManagementEnabled
public boolean isManagementEnabled() -
setManagementEnabled
Sets whether management is enabled on this cache.Management may be enabled or disabled at runtime via
CacheManager.enableManagement(String, boolean).- Specified by:
setManagementEnabledin interfaceCacheConfiguration<K,V> - Parameters:
enabled-trueto enable management,falseto disable- Returns:
- the
CacheConfig
-
getHotRestartConfig
Gets theHotRestartConfigfor thisCacheConfiguration- Returns:
- hot restart config
-
getDataPersistenceConfig
Gets thePersistConfigfor thisCacheConfiguration- Returns:
- dataPersistenceConfig config
-
setHotRestartConfig
@Deprecated public CacheConfiguration<K,V> setHotRestartConfig(@Nonnull HotRestartConfig hotRestartConfig) Deprecated.since 5.0 usesetDataPersistenceConfig(DataPersistenceConfig)Sets theHotRestartConfigfor thisCacheConfiguration- Parameters:
hotRestartConfig- hot restart config- Returns:
- this
CacheConfigurationinstance
-
setDataPersistenceConfig
public CacheConfiguration<K,V> setDataPersistenceConfig(@Nonnull DataPersistenceConfig dataPersistenceConfig) Sets theDataPersistenceConfigfor thisCacheConfiguration- Parameters:
dataPersistenceConfig- dataPersistenceConfig config- Returns:
- this
CacheConfigurationinstance
-
getEventJournalConfig
Gets theEventJournalConfigfor thisCacheConfiguration- Returns:
- event journal config
-
setEventJournalConfig
public CacheConfiguration<K,V> setEventJournalConfig(@Nonnull EventJournalConfig eventJournalConfig) Sets theEventJournalConfigfor thisCacheConfiguration- Parameters:
eventJournalConfig- event journal config- Returns:
- this
CacheConfigurationinstance
-
getCacheLoaderFactory
-
setCacheLoaderFactory
public CacheConfiguration<K,V> setCacheLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K, V>> cacheLoaderFactory) Description copied from interface:CacheConfigurationSet theCacheLoaderfactory.- Specified by:
setCacheLoaderFactoryin interfaceCacheConfiguration<K,V> - Parameters:
cacheLoaderFactory- theCacheLoaderFactory- Returns:
- the
CacheConfigurationto 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:CacheConfigurationSet theFactoryfor theExpiryPolicy. Ifnullis specified the defaultExpiryPolicyis used.- Specified by:
setExpiryPolicyFactoryin interfaceCacheConfiguration<K,V> - Parameters:
expiryPolicyFactory- theExpiryPolicyFactory- Returns:
- the
CacheConfigurationto 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:CacheConfigurationSet theCacheWriterfactory.- Specified by:
setCacheWriterFactoryin interfaceCacheConfiguration<K,V> - Parameters:
cacheWriterFactory- theCacheWriterFactory- Returns:
- the
CacheConfigurationto permit fluent-style method calls
-
getCacheWriterFactory
-
getExpiryPolicyFactory
public javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy> getExpiryPolicyFactory() -
getKeyType
-
getKeyClassName
-
setKeyClassName
-
getValueType
-
getValueClassName
-
setValueClassName
-
setTypes
Sets the expected type of keys and values for aCacheconfigured with thisConfiguration. Setting both toObject.classmeans type-safety checks are not required.This is used by
CacheManagerto ensure that the key and value types are the same as those configured for theCacheprior to returning a requested cache from this method.Implementations may further perform type checking on mutative cache operations and throw a
ClassCastExceptionif these checks fail.- Specified by:
setTypesin interfaceCacheConfiguration<K,V> - Parameters:
keyType- the expected key typevalueType- the expected value type- Returns:
- the
CacheConfig - Throws:
NullPointerException- should the key or value type be null- See Also:
-
CacheManager.getCache(String, Class, Class)
-
isStoreByValue
public boolean isStoreByValue() -
setStoreByValue
Set if a configured cache should use store-by-value or store-by-reference semantics.- Specified by:
setStoreByValuein interfaceCacheConfiguration<K,V> - Parameters:
storeByValue-trueif store-by-value is required,falsefor store-by-reference- Returns:
- the
CacheConfig
-
getFactoryId
public int getFactoryId()Description copied from interface:IdentifiedDataSerializableReturns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryIdin interfaceIdentifiedDataSerializable- Returns:
- factory ID
-
createConcurrentSet
-
setKeyType
-
setValueType
-
setListenerConfigurations
-
setListenerConfigurations
-
getListenerConfigurations
-
hasListenerConfiguration
protected boolean hasListenerConfiguration() -
hashCode
public int hashCode() -
equals
-
setClassLoader
-
keyValueTypesEqual
-
setDataPersistenceConfig(DataPersistenceConfig)