public class CallableCacheLoaderAdapter<K,V> extends Object implements Callable<V>, org.apache.geode.cache.CacheLoader<K,V>
CallableCacheLoaderAdapter
class is a Callable
and GemFire CacheLoader
implementation
that adapts the Callable
interface into an instance of the CacheLoader
interface. This class is
useful in situations where GemFire developers have several CacheLoader
implementations that they wish to
use with Spring's Cache Abstraction.Callable
,
CacheLoader
,
LoaderHelper
,
Region
Constructor and Description |
---|
CallableCacheLoaderAdapter(org.apache.geode.cache.CacheLoader<K,V> delegate)
Constructs an instance of the CallableCacheLoaderAdapter that delegates to the given
CacheLoader . |
CallableCacheLoaderAdapter(org.apache.geode.cache.CacheLoader<K,V> delegate,
K key,
org.apache.geode.cache.Region<K,V> region)
Constructs an instance of the CallableCacheLoaderAdapter that delegates to the given
CacheLoader
and is initialized with the given key for which the value will be loaded along with the Region
in which the entry (key/value) belongs. |
CallableCacheLoaderAdapter(org.apache.geode.cache.CacheLoader<K,V> delegate,
K key,
org.apache.geode.cache.Region<K,V> region,
Object argument)
Constructs an instance of the CallableCacheLoaderAdapter that delegates to the given
CacheLoader
and is initialized with the given key for which the value will be loaded along with the Region
in which the entry (key/value) belongs. |
Modifier and Type | Method and Description |
---|---|
V |
call()
Invoked to load a cache value for the specified key.
|
void |
close()
Closes any resources used by this
CacheLoader . |
protected Object |
getArgument()
Gets the argument used by this
CacheLoader to load the value for the specified key. |
protected org.apache.geode.cache.CacheLoader<K,V> |
getCacheLoader()
The
CacheLoader delegate used to actually load the cache value for the specified key. |
protected K |
getKey()
The specified key for which a value will be loaded by this
CacheLoader . |
protected org.apache.geode.cache.Region<K,V> |
getRegion()
Returns the Region to which the entry (key/value) belongs.
|
V |
load(org.apache.geode.cache.LoaderHelper<K,V> loaderHelper)
Loads a value for the specified cache (i.e.
|
public CallableCacheLoaderAdapter(org.apache.geode.cache.CacheLoader<K,V> delegate)
CacheLoader
.delegate
- the CacheLoader
delegated to by this adapter.CallableCacheLoaderAdapter(CacheLoader, Object, Region, Object)
,
CacheLoader
public CallableCacheLoaderAdapter(org.apache.geode.cache.CacheLoader<K,V> delegate, K key, org.apache.geode.cache.Region<K,V> region)
CacheLoader
and is initialized with the given key for which the value will be loaded along with the Region
in which the entry (key/value) belongs.delegate
- the CacheLoader
delegated to by this adapter.key
- the key for which the value will be loaded.region
- the Region
in which the entry (key/value) belongs.CallableCacheLoaderAdapter(CacheLoader, Object, Region, Object)
,
CacheLoader
,
Region
public CallableCacheLoaderAdapter(org.apache.geode.cache.CacheLoader<K,V> delegate, K key, org.apache.geode.cache.Region<K,V> region, Object argument)
CacheLoader
and is initialized with the given key for which the value will be loaded along with the Region
in which the entry (key/value) belongs. Additionally, an argument may be specified for use with the
CacheLoader
delegate.delegate
- the CacheLoader
delegated to by this adapter.key
- the key for which the value will be loaded.region
- the Region
in which the entry (key/value) belongs.argument
- the Object argument used with the CacheLoader
delegate.CallableCacheLoaderAdapter(CacheLoader, Object, Region, Object)
,
CacheLoader
,
Region
protected Object getArgument()
CacheLoader
to load the value for the specified key.CacheLoader
when loading the value for the specified key.protected org.apache.geode.cache.CacheLoader<K,V> getCacheLoader()
CacheLoader
delegate used to actually load the cache value for the specified key.CacheLoader
used when loading the cache value for the specified key.CacheLoader
protected K getKey()
CacheLoader
.protected org.apache.geode.cache.Region<K,V> getRegion()
Region
public final V call() throws Exception
load(LoaderHelper)
.call
in interface Callable<V>
IllegalStateException
- if the Region
or key references are null.Exception
- if the load operation fails.load(LoaderHelper)
public void close()
CacheLoader
. Delegates to the underlying CacheLoader
.close
in interface org.apache.geode.cache.CacheCallback
getCacheLoader()
public V load(org.apache.geode.cache.LoaderHelper<K,V> loaderHelper) throws org.apache.geode.cache.CacheLoaderException
Region
) and key with the help of the LoaderHelper
.
Delegates to the underlying CacheLoader
.load
in interface org.apache.geode.cache.CacheLoader<K,V>
loaderHelper
- a LoaderHelper
object passed in from cache service providing access to the key,
Region
, argument, and netSearch
.null
causes
Region.get(Object, Object)
to return null
.org.apache.geode.cache.CacheLoaderException
- if an error occurs during the load operation. This exception, or any other
Exception thrown by this method will be propagated back to the application from the
Region.get(Object)
method.CacheLoader.load(LoaderHelper)
,
LoaderHelper
,
getCacheLoader()
Copyright © 2011–2017 Pivotal Software, Inc.. All rights reserved.