|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.cache.commands.AbstractVisitor org.jboss.cache.interceptors.base.CommandInterceptor
public class CommandInterceptor
This is the base class for all interceptors to extend, and implements the Visitor
interface
allowing it to intercept invocations on VisitableCommand
s.
CacheInvocationDelegate
(for invocations on the Cache
public interface), the NodeInvocationDelegate
for invocations on the Node
public interface, or by the CommandAwareRpcDispatcher
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(org.jboss.cache.InvocationContext, org.jboss.cache.commands.read.GetKeyValueCommand)
)
or the more generic handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)
which is the default behaviour of
any visit method, as defined in AbstractVisitor.handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)
.
The preferred approach is to override the specific visitXXX() methods that are of interest rather than to override handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)
and then write a series of if statements or a switch block, if command-specific behaviour is needed.
VisitableCommand
,
Visitor
,
InterceptorChain
Field Summary | |
---|---|
protected Configuration |
configuration
|
protected org.apache.commons.logging.Log |
log
|
protected boolean |
trace
|
Constructor Summary | |
---|---|
CommandInterceptor()
|
Method Summary | |
---|---|
Map<String,Object> |
dumpStatistics()
Returns a map of statistics. |
CommandInterceptor |
getNext()
Retrieves the next interceptor in the chain. |
boolean |
getStatisticsEnabled()
Returns whether an interceptor's statistics are being captured. |
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 |
resetStatistics()
Resets statistics gathered. |
void |
setNext(CommandInterceptor next)
Sets the next interceptor in the chain to the interceptor passed in. |
void |
setStatisticsEnabled(boolean enabled)
Enables an interceptor's cache statistics If true, the interceptor will capture statistics and make them available through the mbean. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected org.apache.commons.logging.Log log
protected boolean trace
protected Configuration configuration
Constructor Detail |
---|
public CommandInterceptor()
Method Detail |
---|
public boolean getStatisticsEnabled()
InterceptorMBean
getStatisticsEnabled
in interface InterceptorMBean
public void setStatisticsEnabled(boolean enabled)
InterceptorMBean
setStatisticsEnabled
in interface InterceptorMBean
enabled
- whether gathering statistics for JMX are enabled.public Map<String,Object> dumpStatistics()
dumpStatistics
in interface InterceptorMBean
public void resetStatistics()
resetStatistics
in interface InterceptorMBean
public CommandInterceptor getNext()
public boolean hasNext()
public void setNext(CommandInterceptor next)
next
- next interceptor in the chain.public Object invokeNextInterceptor(InvocationContext ctx, VisitableCommand command) throws Throwable
super.invoke().
ctx
- invocation contextcommand
- command to pass up the chain.
Throwable
- in the event of problemsprotected Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
handleDefault
in class AbstractVisitor
ctx
- invocation contextcommand
- command to invoke
Throwable
- in the event of problems
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |