org.infinispan.loaders.jdbc.binary
Class JdbcBinaryCacheStore

java.lang.Object
  extended by org.infinispan.loaders.AbstractCacheLoader
      extended by org.infinispan.loaders.AbstractCacheStore
          extended by org.infinispan.loaders.LockSupportCacheStore
              extended by org.infinispan.loaders.bucket.BucketBasedCacheStore
                  extended by 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 coresponding to a bucket. This is in contrast to JdbcStringBasedCacheStore which stores each StoredEntry as an row in the database.

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 releated configurations are described in JdbcBinaryCacheStoreConfig.

Author:
Mircea.Markus@jboss.com
See Also:
JdbcBinaryCacheStoreConfig, JdbcStringBasedCacheStore

Field Summary
 
Fields inherited from class org.infinispan.loaders.AbstractCacheStore
marshaller
 
Constructor Summary
JdbcBinaryCacheStore()
           
 
Method Summary
protected  void clearLockSafe()
           
 void doConnectionFactoryInitialization(ConnectionFactory connectionFactory)
          Keeps a reference to the connection factory for further use.
protected  void fromStreamLockSafe(ObjectInput objectInput)
           
 Class<? extends CacheLoaderConfig> getConfigurationClass()
           
 ConnectionFactory getConnectionFactory()
           
 TableManipulation getTableManipulation()
           
 void init(CacheLoaderConfig config, Cache cache, Marshaller m)
          Used to initialize a cache loader.
protected  void insertBucket(Bucket bucket)
           
 Set<InternalCacheEntry> loadAllLockSafe()
           
protected  Bucket loadBucket(String keyHashCode)
          Loads the bucket from the store, base on the hashcode.
 void purgeInternal()
           
protected  void saveBucket(Bucket bucket)
          This method assumes that the bucket is already persisted in the database.
 void start()
           
 void stop()
           
protected  void toStreamLockSafe(ObjectOutput objectOutput)
           
 
Methods inherited from class org.infinispan.loaders.bucket.BucketBasedCacheStore
getLockFromKey, loadLockSafe, removeLockSafe, storeLockSafe
 
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, getMarshaller, prepare, purgeExpired, removeAll, rollback, safeClose, safeClose
 
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

JdbcBinaryCacheStore

public JdbcBinaryCacheStore()
Method Detail

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 bean
cache - 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
Specified by:
insertBucket in class BucketBasedCacheStore
Throws:
CacheLoaderException

saveBucket

protected void saveBucket(Bucket bucket)
                   throws CacheLoaderException
Description copied from class: BucketBasedCacheStore
This method assumes that the bucket is already persisted in the database.

Specified by:
saveBucket in class BucketBasedCacheStore
Throws:
CacheLoaderException - if the bucket is not already present, or something happens while persisting.

loadBucket

protected Bucket loadBucket(String keyHashCode)
                     throws CacheLoaderException
Description copied from class: BucketBasedCacheStore
Loads the bucket from the store, base on the hashcode.

Specified by:
loadBucket in class BucketBasedCacheStore
Throws:
CacheLoaderException

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
Overrides:
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()

Google Analytics

Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.