public abstract class CommandInterceptor extends AbstractVisitor
Visitor
interface allowing it to
intercept invocations on VisitableCommand
s.
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 CommandInterceptor.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
CommandInterceptor.handleDefault(InvocationContext, VisitableCommand)
and then write a series of if statements or a switch
block, if command-specific behaviour is needed.
VisitableCommand
,
Visitor
,
InterceptorChain
Modifier and Type | Field and Description |
---|---|
protected Configuration |
cacheConfiguration |
Constructor and Description |
---|
CommandInterceptor() |
Modifier and Type | Method and Description |
---|---|
protected long |
getLockAcquisitionTimeout(FlagAffectedCommand command,
boolean skipLocking) |
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() |
protected boolean |
hasSkipLocking(FlagAffectedCommand command) |
void |
injectConfiguration(Configuration configuration) |
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.
|
protected Configuration cacheConfiguration
protected Log getLog()
public void injectConfiguration(Configuration configuration)
public final CommandInterceptor getNext()
public final boolean hasNext()
public final void setNext(CommandInterceptor next)
next
- next interceptor in the chain.public final Object invokeNextInterceptor(InvocationContext ctx, VisitableCommand command)
ctx
- invocation contextcommand
- command to pass up the chain.Throwable
- in the event of problemsprotected Object handleDefault(InvocationContext ctx, VisitableCommand command)
handleDefault
in class AbstractVisitor
ctx
- invocation contextcommand
- command to invokeThrowable
- in the event of problemsprotected final long getLockAcquisitionTimeout(FlagAffectedCommand command, boolean skipLocking)
protected final boolean hasSkipLocking(FlagAffectedCommand command)
Copyright © 2015 JBoss, a division of Red Hat. All rights reserved.