public class AbstractDelegatingAdvancedCache<K,V> extends AbstractDelegatingCache<K,V> implements AdvancedCache<K,V>
AbstractDelegatingCache
, but for AdvancedCache
.AbstractDelegatingCache
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractDelegatingAdvancedCache.AdvancedCacheWrapper<K,V> |
Modifier and Type | Field and Description |
---|---|
protected AdvancedCache<K,V> |
cache |
private AbstractDelegatingAdvancedCache.AdvancedCacheWrapper<K,V> |
wrapper |
Constructor and Description |
---|
AbstractDelegatingAdvancedCache(AdvancedCache<K,V> cache) |
AbstractDelegatingAdvancedCache(AdvancedCache<K,V> cache,
AbstractDelegatingAdvancedCache.AdvancedCacheWrapper<K,V> wrapper) |
Modifier and Type | Method and Description |
---|---|
void |
addInterceptor(org.infinispan.interceptors.base.CommandInterceptor i,
int position)
Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the
chain is at position 0 and the last one at NUM_INTERCEPTORS - 1.
|
boolean |
addInterceptorAfter(org.infinispan.interceptors.base.CommandInterceptor i,
java.lang.Class<? extends org.infinispan.interceptors.base.CommandInterceptor> afterInterceptor)
Adds a custom interceptor to the interceptor chain, after an instance of the specified interceptor type.
|
boolean |
addInterceptorBefore(org.infinispan.interceptors.base.CommandInterceptor i,
java.lang.Class<? extends org.infinispan.interceptors.base.CommandInterceptor> beforeInterceptor)
Adds a custom interceptor to the interceptor chain, before an instance of the specified interceptor type.
|
void |
applyDelta(K deltaAwareValueKey,
org.infinispan.atomic.Delta delta,
java.lang.Object... locksToAcquire)
Applies the given Delta to the DeltaAware object stored under deltaAwareValueKey if and only if all
locksToAcquire locks are successfully obtained
|
org.infinispan.iteration.EntryIterable<K,V> |
filterEntries(org.infinispan.filter.KeyValueFilter<? super K,? super V> filter)
Retrieve the entry iterable that can be used to iterate over the contents of this cache.
|
AdvancedCache<K,V> |
getAdvancedCache() |
org.infinispan.security.AuthorizationManager |
getAuthorizationManager()
Retrieves the
AuthorizationManager if the cache has security enabled. |
org.infinispan.batch.BatchContainer |
getBatchContainer()
Returns the component in charge of batching cache operations.
|
org.infinispan.container.entries.CacheEntry |
getCacheEntry(K key)
Retrieves a CacheEntry corresponding to a specific key.
|
java.lang.ClassLoader |
getClassLoader()
Returns the cache loader associated associated with this cache.
|
org.infinispan.factories.ComponentRegistry |
getComponentRegistry() |
org.infinispan.container.DataContainer |
getDataContainer()
Returns the container where data is stored in the cache.
|
org.infinispan.distribution.DistributionManager |
getDistributionManager()
Retrieves a reference to the
DistributionManager if the cache is configured
to use Distribution. |
org.infinispan.eviction.EvictionManager |
getEvictionManager() |
java.util.List<org.infinispan.interceptors.base.CommandInterceptor> |
getInterceptorChain()
Retrieves the current Interceptor chain.
|
org.infinispan.context.InvocationContextContainer |
getInvocationContextContainer()
Returns the component in charge of managing the interactions between the
cache operations and the context information associated with them.
|
org.infinispan.util.concurrent.locks.LockManager |
getLockManager()
Returns the component that deals with all aspects of acquiring and
releasing locks for cache entries.
|
org.infinispan.remoting.rpc.RpcManager |
getRpcManager()
Returns the component in charge of communication with other caches in
the cluster.
|
org.infinispan.stats.Stats |
getStats()
Returns a
Stats object that allows several statistics associated
with this cache at runtime. |
TransactionManager |
getTransactionManager()
Returns the transaction manager configured for this cache.
|
javax.transaction.xa.XAResource |
getXAResource()
Returns the
XAResource associated with this cache which can be
used to do transactional recovery. |
boolean |
lock(java.util.Collection<? extends K> keys)
Locks collections of keys eagerly across cache nodes in a cluster.
|
boolean |
lock(K... key)
Locks a given key or keys eagerly across cache nodes in a cluster.
|
V |
put(K key,
V value,
org.infinispan.metadata.Metadata metadata)
An overloaded form of
#put(K, V) , which takes in an instance of
Metadata which can be used to provide metadata information for
the entry being stored, such as lifespan, version of value...etc. |
org.infinispan.util.concurrent.NotifyingFuture<V> |
putAsync(K key,
V value,
org.infinispan.metadata.Metadata metadata)
Asynchronous version of
AdvancedCache.put(Object, Object, Metadata) which stores
metadata alongside the value. |
protected void |
putForExternalRead(K key,
V value,
java.util.EnumSet<org.infinispan.context.Flag> flags,
java.lang.ClassLoader classLoader) |
V |
putIfAbsent(K key,
V value,
org.infinispan.metadata.Metadata metadata)
An overloaded form of
#putIfAbsent(K, V) , which takes in an
instance of Metadata which can be used to provide metadata
information for the entry being stored, such as lifespan, version
of value...etc. |
void |
removeInterceptor(java.lang.Class<? extends org.infinispan.interceptors.base.CommandInterceptor> interceptorType)
Removes the interceptor of specified type.
|
void |
removeInterceptor(int position)
Removes the interceptor at a specified position, where the first interceptor in the chain is at position 0 and the
last one at getInterceptorChain().size() - 1.
|
V |
replace(K key,
V value,
org.infinispan.metadata.Metadata metadata)
An overloaded form of
#replace(K, V) , which takes in an
instance of Metadata which can be used to provide metadata
information for the entry being stored, such as lifespan, version
of value...etc. |
boolean |
replace(K key,
V oldValue,
V value,
org.infinispan.metadata.Metadata metadata)
An overloaded form of
#replace(K, V, V) , which takes in an
instance of Metadata which can be used to provide metadata
information for the entry being stored, such as lifespan, version
of value...etc. |
AdvancedCache<K,V> |
with(java.lang.ClassLoader classLoader)
Using this operation, users can call any
AdvancedCache operation
with a given ClassLoader . |
AdvancedCache<K,V> |
withFlags(org.infinispan.context.Flag... flags)
A method that adds flags to any API call.
|
addListener, addListener, clear, clearAsync, containsKey, containsValue, endBatch, entrySet, evict, get, getAsync, getCacheConfiguration, getCacheManager, getDelegate, getListeners, getName, getStatus, getVersion, isEmpty, keySet, put, put, put, putAll, putAll, putAll, putAllAsync, putAllAsync, putAllAsync, putAsync, putAsync, putAsync, putForExternalRead, putIfAbsent, putIfAbsent, putIfAbsent, putIfAbsentAsync, putIfAbsentAsync, putIfAbsentAsync, remove, remove, removeAsync, removeAsync, removeListener, replace, replace, replace, replace, replace, replace, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, set, size, start, startBatch, stop, toString, values
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
entrySet, evict, getCacheConfiguration, getCacheManager, getStatus, keySet, putForExternalRead, size, values
clearAsync, getAsync, putAllAsync, putAllAsync, putAllAsync, putAsync, putAsync, putAsync, putIfAbsentAsync, putIfAbsentAsync, putIfAbsentAsync, removeAsync, removeAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync
getName, getVersion, put, put, put, putAll, putAll, putIfAbsent, putIfAbsent, remove, replace, replace, replace, replace
putIfAbsent, remove, replace, replace
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, putAll
endBatch, startBatch
protected final AdvancedCache<K,V> cache
private final AbstractDelegatingAdvancedCache.AdvancedCacheWrapper<K,V> wrapper
public AbstractDelegatingAdvancedCache(AdvancedCache<K,V> cache)
public AbstractDelegatingAdvancedCache(AdvancedCache<K,V> cache, AbstractDelegatingAdvancedCache.AdvancedCacheWrapper<K,V> wrapper)
public void addInterceptor(org.infinispan.interceptors.base.CommandInterceptor i, int position)
AdvancedCache
addInterceptor
in interface AdvancedCache<K,V>
i
- the interceptor to addposition
- the position to add the interceptorpublic boolean addInterceptorAfter(org.infinispan.interceptors.base.CommandInterceptor i, java.lang.Class<? extends org.infinispan.interceptors.base.CommandInterceptor> afterInterceptor)
AdvancedCache
addInterceptorAfter
in interface AdvancedCache<K,V>
i
- interceptor to addafterInterceptor
- interceptor type after which to place custom interceptorpublic boolean addInterceptorBefore(org.infinispan.interceptors.base.CommandInterceptor i, java.lang.Class<? extends org.infinispan.interceptors.base.CommandInterceptor> beforeInterceptor)
AdvancedCache
addInterceptorBefore
in interface AdvancedCache<K,V>
i
- interceptor to addbeforeInterceptor
- interceptor type before which to place custom interceptorpublic void removeInterceptor(int position)
AdvancedCache
removeInterceptor
in interface AdvancedCache<K,V>
position
- the position at which to remove an interceptorpublic void removeInterceptor(java.lang.Class<? extends org.infinispan.interceptors.base.CommandInterceptor> interceptorType)
AdvancedCache
removeInterceptor
in interface AdvancedCache<K,V>
interceptorType
- type of interceptor to removepublic AdvancedCache<K,V> getAdvancedCache()
getAdvancedCache
in interface Cache<K,V>
getAdvancedCache
in class AbstractDelegatingCache<K,V>
public java.util.List<org.infinispan.interceptors.base.CommandInterceptor> getInterceptorChain()
AdvancedCache
getInterceptorChain
in interface AdvancedCache<K,V>
List
of CommandInterceptor
s
configured for this cachepublic org.infinispan.eviction.EvictionManager getEvictionManager()
getEvictionManager
in interface AdvancedCache<K,V>
public org.infinispan.factories.ComponentRegistry getComponentRegistry()
getComponentRegistry
in interface AdvancedCache<K,V>
public org.infinispan.distribution.DistributionManager getDistributionManager()
AdvancedCache
DistributionManager
if the cache is configured
to use Distribution. Otherwise, returns a null.getDistributionManager
in interface AdvancedCache<K,V>
public org.infinispan.security.AuthorizationManager getAuthorizationManager()
AdvancedCache
AuthorizationManager
if the cache has security enabled. Otherwise returns nullgetAuthorizationManager
in interface AdvancedCache<K,V>
public org.infinispan.remoting.rpc.RpcManager getRpcManager()
AdvancedCache
ClusteringConfiguration.cacheMode()
is CacheMode.LOCAL
, this
method will return null.getRpcManager
in interface AdvancedCache<K,V>
public org.infinispan.batch.BatchContainer getBatchContainer()
AdvancedCache
getBatchContainer
in interface AdvancedCache<K,V>
public org.infinispan.context.InvocationContextContainer getInvocationContextContainer()
AdvancedCache
getInvocationContextContainer
in interface AdvancedCache<K,V>
public org.infinispan.container.DataContainer getDataContainer()
AdvancedCache
getDataContainer
in interface AdvancedCache<K,V>
public TransactionManager getTransactionManager()
AdvancedCache
getTransactionManager
in interface AdvancedCache<K,V>
public org.infinispan.util.concurrent.locks.LockManager getLockManager()
AdvancedCache
getLockManager
in interface AdvancedCache<K,V>
public javax.transaction.xa.XAResource getXAResource()
AdvancedCache
XAResource
associated with this cache which can be
used to do transactional recovery.getXAResource
in interface AdvancedCache<K,V>
XAResource
public AdvancedCache<K,V> withFlags(org.infinispan.context.Flag... flags)
AdvancedCache
cache.withFlags(Flag.FORCE_WRITE_LOCK).get(key);will invoke a cache.get() with a write lock forced. Note that for the flag to take effect, the cache operation must be invoked on the instance returned by this method. As an alternative to setting this on every invocation, users could also consider using the
DecoratedCache
wrapper, as this allows for more readable
code. E.g.:
Cache forceWriteLockCache = new DecoratedCache(cache, Flag.FORCE_WRITE_LOCK); forceWriteLockCache.get(key1); forceWriteLockCache.get(key2); forceWriteLockCache.get(key3);
withFlags
in interface AdvancedCache<K,V>
flags
- a set of flags to apply. See the Flag
documentation.AdvancedCache
instance on which a real operation is to be invoked, if the flags are
to be applied.public boolean lock(K... key)
AdvancedCache
Keys can be locked eagerly in the context of a transaction only.
lock
in interface AdvancedCache<K,V>
key
- the keys to lockFlag.FAIL_SILENTLY
.public boolean lock(java.util.Collection<? extends K> keys)
AdvancedCache
Collections of keys can be locked eagerly in the context of a transaction only.
lock
in interface AdvancedCache<K,V>
keys
- collection of keys to lockFlag.FAIL_SILENTLY
.public void applyDelta(K deltaAwareValueKey, org.infinispan.atomic.Delta delta, java.lang.Object... locksToAcquire)
AdvancedCache
applyDelta
in interface AdvancedCache<K,V>
deltaAwareValueKey
- the key for DeltaAware objectdelta
- the delta to be applied to DeltaAware objectlocksToAcquire
- keys to be locked in DeltaAware scopepublic org.infinispan.stats.Stats getStats()
AdvancedCache
Stats
object that allows several statistics associated
with this cache at runtime.getStats
in interface AdvancedCache<K,V>
Stats
objectpublic java.lang.ClassLoader getClassLoader()
AdvancedCache
DecoratedCache
wrapper.getClassLoader
in interface AdvancedCache<K,V>
public AdvancedCache<K,V> with(java.lang.ClassLoader classLoader)
AdvancedCache
AdvancedCache
operation
with a given ClassLoader
. This means that any ClassLoader
happening
as a result of the cache operation will be done using the ClassLoader
given. For example:
When users store POJO instances in caches configured with StoreAsBinaryConfiguration
,
these instances are transformed into byte arrays. When these entries are
read from the cache, a lazy unmarshalling process happens where these byte
arrays are transformed back into POJO instances. Using AdvancedCache.with(ClassLoader)
when reading that enables users to provide the class loader that should
be used when trying to locate the classes that are constructed as a result
of the unmarshalling process.
cache.with(classLoader).get(key);Note that for the flag to take effect, the cache operation must be invoked on the instance returned by this method. As an alternative to setting this on every invocation, users could also consider using the
DecoratedCache
wrapper, as this allows for more readable
code. E.g.:
Cache classLoaderSpecificCache = new DecoratedCache(cache, classLoader); classLoaderSpecificCache.get(key1); classLoaderSpecificCache.get(key2); classLoaderSpecificCache.get(key3);
with
in interface AdvancedCache<K,V>
AdvancedCache
instance upon which operations can be called
with a particular ClassLoader
.public org.infinispan.container.entries.CacheEntry getCacheEntry(K key)
AdvancedCache
getCacheEntry
in interface AdvancedCache<K,V>
key
- the key whose associated cache entry is to be returnednull
if this map contains no mapping for the keypublic org.infinispan.iteration.EntryIterable<K,V> filterEntries(org.infinispan.filter.KeyValueFilter<? super K,? super V> filter)
AdvancedCache
Iterable.iterator()
will cause a new request chain to retrieve all of the values in
the cache, including any configured loaders. This iterator is performed in memory sensitive way and thus works
for distributed caches unlike Cache.entrySet()
.
Whenever possible a user should provide a converter through
EntryIterable.converter(org.infinispan.filter.Converter)
to reduce value
payloads or create projection views.
This iterator does not participate in any ongoing transaction that may be present. This is because
IsolationLevel.REPEATABLE_READ
transactions have to keep track of all
the entries they have read (which in this case would include the entries that did not match the filter).
Keeping all the values on a single node would negate the benefits of using a filter and/or converter, and in many
cases it would cause OutOfMemoryErrors. If it is desired to remove entries the
BasicCache.remove(Object)
method or another similar method may be used which would
participate in the transaction
The iterable should always be closed after finished with it, using the standard try/finally or try with resource idioms to ensure that any current resources are freed if an exception prevents full iteration of iterator. Note this will prevent any ongoing iterators that were created from it from progressing further.
filterEntries
in interface AdvancedCache<K,V>
filter
- The filter to use. Note this is required and for distributed caches must be serializablepublic V put(K key, V value, org.infinispan.metadata.Metadata metadata)
AdvancedCache
#put(K, V)
, which takes in an instance of
Metadata
which can be used to provide metadata information for
the entry being stored, such as lifespan, version of value...etc.put
in interface AdvancedCache<K,V>
key
- key to usevalue
- value to storemetadata
- information to store alongside the valuepublic V replace(K key, V value, org.infinispan.metadata.Metadata metadata)
AdvancedCache
#replace(K, V)
, which takes in an
instance of Metadata
which can be used to provide metadata
information for the entry being stored, such as lifespan, version
of value...etc. The Metadata
is only stored if the call is
successful.replace
in interface AdvancedCache<K,V>
key
- key with which the specified value is associatedvalue
- value to be associated with the specified keymetadata
- information to store alongside the new valuepublic boolean replace(K key, V oldValue, V value, org.infinispan.metadata.Metadata metadata)
AdvancedCache
#replace(K, V, V)
, which takes in an
instance of Metadata
which can be used to provide metadata
information for the entry being stored, such as lifespan, version
of value...etc. The Metadata
is only stored if the call is
successful.replace
in interface AdvancedCache<K,V>
key
- key with which the specified value is associatedoldValue
- value expected to be associated with the specified keyvalue
- value to be associated with the specified keymetadata
- information to store alongside the new valuepublic V putIfAbsent(K key, V value, org.infinispan.metadata.Metadata metadata)
AdvancedCache
#putIfAbsent(K, V)
, which takes in an
instance of Metadata
which can be used to provide metadata
information for the entry being stored, such as lifespan, version
of value...etc. The Metadata
is only stored if the call is
successful.putIfAbsent
in interface AdvancedCache<K,V>
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keymetadata
- information to store alongside the new valuepublic org.infinispan.util.concurrent.NotifyingFuture<V> putAsync(K key, V value, org.infinispan.metadata.Metadata metadata)
AdvancedCache
AdvancedCache.put(Object, Object, Metadata)
which stores
metadata alongside the value. This method does not block on remote calls,
even if your cache mode is synchronous. Has no benefit over
AdvancedCache.put(Object, Object, Metadata)
if used in LOCAL mode.
putAsync
in interface AdvancedCache<K,V>
key
- key to usevalue
- value to storemetadata
- information to store alongside the new value