org.infinispan.interceptors.base
Class CommandInterceptor

java.lang.Object
  extended by org.infinispan.commands.AbstractVisitor
      extended by org.infinispan.interceptors.base.CommandInterceptor
All Implemented Interfaces:
Visitor
Direct Known Subclasses:
AbstractLockingInterceptor, BaseCustomInterceptor, BaseRpcInterceptor, BatchingInterceptor, CallInterceptor, DeadlockDetectingInterceptor, EntryWrappingInterceptor, InvocationContextInterceptor, IsMarshallableInterceptor, JmxStatsCommandInterceptor, MarshalledValueInterceptor, NotificationInterceptor, PrePostProcessingCommandInterceptor, QueryInterceptor, StateTransferLockInterceptor, TxInterceptor

public abstract class CommandInterceptor
extends AbstractVisitor

This is the base class for all interceptors to extend, and implements the Visitor interface allowing it to intercept invocations on VisitableCommands.

Commands are either created by the CacheImpl (for invocations on the Cache public interface), or by the InboundInvocationHandler for remotely originating invocations, and are passed up the interceptor chain by using the InterceptorChain helper class.

When writing interceptors, authors can either override a specific visitXXX() method (such as AbstractVisitor.visitGetKeyValueCommand(InvocationContext, GetKeyValueCommand)) or the more generic handleDefault(InvocationContext, VisitableCommand) which is the default behaviour of any visit method, as defined in AbstractVisitor.handleDefault(InvocationContext, VisitableCommand).

The preferred approach is to override the specific visitXXX() methods that are of interest rather than to override handleDefault(InvocationContext, VisitableCommand) and then write a series of if statements or a switch block, if command-specific behaviour is needed.

Since:
4.0
Author:
Mircea.Markus@jboss.com
See Also:
VisitableCommand, Visitor, InterceptorChain

Field Summary
protected  Configuration configuration
           
 
Constructor Summary
CommandInterceptor()
           
 
Method Summary
protected  Log getLog()
           
 CommandInterceptor getNext()
          Retrieves the next interceptor in the chain.
protected  Object handleDefault(InvocationContext ctx, VisitableCommand command)
          The default behaviour of the visitXXX methods, which is to ignore the call and pass the call up to the next interceptor in the chain.
 boolean hasNext()
           
 Object invokeNextInterceptor(InvocationContext ctx, VisitableCommand command)
          Invokes the next interceptor in the chain.
 void setNext(CommandInterceptor next)
          Sets the next interceptor in the chain to the interceptor passed in.
 
Methods inherited from class org.infinispan.commands.AbstractVisitor
visitApplyDeltaCommand, visitClearCommand, visitCollection, visitCommitCommand, visitDistributedExecuteCommand, visitEntrySetCommand, visitEvictCommand, visitGetKeyValueCommand, visitInvalidateCommand, visitInvalidateL1Command, visitKeySetCommand, visitLockControlCommand, visitPrepareCommand, visitPutKeyValueCommand, visitPutMapCommand, visitRemoveCommand, visitReplaceCommand, visitRollbackCommand, visitSizeCommand, visitUnknownCommand, visitValuesCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configuration

protected Configuration configuration
Constructor Detail

CommandInterceptor

public CommandInterceptor()
Method Detail

getLog

protected Log getLog()

getNext

public final CommandInterceptor getNext()
Retrieves the next interceptor in the chain.

Returns:
the next interceptor in the chain.

hasNext

public final boolean hasNext()
Returns:
true if there is another interceptor in the chain after this; false otherwise.

setNext

public final void setNext(CommandInterceptor next)
Sets the next interceptor in the chain to the interceptor passed in.

Parameters:
next - next interceptor in the chain.

invokeNextInterceptor

public final Object invokeNextInterceptor(InvocationContext ctx,
                                          VisitableCommand command)
                                   throws Throwable
Invokes the next interceptor in the chain. This is how interceptor implementations should pass a call up the chain to the next interceptor.

Parameters:
ctx - invocation context
command - command to pass up the chain.
Returns:
return value of the invocation
Throws:
Throwable - in the event of problems

handleDefault

protected Object handleDefault(InvocationContext ctx,
                               VisitableCommand command)
                        throws Throwable
The default behaviour of the visitXXX methods, which is to ignore the call and pass the call up to the next interceptor in the chain.

Overrides:
handleDefault in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to invoke
Returns:
return value
Throws:
Throwable - in the event of problems

-->

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