Top Description Fields Constructors Methods
javax.cache.configuration

public Class MutableConfiguration<K, V>

extends Object
implements CompleteConfiguration<K, V>
Class Inheritance
All Implemented Interfaces
javax.cache.configuration.CompleteConfiguration, java.io.Serializable, javax.cache.configuration.Configuration
Type Parameters
<K>
the type of keys maintained the cache
<V>
the type of cached values
Imports
javax.cache.Cache, .CacheManager, javax.cache.event.CacheEntryListener, javax.cache.expiry.EternalExpiryPolicy, .ExpiryPolicy, javax.cache.integration.CacheLoader, .CacheWriter, java.util.HashSet

A simple mutable implementation of a Configuration.
Authors
Brian Oliver, Greg Luck
Since
1.0

Field Summary

Modifier and TypeField and Description
protected Factory<CacheLoader<K, V>>
protected Factory<CacheWriter<? super K, ? super V>>
protected Factory<ExpiryPolicy>
protected boolean
isManagementEnabled

Whether management is enabled

protected 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 Class<K>
keyType

The type of keys for Caches configured with this Configuration.

protected HashSet<CacheEntryListenerConfiguration<K, V>>
public static final long
serialVersionUID

The serialVersionUID required for java.io.Serializable.

protected Class<V>
valueType

The type of values for Caches configured with this Configuration.

Constructor Summary

AccessConstructor and Description
public
MutableConfiguration()

Default JavaBean constructor.

public

Method Summary

Modifier and TypeMethod and Description
public MutableConfiguration<K, V>

Returns:

the MutableConfiguration to permit fluent-style method calls
addCacheEntryListenerConfiguration
(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration)

Add a configuration for a CacheEntryListener.

public boolean
equals(Object
the reference object with which to compare.
object
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Iterable<CacheEntryListenerConfiguration<K, V>>
public Factory<CacheLoader<K, V>>
public Factory<CacheWriter<? super K, ? super V>>
public Factory<ExpiryPolicy>
public Class<K>
getKeyType()

Implements javax.cache.configuration.Configuration.getKeyType.

Determines the required type of keys for Caches configured with this Configuration.
public Class<V>
getValueType()

Implements javax.cache.configuration.Configuration.getValueType.

Determines the required type of values for Caches configured with this Configuration.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
isManagementEnabled()

Implements javax.cache.configuration.CompleteConfiguration.isManagementEnabled.

Checks whether management is enabled on this cache.
public boolean
isReadThrough()

Implements javax.cache.configuration.CompleteConfiguration.isReadThrough.

Determines if a javax.cache.Cache should operate in read-through mode.
public boolean
isStatisticsEnabled()

Implements javax.cache.configuration.CompleteConfiguration.isStatisticsEnabled.

Checks whether statistics collection is enabled in this cache.
public boolean
isStoreByValue()

Implements javax.cache.configuration.Configuration.isStoreByValue.

Whether storeByValue (true) or storeByReference (false).
public boolean
isWriteThrough()

Implements javax.cache.configuration.CompleteConfiguration.isWriteThrough.

Determines if a javax.cache.Cache should operate in write-through mode.
public MutableConfiguration<K, V>

Returns:

the MutableConfiguration to permit fluent-style method calls
removeCacheEntryListenerConfiguration
(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration)

Remove a configuration for a CacheEntryListener.

public MutableConfiguration<K, V>

Returns:

the MutableConfiguration to permit fluent-style method calls
setCacheLoaderFactory
(Factory<? extends CacheLoader<K, V>> factory)

Set the CacheLoader factory.

public MutableConfiguration<K, V>

Returns:

the MutableConfiguration to permit fluent-style method calls
setCacheWriterFactory
(Factory<? extends CacheWriter<? super K, ? super V>> factory)

Set the CacheWriter factory.

public MutableConfiguration<K, V>

Returns:

the MutableConfiguration to permit fluent-style method calls
setExpiryPolicyFactory
(Factory<? extends ExpiryPolicy> factory)

Set the Factory for the ExpiryPolicy.

public MutableConfiguration<K, V>

Returns:

the MutableConfiguration to permit fluent-style method calls
setManagementEnabled
(boolean
true to enable statistics, false to disable.
enabled
)

Sets whether management is enabled on a cache.

public MutableConfiguration<K, V>

Returns:

the MutableConfiguration to permit fluent-style method calls
setReadThrough
(boolean
true if read-through is required
isReadThrough
)

Set if read-through caching should be used.

public MutableConfiguration<K, V>

Returns:

the MutableConfiguration to permit fluent-style method calls
setStatisticsEnabled
(boolean
true to enable statistics, false to disable.
enabled
)

Sets whether statistics gathering is enabled on a cache.

public MutableConfiguration<K, V>

Returns:

the MutableConfiguration to permit fluent-style method calls
setStoreByValue
(boolean
true if store-by-value is required, false for store-by-reference
isStoreByValue
)

Set if a configured cache should use store-by-value or store-by-reference semantics.

public MutableConfiguration<K, V>

Returns:

the MutableConfiguration to permit fluent-style method calls
setTypes
(Class<K>
the expected key type
keyType
,
Class<V>
the expected value type
valueType
)

Sets the expected type of keys and values for a Cache configured with this Configuration.

public MutableConfiguration<K, V>

Returns:

the MutableConfiguration to permit fluent-style method calls
setWriteThrough
(boolean
true if write-through is required
isWriteThrough
)

Set if write-through caching should be used.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheLoaderFactoryback to summary
protected Factory<CacheLoader<K, V>> cacheLoaderFactory

The Factory for the CacheLoader.

cacheWriterFactoryback to summary
protected Factory<CacheWriter<? super K, ? super V>> cacheWriterFactory

The Factory for the CacheWriter.

expiryPolicyFactoryback to summary
protected Factory<ExpiryPolicy> expiryPolicyFactory

The Factory for the ExpiryPolicy.

isManagementEnabledback to summary
protected boolean isManagementEnabled

Whether management is enabled

isReadThroughback to summary
protected boolean isReadThrough

A flag indicating if "read-through" mode is required.

isStatisticsEnabledback to summary
protected boolean isStatisticsEnabled

A flag indicating if statistics gathering is enabled.

isStoreByValueback to summary
protected boolean isStoreByValue

A flag indicating if the cache will be store-by-value or store-by-reference.

isWriteThroughback to summary
protected boolean isWriteThrough

A flag indicating if "write-through" mode is required.

keyTypeback to summary
protected Class<K> keyType

The type of keys for Caches configured with this Configuration.

listenerConfigurationsback to summary
protected HashSet<CacheEntryListenerConfiguration<K, V>> listenerConfigurations

The CacheEntryListenerConfigurations for the Configuration.

serialVersionUIDback to summary
public static final long serialVersionUID

The serialVersionUID required for java.io.Serializable.

valueTypeback to summary
protected Class<V> valueType

The type of values for Caches configured with this Configuration.

Constructor Detail

MutableConfigurationback to summary
public MutableConfiguration()

Default JavaBean constructor.

Creates a default configuration. Default configurations have no runtime type checking and are set for eternal expiry.

To enable runtime type enforcement, if supported by the implementation, call setTypes after construction.

After construction set any other configuration parameters in the fluent style. e.g.

CacheConfiguration<Integer, String> = new MutableConfiguration<Integer, String>()
            .setTypes(Integer.class, String.class)
            .setReadThrough(true)
            . . .
See Also
setTypes(Class, Class)
MutableConfigurationback to summary
public MutableConfiguration(CompleteConfiguration<K, V> configuration)

Constructs a MutableConfiguration based on another CompleteConfiguration.

Parameters
configuration:CompleteConfiguration<K, V>

the CompleteConfiguration

Method Detail

addCacheEntryListenerConfigurationback to summary
public MutableConfiguration<K, V> addCacheEntryListenerConfiguration(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration)

Add a configuration for a CacheEntryListener.

Parameters
cacheEntryListenerConfiguration:CacheEntryListenerConfiguration<K, V>

the CacheEntryListenerConfiguration

Returns:MutableConfiguration<K, V>

the MutableConfiguration to permit fluent-style method calls

Exceptions
IllegalArgumentException:
is the same CacheEntryListenerConfiguration is used more than once
equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
object:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getCacheEntryListenerConfigurationsback to summary
public Iterable<CacheEntryListenerConfiguration<K, V>> getCacheEntryListenerConfigurations()

Implements javax.cache.configuration.CompleteConfiguration.getCacheEntryListenerConfigurations.

Doc from javax.cache.configuration.CompleteConfiguration.getCacheEntryListenerConfigurations.

Obtains the javax.cache.configuration.CacheEntryListenerConfigurations for javax.cache.event.CacheEntryListeners to be configured on a javax.cache.Cache.

Returns:Iterable<CacheEntryListenerConfiguration<K, V>>

an Iterable over the javax.cache.configuration.CacheEntryListenerConfigurations

Annotations
@Override
getCacheLoaderFactoryback to summary
public Factory<CacheLoader<K, V>> getCacheLoaderFactory()

Implements javax.cache.configuration.CompleteConfiguration.getCacheLoaderFactory.

Doc from javax.cache.configuration.CompleteConfiguration.getCacheLoaderFactory.

Gets the javax.cache.configuration.Factory for the javax.cache.integration.CacheLoader, if any.

A CacheLoader should be configured for "Read Through" caches to load values when a cache miss occurs using either the javax.cache.Cache#get(Object) and/or javax.cache.Cache#getAll(java.util.Set) methods.

The default value is null.

Returns:Factory<CacheLoader<K, V>>

the javax.cache.configuration.Factory for the javax.cache.integration.CacheLoader or null if none has been set.

Annotations
@Override
getCacheWriterFactoryback to summary
public Factory<CacheWriter<? super K, ? super V>> getCacheWriterFactory()

Implements javax.cache.configuration.CompleteConfiguration.getCacheWriterFactory.

Doc from javax.cache.configuration.CompleteConfiguration.getCacheWriterFactory.

Gets the javax.cache.configuration.Factory for the javax.cache.integration.CacheWriter, if any.

The default value is null.

Returns:Factory<CacheWriter<? super K, ? super V>>

the javax.cache.configuration.Factory for the javax.cache.integration.CacheWriter or null if none has been set.

Annotations
@Override
getExpiryPolicyFactoryback to summary
public Factory<ExpiryPolicy> getExpiryPolicyFactory()

Implements javax.cache.configuration.CompleteConfiguration.getExpiryPolicyFactory.

Doc from javax.cache.configuration.CompleteConfiguration.getExpiryPolicyFactory.

Gets the javax.cache.configuration.Factory for the javax.cache.expiry.ExpiryPolicy to be used for caches.

The default value is a javax.cache.configuration.Factory that will produce a javax.cache.expiry.EternalExpiryPolicy instance.

Returns:Factory<ExpiryPolicy>

the javax.cache.configuration.Factory for javax.cache.expiry.ExpiryPolicy (must not be null)

getKeyTypeback to summary
public Class<K> getKeyType()

Implements javax.cache.configuration.Configuration.getKeyType.

Doc from javax.cache.configuration.Configuration.getKeyType.

Determines the required type of keys for Caches configured with this Configuration.

Returns:Class<K>

the key type or Object.class if the type is undefined

Annotations
@Override
getValueTypeback to summary
public Class<V> getValueType()

Implements javax.cache.configuration.Configuration.getValueType.

Doc from javax.cache.configuration.Configuration.getValueType.

Determines the required type of values for Caches configured with this Configuration.

Returns:Class<V>

the value type or Object.class if the type is undefined

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isManagementEnabledback to summary
public boolean isManagementEnabled()

Implements javax.cache.configuration.CompleteConfiguration.isManagementEnabled.

Doc from javax.cache.configuration.CompleteConfiguration.isManagementEnabled.

Checks whether management is enabled on this cache.

The default value is false.

Returns:boolean

true if management is enabled

Annotations
@Override
isReadThroughback to summary
public boolean isReadThrough()

Implements javax.cache.configuration.CompleteConfiguration.isReadThrough.

Doc from javax.cache.configuration.CompleteConfiguration.isReadThrough.

Determines if a javax.cache.Cache should operate in read-through mode.

When in "read-through" mode, cache misses that occur due to cache entries not existing as a result of performing a "get" will appropriately cause the configured javax.cache.integration.CacheLoader to be invoked.

The default value is false.

Returns:boolean

true when a javax.cache.Cache is in "read-through" mode.

Annotations
@Override
isStatisticsEnabledback to summary
public boolean isStatisticsEnabled()

Implements javax.cache.configuration.CompleteConfiguration.isStatisticsEnabled.

Doc from javax.cache.configuration.CompleteConfiguration.isStatisticsEnabled.

Checks whether statistics collection is enabled in this cache.

The default value is false.

Returns:boolean

true if statistics collection is enabled

Annotations
@Override
isStoreByValueback to summary
public boolean isStoreByValue()

Implements javax.cache.configuration.Configuration.isStoreByValue.

Doc from javax.cache.configuration.Configuration.isStoreByValue.

Whether storeByValue (true) or storeByReference (false). When true, both keys and values are stored by value.

When false, both keys and values are stored by reference. Caches stored by reference are capable of mutation by any threads holding the reference. The effects are:

  • if the key is mutated, then the key may not be retrievable or removable
  • if the value is mutated, then all threads in the JVM can potentially observe those mutations, subject to the normal Java Memory Model rules.
Storage by reference only applies to the local heap. If an entry is moved off heap it will need to be transformed into a representation. Any mutations that occur after transformation may not be reflected in the cache.

When a cache is storeByValue, any mutation to the key or value does not affect the key of value stored in the cache.

The default value is true.

Returns:boolean

true if the cache is store by value

Annotations
@Override
isWriteThroughback to summary
public boolean isWriteThrough()

Implements javax.cache.configuration.CompleteConfiguration.isWriteThrough.

Doc from javax.cache.configuration.CompleteConfiguration.isWriteThrough.

Determines if a javax.cache.Cache should operate in write-through mode.

When in "write-through" mode, cache updates that occur as a result of performing "put" operations called via one of javax.cache.Cache#put(Object, Object), javax.cache.Cache#getAndRemove(Object), javax.cache.Cache#removeAll(), javax.cache.Cache#getAndPut(Object, Object) javax.cache.Cache#getAndRemove(Object), javax.cache.Cache#getAndReplace(Object, Object), javax.cache.Cache#invoke(Object, javax.cache.processor.EntryProcessor, Object...), javax.cache.Cache#invokeAll(java.util.Set, javax.cache.processor.EntryProcessor, Object...) will appropriately cause the configured javax.cache.integration.CacheWriter to be invoked.

The default value is false.

Returns:boolean

true when a javax.cache.Cache is in "write-through" mode.

Annotations
@Override
removeCacheEntryListenerConfigurationback to summary
public MutableConfiguration<K, V> removeCacheEntryListenerConfiguration(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration)

Remove a configuration for a CacheEntryListener.

Parameters
cacheEntryListenerConfiguration:CacheEntryListenerConfiguration<K, V>

the CacheEntryListenerConfiguration to remove

Returns:MutableConfiguration<K, V>

the MutableConfiguration to permit fluent-style method calls

setCacheLoaderFactoryback to summary
public MutableConfiguration<K, V> setCacheLoaderFactory(Factory<? extends CacheLoader<K, V>> factory)

Set the CacheLoader factory.

Parameters
factory:Factory<? extends CacheLoader<K, V>>

the CacheLoader Factory

Returns:MutableConfiguration<K, V>

the MutableConfiguration to permit fluent-style method calls

setCacheWriterFactoryback to summary
public MutableConfiguration<K, V> setCacheWriterFactory(Factory<? extends CacheWriter<? super K, ? super V>> factory)

Set the CacheWriter factory.

Parameters
factory:Factory<? extends CacheWriter<? super K, ? super V>>

the CacheWriter Factory

Returns:MutableConfiguration<K, V>

the MutableConfiguration to permit fluent-style method calls

setExpiryPolicyFactoryback to summary
public MutableConfiguration<K, V> setExpiryPolicyFactory(Factory<? extends ExpiryPolicy> factory)

Set the Factory for the ExpiryPolicy. If null is specified the default ExpiryPolicy is used.

Only one expiry policy can be set for a cache. The last policy applied before cache construction will be the one used.

Parameters
factory:Factory<? extends ExpiryPolicy>

the ExpiryPolicy Factory

Returns:MutableConfiguration<K, V>

the MutableConfiguration to permit fluent-style method calls

setManagementEnabledback to summary
public MutableConfiguration<K, V> setManagementEnabled(boolean enabled)

Sets whether management is enabled on a cache.

Management may be enabled or disabled at runtime via CacheManager#enableManagement(String, boolean).

Parameters
enabled:boolean

true to enable statistics, false to disable.

Returns:MutableConfiguration<K, V>

the MutableConfiguration to permit fluent-style method calls

setReadThroughback to summary
public MutableConfiguration<K, V> setReadThrough(boolean isReadThrough)

Set if read-through caching should be used.

It is an invalid configuration to set this to true without specifying a CacheLoader Factory.

Parameters
isReadThrough:boolean

true if read-through is required

Returns:MutableConfiguration<K, V>

the MutableConfiguration to permit fluent-style method calls

setStatisticsEnabledback to summary
public MutableConfiguration<K, V> setStatisticsEnabled(boolean enabled)

Sets whether statistics gathering is enabled on a cache.

Statistics may be enabled or disabled at runtime via CacheManager#enableStatistics(String, boolean).

Parameters
enabled:boolean

true to enable statistics, false to disable.

Returns:MutableConfiguration<K, V>

the MutableConfiguration to permit fluent-style method calls

setStoreByValueback to summary
public MutableConfiguration<K, V> setStoreByValue(boolean isStoreByValue)

Set if a configured cache should use store-by-value or store-by-reference semantics.

Parameters
isStoreByValue:boolean

true if store-by-value is required, false for store-by-reference

Returns:MutableConfiguration<K, V>

the MutableConfiguration to permit fluent-style method calls

setTypesback to summary
public MutableConfiguration<K, V> setTypes(Class<K> keyType, Class<V> valueType)

Sets the expected type of keys and values for a Cache configured with this Configuration. Setting both to Object.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 the Cache 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.

Parameters
keyType:Class<K>

the expected key type

valueType:Class<V>

the expected value type

Returns:MutableConfiguration<K, V>

the MutableConfiguration to permit fluent-style method calls

Exceptions
NullPointerException:
should the key or value type be null
See Also
CacheManager#getCache(String, Class, Class)
setWriteThroughback to summary
public MutableConfiguration<K, V> setWriteThrough(boolean isWriteThrough)

Set if write-through caching should be used.

It is an invalid configuration to set this to true without specifying a CacheWriter Factory.

Parameters
isWriteThrough:boolean

true if write-through is required

Returns:MutableConfiguration<K, V>

the MutableConfiguration to permit fluent-style method calls