Class TransformingCacheProxy<K,V,K0,V0>
- java.lang.Object
-
- org.cache2k.jcache.provider.generic.storeByValueSimulation.TransformingCacheProxy<K,V,K0,V0>
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<javax.cache.Cache.Entry<K,V>>,javax.cache.Cache<K,V>
- Direct Known Subclasses:
CopyCacheProxy
public abstract class TransformingCacheProxy<K,V,K0,V0> extends Object implements javax.cache.Cache<K,V>
This is a proxy that filters all keys and values that go in and out. The basic use case is to mimic store by value semantics on a heap based cache. This is done by cloning or otherwise copying all instances that go in and out from a cache.This generic approach also may convert the types. Right now we just need the identical types, so this might be a little over engineered.
Complete except listeners and configuration.
- Author:
- Jens Wilke
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.cache.Cache<K0,V0>cacheprotected ObjectTransformer<K,K0>keyTransformerprotected ObjectTransformer<K,K0>passingKeyTransformerprotected ObjectTransformer<V,V0>passingValueTransformerprotected ObjectTransformer<V,V0>valueTransformer
-
Constructor Summary
Constructors Constructor Description TransformingCacheProxy(javax.cache.Cache<K0,V0> cache, ObjectTransformer<K,K0> keyTransformer, ObjectTransformer<V,V0> valueTransformer, ObjectTransformer<K,K0> passingKeyTransformer, ObjectTransformer<V,V0> passingValueTransformer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()voidclose()booleancontainsKey(K key)Vget(K key)Map<K,V>getAll(Set<? extends K> keys)VgetAndPut(K key, V value)VgetAndRemove(K key)VgetAndReplace(K key, V value)javax.cache.CacheManagergetCacheManager()StringgetName()javax.cache.Cache<K0,V0>getWrappedCache()<T> Tinvoke(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments)<T> Map<K,javax.cache.processor.EntryProcessorResult<T>>invokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments)booleanisClosed()Iterator<javax.cache.Cache.Entry<K,V>>iterator()voidloadAll(Set<? extends K> keys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener)voidput(K key, V value)voidputAll(Map<? extends K,? extends V> map)booleanputIfAbsent(K key, V value)booleanremove(K key)booleanremove(K key, V oldValue)voidremoveAll()voidremoveAll(Set<? extends K> keys)booleanreplace(K key, V value)booleanreplace(K key, V oldValue, V newValue)StringtoString()<T> Tunwrap(Class<T> clazz)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.cache.Cache
deregisterCacheEntryListener, getConfiguration, registerCacheEntryListener
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
keyTransformer
protected ObjectTransformer<K,K0> keyTransformer
-
valueTransformer
protected ObjectTransformer<V,V0> valueTransformer
-
passingKeyTransformer
protected ObjectTransformer<K,K0> passingKeyTransformer
-
passingValueTransformer
protected ObjectTransformer<V,V0> passingValueTransformer
-
-
Constructor Detail
-
TransformingCacheProxy
public TransformingCacheProxy(javax.cache.Cache<K0,V0> cache, ObjectTransformer<K,K0> keyTransformer, ObjectTransformer<V,V0> valueTransformer, ObjectTransformer<K,K0> passingKeyTransformer, ObjectTransformer<V,V0> passingValueTransformer)
- Parameters:
cache- the wrapped cachekeyTransformer- Keys that go in and out will be sent throughvalueTransformer- Values that go in and out will be sent throughpassingKeyTransformer- Special transformer for keys that go in and are not stored by the cache (e.g. for #conatainsKey)passingValueTransformer- Special transformer for keys that go in and are not stored by the cache (e.g. for the oldValue in replace)
-
-
Method Detail
-
containsKey
public boolean containsKey(K key)
-
loadAll
public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener)
-
invoke
public <T> T invoke(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments) throws javax.cache.processor.EntryProcessorException
-
invokeAll
public <T> Map<K,javax.cache.processor.EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments)
-
getCacheManager
public javax.cache.CacheManager getCacheManager()
-
close
public void close()
-
unwrap
public <T> T unwrap(Class<T> clazz)
-
-