org.jboss.cache.interceptors
Class Interceptor

java.lang.Object
  extended by org.jboss.cache.interceptors.Interceptor
All Implemented Interfaces:
InterceptorMBean
Direct Known Subclasses:
CallInterceptor, MarshalledValueInterceptor, MethodDispacherInterceptor, UnlockInterceptor

public abstract class Interceptor
extends Object
implements InterceptorMBean

Class representing an interceptor.

Version:
$Id: Interceptor.java 5306 2008-02-06 01:19:52Z manik.surtani@jboss.com $
Author:
Bela Ban

Field Summary
protected  CacheSPI<?,?> cache
           
protected  Configuration configuration
           
protected  Interceptor last
           
protected  org.apache.commons.logging.Log log
           
protected  Interceptor next
           
protected  boolean trace
           
 
Constructor Summary
Interceptor()
           
 
Method Summary
protected  void assertTransactionValid(InvocationContext ctx)
          Tests whether the caller is in a valid transaction.
 Map<String,Object> dumpStatistics()
          This implementation returns an empty Map.
 Interceptor getLast()
           
 Interceptor getNext()
           
 boolean getStatisticsEnabled()
          Returns whether an interceptor's statistics are being captured.
protected  void initLogger()
           
 Object invoke(InvocationContext ctx)
          Using this method call for forwarding a call in the chain is not redable and error prone in the case of interceptors extending other interceptors.
protected  boolean isActive(Transaction tx)
          Returns true if transaction is ACTIVE, false otherwise
protected  boolean isPreparing(Transaction tx)
          Returns true if transaction is PREPARING, false otherwise
protected  boolean isValid(Transaction tx)
          Return s true of tx's status is ACTIVE or PREPARING
 Object nextInterceptor(InvocationContext ctx)
          Forwards the call to the nextInterceptor interceptor in the chain.
 NodeSPI peekNode(InvocationContext ctx, Fqn f, boolean forceRefresh, boolean includeDeletedNodes, boolean includeInvalidNodes)
          First checks the invocation context for previously obtained reference to a node, if this doesn't exist, performs a cache.peek() and holds on to the node reference.
 void resetStatistics()
          This implementation is a no-op.
 void setCache(CacheSPI cache)
           
 void setLast(Interceptor last)
           
 void setNext(Interceptor i)
           
 void setStatisticsEnabled(boolean enabled)
          Enables an interceptor's cache statistics If true, the interceptor will capture statistics and make them available through the mbean.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

next

protected Interceptor next

last

protected Interceptor last

cache

protected CacheSPI<?,?> cache

log

protected org.apache.commons.logging.Log log

configuration

protected Configuration configuration

trace

protected boolean trace
Constructor Detail

Interceptor

public Interceptor()
Method Detail

initLogger

protected void initLogger()

setNext

public void setNext(Interceptor i)

getNext

public Interceptor getNext()

setCache

public void setCache(CacheSPI cache)

invoke

public Object invoke(InvocationContext ctx)
              throws Throwable
Using this method call for forwarding a call in the chain is not redable and error prone in the case of interceptors extending other interceptors. This metod rather refers to interceptor doing its business operations rather than delegating to the nextInterceptor interceptor in chain. For delegation please use nextInterceptor(org.jboss.cache.InvocationContext)

Throws:
Throwable

nextInterceptor

public Object nextInterceptor(InvocationContext ctx)
                       throws Throwable
Forwards the call to the nextInterceptor interceptor in the chain.

Throws:
Throwable

getStatisticsEnabled

public boolean getStatisticsEnabled()
Description copied from interface: InterceptorMBean
Returns whether an interceptor's statistics are being captured.

Specified by:
getStatisticsEnabled in interface InterceptorMBean
Returns:
true if statistics are captured

setStatisticsEnabled

public void setStatisticsEnabled(boolean enabled)
Description copied from interface: InterceptorMBean
Enables an interceptor's cache statistics If true, the interceptor will capture statistics and make them available through the mbean.

Specified by:
setStatisticsEnabled in interface InterceptorMBean
Parameters:
enabled - true if statistics should be captured

getLast

public Interceptor getLast()

setLast

public void setLast(Interceptor last)

dumpStatistics

public Map<String,Object> dumpStatistics()
This implementation returns an empty Map. If individual Interceptors wish to expose statistics, they can override this method.

Specified by:
dumpStatistics in interface InterceptorMBean
Returns:
a map containing statistics

resetStatistics

public void resetStatistics()
This implementation is a no-op. If individual Interceptors wish to expose statistics, they can override this method.

Specified by:
resetStatistics in interface InterceptorMBean

isActive

protected boolean isActive(Transaction tx)
Returns true if transaction is ACTIVE, false otherwise


isPreparing

protected boolean isPreparing(Transaction tx)
Returns true if transaction is PREPARING, false otherwise


isValid

protected boolean isValid(Transaction tx)
Return s true of tx's status is ACTIVE or PREPARING

Parameters:
tx -
Returns:
true if the tx is active or preparing

assertTransactionValid

protected void assertTransactionValid(InvocationContext ctx)
Tests whether the caller is in a valid transaction. If not, will throw a CacheException.


toString

public String toString()
Overrides:
toString in class Object

peekNode

public NodeSPI peekNode(InvocationContext ctx,
                        Fqn f,
                        boolean forceRefresh,
                        boolean includeDeletedNodes,
                        boolean includeInvalidNodes)
First checks the invocation context for previously obtained reference to a node, if this doesn't exist, performs a cache.peek() and holds on to the node reference.

Parameters:
ctx - invocation context
f - fqn to find
forceRefresh - forces calling cache.peek() even if we hold a reference to the relevant node.
includeDeletedNodes - includes nodes marked for deletion if this is true
includeInvalidNodes - includes nodes marked as invalid if this is true
Returns:
a node, or null if one cannot be found.
Since:
2.1.0


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