|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.infinispan.loaders.AbstractCacheLoader
org.infinispan.loaders.AbstractCacheStore
org.infinispan.jcache.JCacheLoaderAdapter<K,V>
public class JCacheLoaderAdapter<K,V>
Field Summary |
---|
Fields inherited from class org.infinispan.loaders.AbstractCacheStore |
---|
multiThreadedPurge, purgerService |
Fields inherited from class org.infinispan.loaders.AbstractCacheLoader |
---|
cache, marshaller, timeService |
Constructor Summary | |
---|---|
JCacheLoaderAdapter()
|
Method Summary | |
---|---|
void |
clear()
Clears all entries in the store |
void |
commit(GlobalTransaction tx)
Commits a transaction that has been previously prepared. |
void |
fromStream(ObjectInput inputStream)
Writes contents of the stream to the store. |
Class<? extends CacheLoaderConfig> |
getConfigurationClass()
This method is used by the configuration parser to get a hold of the CacheLoader implementation's corresponding CacheLoaderConfig type. |
Set<InternalCacheEntry> |
load(int numEntries)
Loads up to a specific number of entries. |
InternalCacheEntry |
load(Object key)
Loads an entry mapped to by a given key. |
Set<InternalCacheEntry> |
loadAll()
Loads all entries in the loader. |
Set<Object> |
loadAllKeys(Set<Object> keysToExclude)
Loads a set of all keys, excluding a filter set. |
void |
prepare(List<? extends Modification> list,
GlobalTransaction tx,
boolean isOnePhase)
Issues a prepare call with a set of modifications to be applied to the cache store |
void |
purgeExpired()
Purges expired entries from the store. |
protected void |
purgeInternal()
|
boolean |
remove(Object key)
Removes an entry in the store. |
void |
rollback(GlobalTransaction tx)
Rolls back a transaction that has been previously prepared This method may be invoked on a transaction for which there is no prior CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean) . |
void |
setCacheLoader(javax.cache.CacheLoader<K,V> delegate)
|
void |
start()
|
void |
stop()
|
void |
store(InternalCacheEntry entry)
Stores an entry |
void |
toStream(ObjectOutput outputStream)
Loads the entire state into a stream, using whichever format is most efficient for the cache loader implementation. |
Methods inherited from class org.infinispan.loaders.AbstractCacheStore |
---|
applyModifications, getCacheStoreConfig, getConcurrencyLevel, getMarshaller, init, removeAll, safeClose, safeClose, supportsMultiThreadedPurge |
Methods inherited from class org.infinispan.loaders.AbstractCacheLoader |
---|
containsKey |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.infinispan.loaders.CacheLoader |
---|
containsKey |
Constructor Detail |
---|
public JCacheLoaderAdapter()
Method Detail |
---|
public void setCacheLoader(javax.cache.CacheLoader<K,V> delegate)
public InternalCacheEntry load(Object key) throws CacheLoaderException
CacheLoader
key
- key
CacheLoaderException
- in the event of problems reading from sourcepublic Set<InternalCacheEntry> loadAll() throws CacheLoaderException
CacheLoader
CacheLoaderException
- in the event of problems reading from sourcepublic Set<InternalCacheEntry> load(int numEntries) throws CacheLoaderException
CacheLoader
numEntries
- maximum number of entries to load
CacheLoaderException
public Set<Object> loadAllKeys(Set<Object> keysToExclude) throws CacheLoaderException
CacheLoader
keysToExclude
- a set of keys to exclude. An empty set or null will indicate that all keys should be returned.
CacheLoaderException
public void start() throws CacheLoaderException
start
in interface CacheLoader
start
in class AbstractCacheStore
CacheLoaderException
public void stop() throws CacheLoaderException
stop
in interface CacheLoader
stop
in class AbstractCacheStore
CacheLoaderException
public Class<? extends CacheLoaderConfig> getConfigurationClass()
CacheLoader
CacheLoaderConfig
type. This is usually done by instantiating the CacheLoader
and then calling this method. This may result in 2 instances being created, however, since the instance
created to get a hold of the configuration type is then discarded and another instance is created for actual
use as a CacheLoader when the cache starts.
Since Infinispan 4.1, you can also annotate your CacheLoader implementation with CacheLoaderMetadata
and provide this information via the annotation, which will prevent unnecessary instances being created.
CacheLoaderConfig
bean used to configure this
implementation of CacheLoader
.public void toStream(ObjectOutput outputStream) throws CacheLoaderException
CacheStore
CacheStore.fromStream(java.io.ObjectInput)
.
While not a requirement, it is recommended that implementations make use of the StreamingMarshaller
when dealing with the stream to make use of efficient marshalling.
It is imperative that implementations do not flush or close the stream after finishing with it.
It is also recommended that implementations use their own start and end markers on the stream since
other processes may write additional data to the stream after the cache store has written to it. As such, either
markers or some other mechanism to prevent the store from reading too much information in CacheStore.fromStream(java.io.ObjectInput)
should be employed, to prevent data corruption.
It can be assumed that the stream passed in already performs buffering such that the cache store implementation
doesn't have to.
outputStream
- stream to write to
CacheLoaderException
- in the event of problems reading from the storepublic void store(InternalCacheEntry entry) throws CacheLoaderException
CacheStore
entry
- entry to store
CacheLoaderException
- in the event of problems writing to the storepublic void fromStream(ObjectInput inputStream) throws CacheLoaderException
CacheStore
CacheStore.toStream(java.io.ObjectOutput)
. While not a
requirement, it is recommended that implementations make use of the StreamingMarshaller
when dealing with the stream to make use of efficient marshalling.
It is imperative that implementations do not close the stream after finishing with it.
It is also recommended that implementations use their own start and end markers on the stream since
other processes may write additional data to the stream after the cache store has written to it. As such, either
markers or some other mechanism to prevent the store from reading too much information should be employed when
writing to the stream in CacheStore.fromStream(java.io.ObjectInput)
to prevent data corruption.
It can be assumed that the stream passed in already performs buffering such that the cache store implementation
doesn't have to.
inputStream
- stream to read from
CacheLoaderException
- in the event of problems writing to the storepublic void clear() throws CacheLoaderException
CacheStore
CacheLoaderException
- in the event of problems writing to the storepublic boolean remove(Object key) throws CacheLoaderException
CacheStore
key
- key to remove
CacheLoaderException
- in the event of problems writing to the storepublic void purgeExpired()
CacheStore
purgeExpired
in interface CacheStore
purgeExpired
in class AbstractCacheStore
public void commit(GlobalTransaction tx)
CacheStore
CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
. The implementation would
need to deal with this case accordingly. Typically, this would be a no-op, after ensuring any resources attached
to the transaction are cleared up.
Also note that this method may be invoked on a thread which is different from the CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
invocation. As such, ThreadLocal
s should not be relied upon to maintain transaction context.
commit
in interface CacheStore
commit
in class AbstractCacheStore
tx
- tx to commitpublic void rollback(GlobalTransaction tx)
CacheStore
CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
. The implementation would
need to deal with this case accordingly. Typically, this would be a no-op, after ensuring any resources attached
to the transaction are cleared up.
Also note that this method may be invoked on a thread which is different from the CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
invocation. As such, ThreadLocal
s should not be relied upon to maintain transaction context.
rollback
in interface CacheStore
rollback
in class AbstractCacheStore
tx
- tx to roll backpublic void prepare(List<? extends Modification> list, GlobalTransaction tx, boolean isOnePhase)
CacheStore
prepare
in interface CacheStore
prepare
in class AbstractCacheStore
list
- modifications to be appliedtx
- transaction identifierisOnePhase
- if true, there will not be a commit or rollback phase and changes should be flushed
immediatelyprotected void purgeInternal() throws CacheLoaderException
purgeInternal
in class AbstractCacheStore
CacheLoaderException
|
--> | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |