org.jboss.cache.interceptors
Class CacheStoreInterceptor

java.lang.Object
  extended by org.jboss.cache.commands.AbstractVisitor
      extended by org.jboss.cache.interceptors.base.CommandInterceptor
          extended by org.jboss.cache.interceptors.base.SkipCheckChainedInterceptor
              extended by org.jboss.cache.interceptors.CacheStoreInterceptor
All Implemented Interfaces:
Visitor, CacheStoreInterceptorMBean, InterceptorMBean

public class CacheStoreInterceptor
extends SkipCheckChainedInterceptor
implements CacheStoreInterceptorMBean

Writes modifications back to the store on the way out: stores modifications back through the CacheLoader, either after each method call (no TXs), or at TX commit.

Version:
$Id: CacheStoreInterceptor.java 5881 2008-05-21 16:12:49Z mircea.markus $
Author:
Bela Ban

Nested Class Summary
static class CacheStoreInterceptor.StoreModificationsBuilder
           
 
Field Summary
 
Fields inherited from class org.jboss.cache.interceptors.base.CommandInterceptor
configuration, log, trace
 
Constructor Summary
CacheStoreInterceptor()
           
 
Method Summary
 Map<String,Object> dumpStatistics()
          Returns a map of statistics.
 long getCacheLoaderStores()
          Returns the number of cache loader stores
protected  Object handleCommitCommand(InvocationContext ctx, CommitCommand command)
           
protected  Object handleMoveCommand(InvocationContext ctx, MoveCommand command)
           
protected  Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command)
           
protected  Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command)
           
protected  Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command)
           
protected  Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command)
           
protected  Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
           
protected  Object handleRemoveDataCommand(InvocationContext ctx, ClearDataCommand command)
           
protected  Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command)
           
protected  Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command)
          remove() methods need to be applied to the CacheLoader before passing up the call: a listener might access an element just removed, causing the CacheLoader to *load* the element before *removing* it.
protected  Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command)
           
protected  void init(DataContainerImpl dataContainer, CacheLoaderManager loaderManager, TransactionManager txManager, CacheLoaderConfig clConfig)
           
 void resetStatistics()
          Resets statistics gathered.
 boolean skipInterception(InvocationContext ctx, VisitableCommand command)
          if this is a shared cache loader and the call is of remote origin, pass up the chain
protected  void start()
           
 
Methods inherited from class org.jboss.cache.interceptors.base.SkipCheckChainedInterceptor
handleAll, handleDefault, handleEvictFqnCommand, handleExistsNodeCommand, handleGetChildrenNamesCommand, handleGetDataMapCommand, handleGetKeysCommand, handleGetKeyValueCommand, handleGetNodeCommand, handleGravitateDataCommand, handleInvalidateCommand, visitClearDataCommand, visitCommitCommand, visitEvictFqnCommand, visitExistsNodeCommand, visitGetChildrenNamesCommand, visitGetDataMapCommand, visitGetKeysCommand, visitGetKeyValueCommand, visitGetNodeCommand, visitGravitateDataCommand, visitInvalidateCommand, visitMoveCommand, visitOptimisticPrepareCommand, visitPrepareCommand, visitPutDataMapCommand, visitPutForExternalReadCommand, visitPutKeyValueCommand, visitRemoveKeyCommand, visitRemoveNodeCommand, visitRollbackCommand
 
Methods inherited from class org.jboss.cache.interceptors.base.CommandInterceptor
getNext, getStatisticsEnabled, hasNext, invokeNextInterceptor, setNext, setStatisticsEnabled
 
Methods inherited from class org.jboss.cache.commands.AbstractVisitor
visitCollection, visitCreateNodeCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.cache.interceptors.InterceptorMBean
getStatisticsEnabled, setStatisticsEnabled
 

Constructor Detail

CacheStoreInterceptor

public CacheStoreInterceptor()
Method Detail

init

protected void init(DataContainerImpl dataContainer,
                    CacheLoaderManager loaderManager,
                    TransactionManager txManager,
                    CacheLoaderConfig clConfig)

start

protected void start()

skipInterception

public boolean skipInterception(InvocationContext ctx,
                                VisitableCommand command)
if this is a shared cache loader and the call is of remote origin, pass up the chain

Specified by:
skipInterception in class SkipCheckChainedInterceptor
Parameters:
ctx - invocation context
command - command
Returns:
true if the invocation should skip the current interceptor and move on to the next in the chain, false otherwise.

handleCommitCommand

protected Object handleCommitCommand(InvocationContext ctx,
                                     CommitCommand command)
                              throws Throwable
Overrides:
handleCommitCommand in class SkipCheckChainedInterceptor
Throws:
Throwable

handleRollbackCommand

protected Object handleRollbackCommand(InvocationContext ctx,
                                       RollbackCommand command)
                                throws Throwable
Overrides:
handleRollbackCommand in class SkipCheckChainedInterceptor
Throws:
Throwable

handleOptimisticPrepareCommand

protected Object handleOptimisticPrepareCommand(InvocationContext ctx,
                                                OptimisticPrepareCommand command)
                                         throws Throwable
Overrides:
handleOptimisticPrepareCommand in class SkipCheckChainedInterceptor
Throws:
Throwable

handlePrepareCommand

protected Object handlePrepareCommand(InvocationContext ctx,
                                      PrepareCommand command)
                               throws Throwable
Overrides:
handlePrepareCommand in class SkipCheckChainedInterceptor
Throws:
Throwable

handleRemoveNodeCommand

protected Object handleRemoveNodeCommand(InvocationContext ctx,
                                         RemoveNodeCommand command)
                                  throws Throwable
remove() methods need to be applied to the CacheLoader before passing up the call: a listener might access an element just removed, causing the CacheLoader to *load* the element before *removing* it.

Overrides:
handleRemoveNodeCommand in class SkipCheckChainedInterceptor
Throws:
Throwable

handleRemoveKeyCommand

protected Object handleRemoveKeyCommand(InvocationContext ctx,
                                        RemoveKeyCommand command)
                                 throws Throwable
Overrides:
handleRemoveKeyCommand in class SkipCheckChainedInterceptor
Throws:
Throwable

handleRemoveDataCommand

protected Object handleRemoveDataCommand(InvocationContext ctx,
                                         ClearDataCommand command)
                                  throws Throwable
Overrides:
handleRemoveDataCommand in class SkipCheckChainedInterceptor
Throws:
Throwable

handleMoveCommand

protected Object handleMoveCommand(InvocationContext ctx,
                                   MoveCommand command)
                            throws Throwable
Overrides:
handleMoveCommand in class SkipCheckChainedInterceptor
Throws:
Throwable

handlePutDataMapCommand

protected Object handlePutDataMapCommand(InvocationContext ctx,
                                         PutDataMapCommand command)
                                  throws Throwable
Overrides:
handlePutDataMapCommand in class SkipCheckChainedInterceptor
Throws:
Throwable

handlePutKeyValueCommand

protected Object handlePutKeyValueCommand(InvocationContext ctx,
                                          PutKeyValueCommand command)
                                   throws Throwable
Overrides:
handlePutKeyValueCommand in class SkipCheckChainedInterceptor
Throws:
Throwable

handlePutForExternalReadCommand

protected Object handlePutForExternalReadCommand(InvocationContext ctx,
                                                 PutForExternalReadCommand command)
                                          throws Throwable
Overrides:
handlePutForExternalReadCommand in class SkipCheckChainedInterceptor
Throws:
Throwable

getCacheLoaderStores

public long getCacheLoaderStores()
Description copied from interface: CacheStoreInterceptorMBean
Returns the number of cache loader stores

Specified by:
getCacheLoaderStores in interface CacheStoreInterceptorMBean
Returns:
the number of cache loader stores

resetStatistics

public void resetStatistics()
Description copied from class: CommandInterceptor
Resets statistics gathered. Is a no-op, and should be overridden if it is to be meaningful.

Specified by:
resetStatistics in interface InterceptorMBean
Overrides:
resetStatistics in class CommandInterceptor

dumpStatistics

public Map<String,Object> dumpStatistics()
Description copied from class: CommandInterceptor
Returns a map of statistics. This is a default implementation which returns an empty map and should be overridden if it is to be meaningful.

Specified by:
dumpStatistics in interface InterceptorMBean
Overrides:
dumpStatistics in class CommandInterceptor
Returns:
an empty map


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