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>
cache
protected ObjectTransformer<K,K0>
keyTransformer
protected ObjectTransformer<K,K0>
passingKeyTransformer
protected ObjectTransformer<V,V0>
passingValueTransformer
protected 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 void
clear()
void
close()
boolean
containsKey(K key)
V
get(K key)
Map<K,V>
getAll(Set<? extends K> keys)
V
getAndPut(K key, V value)
V
getAndRemove(K key)
V
getAndReplace(K key, V value)
javax.cache.CacheManager
getCacheManager()
String
getName()
javax.cache.Cache<K0,V0>
getWrappedCache()
<T> T
invoke(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)
boolean
isClosed()
Iterator<javax.cache.Cache.Entry<K,V>>
iterator()
void
loadAll(Set<? extends K> keys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener)
void
put(K key, V value)
void
putAll(Map<? extends K,? extends V> map)
boolean
putIfAbsent(K key, V value)
boolean
remove(K key)
boolean
remove(K key, V oldValue)
void
removeAll()
void
removeAll(Set<? extends K> keys)
boolean
replace(K key, V value)
boolean
replace(K key, V oldValue, V newValue)
String
toString()
<T> T
unwrap(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)
-
-