org.infinispan.loader
Class AbstractCacheStore

java.lang.Object
  extended by org.infinispan.loader.AbstractCacheLoader
      extended by org.infinispan.loader.AbstractCacheStore
All Implemented Interfaces:
CacheLoader, CacheStore
Direct Known Subclasses:
BdbjeCacheStore, JdbcMixedCacheStore, LockSupportCacheStore

public abstract class AbstractCacheStore
extends AbstractCacheLoader
implements CacheStore

An abstract CacheStore that holds common implementations for some methods

Since:
4.0
Author:
Manik Surtani

Constructor Summary
AbstractCacheStore()
           
 
Method Summary
protected  void applyModifications(List<? extends Modification> mods)
           
 void commit(Transaction tx)
          Commits a transaction that has been previously prepared.
protected  Marshaller getMarshaller()
           
 void init(CacheLoaderConfig config, Cache cache, Marshaller m)
          Used to initialize a cache loader.
 void prepare(List<? extends Modification> mods, Transaction 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()
           
 void removeAll(Set<Object> keys)
          Bulk remove operation
 void rollback(Transaction 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, javax.transaction.Transaction, boolean).

protected  void safeClose(InputStream stream)
           
protected  void safeClose(OutputStream stream)
           
 void start()
           
 void stop()
           
 
Methods inherited from class org.infinispan.loader.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.loader.CacheStore
clear, fromStream, remove, store, toStream
 
Methods inherited from interface org.infinispan.loader.CacheLoader
containsKey, getConfigurationClass, load, loadAll
 

Constructor Detail

AbstractCacheStore

public AbstractCacheStore()
Method Detail

init

public void init(CacheLoaderConfig config,
                 Cache cache,
                 Marshaller m)
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
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.

start

public void start()
           throws CacheLoaderException
Specified by:
start in interface CacheLoader
Throws:
CacheLoaderException

stop

public void stop()
          throws CacheLoaderException
Specified by:
stop in interface CacheLoader
Throws:
CacheLoaderException

purgeExpired

public void purgeExpired()
                  throws CacheLoaderException
Description copied from interface: CacheStore
Purges expired entries from the store.

Specified by:
purgeExpired in interface CacheStore
Throws:
CacheLoaderException - in the event of problems writing to the store

purgeInternal

protected void purgeInternal()
                      throws CacheLoaderException
Throws:
CacheLoaderException

applyModifications

protected void applyModifications(List<? extends Modification> mods)
                           throws CacheLoaderException
Throws:
CacheLoaderException

prepare

public void prepare(List<? extends Modification> mods,
                    Transaction tx,
                    boolean isOnePhase)
             throws CacheLoaderException
Description copied from interface: CacheStore
Issues a prepare call with a set of modifications to be applied to the cache store

Specified by:
prepare in interface CacheStore
Parameters:
mods - modifications to be applied
tx - transaction identifier
isOnePhase - if true, there will not be a commit or rollback phase and changes should be flushed immediately
Throws:
CacheLoaderException - in the event of problems writing to the store

rollback

public void rollback(Transaction tx)
Description copied from interface: CacheStore
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, javax.transaction.Transaction, boolean). The implementation would need to deal with this case acordingly. 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, javax.transaction.Transaction, boolean) invocation. As such, ThreadLocals should not be relied upon to maintain transaction context.

Specified by:
rollback in interface CacheStore
Parameters:
tx - tx to roll back

commit

public void commit(Transaction tx)
            throws CacheLoaderException
Description copied from interface: CacheStore
Commits 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, javax.transaction.Transaction, boolean). The implementation would need to deal with this case acordingly. 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, javax.transaction.Transaction, boolean) invocation. As such, ThreadLocals should not be relied upon to maintain transaction context.

Specified by:
commit in interface CacheStore
Parameters:
tx - tx to commit
Throws:
CacheLoaderException - in the event of problems writing to the store

removeAll

public void removeAll(Set<Object> keys)
               throws CacheLoaderException
Description copied from interface: CacheStore
Bulk remove operation

Specified by:
removeAll in interface CacheStore
Parameters:
keys - to remove
Throws:
CacheLoaderException - in the event of problems writing to the store

safeClose

protected final void safeClose(InputStream stream)
                        throws CacheLoaderException
Throws:
CacheLoaderException

safeClose

protected final void safeClose(OutputStream stream)
                        throws CacheLoaderException
Throws:
CacheLoaderException

getMarshaller

protected Marshaller getMarshaller()


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