org.axonframework.cache
Class JCacheAdapter

java.lang.Object
  extended by org.axonframework.cache.AbstractCacheAdapter<javax.cache.configuration.CacheEntryListenerConfiguration>
      extended by org.axonframework.cache.JCacheAdapter
All Implemented Interfaces:
Cache

public class JCacheAdapter
extends AbstractCacheAdapter<javax.cache.configuration.CacheEntryListenerConfiguration>

Cache adapter implementation that allows providers implementing the JCache abstraction to be used.

Since:
2.1.2
Author:
Allard Buijze

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.axonframework.cache.Cache
Cache.EntryListener, Cache.EntryListenerAdapter
 
Constructor Summary
JCacheAdapter(javax.cache.Cache jCache)
          Initialize the adapter to forward call to the given jCache instance
 
Method Summary
<K> boolean
containsKey(K key)
          Indicates whether there is an item stored under given key.
protected  javax.cache.configuration.CacheEntryListenerConfiguration createListenerAdapter(Cache.EntryListener cacheEntryListener)
          Creates an adapter for the given cacheEntryListener.
protected  void doRegisterListener(javax.cache.configuration.CacheEntryListenerConfiguration listenerAdapter)
          Registers the given listener with the cache implementation
protected  void doUnregisterListener(javax.cache.configuration.CacheEntryListenerConfiguration listenerAdapter)
          Unregisters the given listener with the cache
<K,V> V
get(K key)
          Returns an item from the cache, or null if no item was stored under that key
<K,V> void
put(K key, V value)
          Stores the given value in the cache, under given key.
<K,V> boolean
putIfAbsent(K key, V value)
          Stores the given value in the cache, under given key, if no element is yet available under that key.
<K> boolean
remove(K key)
          Removes the entry stored under given key.
 
Methods inherited from class org.axonframework.cache.AbstractCacheAdapter
registerCacheEntryListener, unregisterCacheEntryListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCacheAdapter

public JCacheAdapter(javax.cache.Cache jCache)
Initialize the adapter to forward call to the given jCache instance

Parameters:
jCache - The cache to forward all calls to
Method Detail

get

public <K,V> V get(K key)
Description copied from interface: Cache
Returns an item from the cache, or null if no item was stored under that key

Type Parameters:
K - The type of key used
V - The type of value stored
Parameters:
key - The key under which the item was cached
Returns:
the item stored under the given key

put

public <K,V> void put(K key,
                      V value)
Description copied from interface: Cache
Stores the given value in the cache, under given key. If an item already exists, it is updated with the new value.

Type Parameters:
K - The type of key used
V - The type of value stored
Parameters:
key - The key under which to store the item
value - The item to cache

putIfAbsent

public <K,V> boolean putIfAbsent(K key,
                                 V value)
Description copied from interface: Cache
Stores the given value in the cache, under given key, if no element is yet available under that key. This operation is performed atomically.

Type Parameters:
K - The type of key used
V - The type of value stored
Parameters:
key - The key under which to store the item
value - The item to cache
Returns:
true if no value was previously assigned to the key, false otherwise.

remove

public <K> boolean remove(K key)
Description copied from interface: Cache
Removes the entry stored under given key. If no such entry exists, nothing happens.

Type Parameters:
K - The type of key used
Parameters:
key - The key under which the item was stored
Returns:
true if a value was previously assigned to the key and has been removed, false otherwise.

containsKey

public <K> boolean containsKey(K key)
Description copied from interface: Cache
Indicates whether there is an item stored under given key.

Type Parameters:
K - The type of key
Parameters:
key - The key to check
Returns:
true if an item is available under that key, false otherwise.

createListenerAdapter

protected javax.cache.configuration.CacheEntryListenerConfiguration createListenerAdapter(Cache.EntryListener cacheEntryListener)
Description copied from class: AbstractCacheAdapter
Creates an adapter for the given cacheEntryListener. The adapter must forward all incoming notifications to the respective methods on the cacheEntryListener.

Specified by:
createListenerAdapter in class AbstractCacheAdapter<javax.cache.configuration.CacheEntryListenerConfiguration>
Parameters:
cacheEntryListener - The listener to create an adapter for
Returns:
an adapter that forwards notifications

doUnregisterListener

protected void doUnregisterListener(javax.cache.configuration.CacheEntryListenerConfiguration listenerAdapter)
Description copied from class: AbstractCacheAdapter
Unregisters the given listener with the cache

Specified by:
doUnregisterListener in class AbstractCacheAdapter<javax.cache.configuration.CacheEntryListenerConfiguration>
Parameters:
listenerAdapter - The listener to register with the cache

doRegisterListener

protected void doRegisterListener(javax.cache.configuration.CacheEntryListenerConfiguration listenerAdapter)
Description copied from class: AbstractCacheAdapter
Registers the given listener with the cache implementation

Specified by:
doRegisterListener in class AbstractCacheAdapter<javax.cache.configuration.CacheEntryListenerConfiguration>
Parameters:
listenerAdapter - the listener to register


Copyright © 2010-2016. All Rights Reserved.