org.infinispan.loaders.jdbc.binary
Class JdbcBinaryCacheStore
java.lang.Object
org.infinispan.loaders.AbstractCacheLoader
org.infinispan.loaders.AbstractCacheStore
org.infinispan.loaders.LockSupportCacheStore
org.infinispan.loaders.bucket.BucketBasedCacheStore
org.infinispan.loaders.jdbc.binary.JdbcBinaryCacheStore
- All Implemented Interfaces:
- CacheLoader, CacheStore
public class JdbcBinaryCacheStore
- extends BucketBasedCacheStore
BucketBasedCacheStore
implementation that will store all the buckets as rows in database, each row
corresponding to a bucket. This is in contrast to JdbcStringBasedCacheStore
which stores each StoredEntry as a row in the database.
It is generally recommended to use JdbcStringBasedCacheStore
whenever
possible as it performs better. Please read JdbcStringBasedCacheStore
's
javadoc for more details on this.
This class has the benefit of being able to store StoredEntries that do not have String keys, at the cost of coarser
grained access granularity, and inherently performance.
All the DB related configurations are described in JdbcBinaryCacheStoreConfig
.
- Author:
- Mircea.Markus@jboss.com
- See Also:
JdbcBinaryCacheStoreConfig
,
JdbcStringBasedCacheStore
Methods inherited from class org.infinispan.loaders.LockSupportCacheStore |
acquireGlobalLock, clear, fromStream, getTotalLockCount, immediateLockForWriting, load, loadAll, lockForReading, lockForWriting, releaseGlobalLock, remove, store, toStream, unlock |
Methods inherited from class org.infinispan.loaders.AbstractCacheStore |
applyModifications, commit, getCacheStoreConfig, getConcurrencyLevel, getMarshaller, prepare, purgeExpired, removeAll, rollback, safeClose, safeClose, supportsMultiThreadedPurge |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JdbcBinaryCacheStore
public JdbcBinaryCacheStore()
init
public void init(CacheLoaderConfig config,
Cache cache,
Marshaller m)
throws CacheLoaderException
- Description copied from interface:
CacheLoader
- Used to initialize a cache loader. Typically invoked by the
CacheLoaderManager
when setting up cache loaders.
- Specified by:
init
in interface CacheLoader
- Overrides:
init
in class LockSupportCacheStore
- Parameters:
config
- the cache loader configuration beancache
- cache associated with this cache loader. Implementations may use this to determine cache name when
selecting where refer to state in storage, for example, a different database table name.m
- marshaller to use when loading state from a stream, if supported by the implementation.
- Throws:
CacheLoaderException
start
public void start()
throws CacheLoaderException
- Specified by:
start
in interface CacheLoader
- Overrides:
start
in class LockSupportCacheStore
- Throws:
CacheLoaderException
stop
public void stop()
throws CacheLoaderException
- Specified by:
stop
in interface CacheLoader
- Overrides:
stop
in class AbstractCacheStore
- Throws:
CacheLoaderException
insertBucket
protected void insertBucket(Bucket bucket)
throws CacheLoaderException
- Description copied from class:
BucketBasedCacheStore
- Inserts a new Bucket in the storage system. If the bucket already exists, this method should simply update the
store with the contents of the bucket - i.e., behave the same as
BucketBasedCacheStore.updateBucket(Bucket)
.
- Specified by:
insertBucket
in class BucketBasedCacheStore
- Parameters:
bucket
- bucket to insert
- Throws:
CacheLoaderException
- in case of problems with the store.
updateBucket
protected void updateBucket(Bucket bucket)
throws CacheLoaderException
- Description copied from class:
BucketBasedCacheStore
- Updates a bucket in the store with the Bucket passed in to the method. This method assumes that the bucket
already exists in the store.
- Specified by:
updateBucket
in class BucketBasedCacheStore
- Parameters:
bucket
- bucket to update.
- Throws:
CacheLoaderException
- in case of problems with the store.
loadBucket
protected Bucket loadBucket(String keyHashCode)
throws CacheLoaderException
- Description copied from class:
BucketBasedCacheStore
- Loads a Bucket from the store, based on the hash code of the bucket.
- Specified by:
loadBucket
in class BucketBasedCacheStore
- Parameters:
keyHashCode
- String representation of the Bucket's hash
- Returns:
- a Bucket if one exists, null otherwise.
- Throws:
CacheLoaderException
- in case of problems with the store.
loadAllLockSafe
public Set<InternalCacheEntry> loadAllLockSafe()
throws CacheLoaderException
- Specified by:
loadAllLockSafe
in class LockSupportCacheStore
- Throws:
CacheLoaderException
fromStreamLockSafe
protected void fromStreamLockSafe(ObjectInput objectInput)
throws CacheLoaderException
- Specified by:
fromStreamLockSafe
in class LockSupportCacheStore
- Throws:
CacheLoaderException
toStreamLockSafe
protected void toStreamLockSafe(ObjectOutput objectOutput)
throws CacheLoaderException
- Specified by:
toStreamLockSafe
in class LockSupportCacheStore
- Throws:
CacheLoaderException
clearLockSafe
protected void clearLockSafe()
throws CacheLoaderException
- Specified by:
clearLockSafe
in class LockSupportCacheStore
- Throws:
CacheLoaderException
purgeInternal
public void purgeInternal()
throws CacheLoaderException
- Specified by:
purgeInternal
in class AbstractCacheStore
- Throws:
CacheLoaderException
getConfigurationClass
public Class<? extends CacheLoaderConfig> getConfigurationClass()
- Returns:
- the type of the
CacheLoaderConfig
bean used to configure this
implementation of CacheLoader
getConnectionFactory
public ConnectionFactory getConnectionFactory()
doConnectionFactoryInitialization
public void doConnectionFactoryInitialization(ConnectionFactory connectionFactory)
throws CacheLoaderException
- Keeps a reference to the connection factory for further use. Also initializes the
TableManipulation
that needs connections. This method should be called when you don't
want the store to manage the connection factory, perhaps because it is using an shared connection factory: see
JdbcMixedCacheStore
for such an example of this.
- Throws:
CacheLoaderException
getTableManipulation
public TableManipulation getTableManipulation()
Copyright © 2010 JBoss, a division of Red Hat. All Rights Reserved.