org.infinispan.interceptors.base
Class CommandInterceptor
java.lang.Object
org.infinispan.commands.AbstractVisitor
org.infinispan.interceptors.base.CommandInterceptor
- All Implemented Interfaces:
- Visitor
- Direct Known Subclasses:
- BaseRpcInterceptor, BatchingInterceptor, CallInterceptor, DeadlockDetectingInterceptor, ImplicitEagerLockingInterceptor, InvocationContextInterceptor, JmxStatsCommandInterceptor, LockingInterceptor, MarshalledValueInterceptor, NotificationInterceptor, PrePostProcessingCommandInterceptor, QueryInterceptor, 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 VisitableCommand
s.
Commands are either created by the CacheDelegate
(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
Methods inherited from class org.infinispan.commands.AbstractVisitor |
visitClearCommand, visitCollection, visitCommitCommand, visitEntrySetCommand, visitEvictCommand, visitGetKeyValueCommand, visitInvalidateCommand, visitKeySetCommand, visitLockControlCommand, visitPrepareCommand, visitPutKeyValueCommand, visitPutMapCommand, visitRemoveCommand, visitReplaceCommand, visitRollbackCommand, visitSizeCommand, visitValuesCommand |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
protected Log log
trace
protected boolean trace
configuration
protected Configuration configuration
CommandInterceptor
public CommandInterceptor()
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 contextcommand
- 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 contextcommand
- command to invoke
- Returns:
- return value
- Throws:
Throwable
- in the event of problems
Copyright © 2010 JBoss, a division of Red Hat. All Rights Reserved.