Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 115   Methods: 3
NCLOC: 83   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CallInterceptor.java 72.7% 83.3% 100% 80%
coverage coverage
 1    package org.jboss.cache.interceptors;
 2   
 3    import org.jboss.cache.CacheImpl;
 4    import org.jboss.cache.CacheSPI;
 5    import org.jboss.cache.InvocationContext;
 6    import org.jboss.cache.config.Option;
 7    import org.jboss.cache.marshall.MethodCall;
 8    import org.jboss.cache.marshall.MethodDeclarations;
 9    import org.jboss.cache.transaction.GlobalTransaction;
 10   
 11    import javax.transaction.Transaction;
 12   
 13    /**
 14    * Always at the end of the chain, directly in front of the cache. Simply calls into the cache using reflection.
 15    * If the call resulted in a modification, add the Modification to the end of the modification list
 16    * keyed by the current transaction.
 17    * <p/>
 18    * Although always added to the end of an optimistically locked chain as well, calls should not make it down to
 19    * this interceptor unless it is a call the OptimisticNodeInterceptor knows nothing about.
 20    *
 21    * @author Bela Ban
 22    * @version $Id: CallInterceptor.java,v 1.18 2007/05/23 15:22:03 msurtani Exp $
 23    */
 24    public class CallInterceptor extends Interceptor
 25    {
 26    private CacheImpl cache;
 27   
 28  5678 public void setCache(CacheSPI cache)
 29    {
 30  5678 super.setCache(cache);
 31    }
 32   
 33  2854 public void setTreeCacheInstance(CacheImpl c)
 34    {
 35  2854 cache = c;
 36    }
 37   
 38  1566988 public Object invoke(InvocationContext ctx) throws Throwable
 39    {
 40  1566992 MethodCall m = ctx.getMethodCall();
 41  1566992 Object retval = null;
 42   
 43  1566992 if (!MethodDeclarations.isTransactionLifecycleMethod(m.getMethodId()))
 44    {
 45  0 if (log.isTraceEnabled()) log.trace("Passing up method " + m + " so it gets invoked on cache.");
 46  1430741 try
 47    {
 48    //retval = super.invoke(m);
 49  1430741 retval = m.invoke(cache);
 50    }
 51    catch (Throwable t)
 52    {
 53  4 retval = t;
 54    }
 55    }
 56    else
 57    {
 58  0 if (log.isTraceEnabled()) log.trace("Suppressing invocation of method " + m + " on cache.");
 59    }
 60   
 61  1566992 Transaction tx = ctx.getTransaction();
 62  1566992 if (tx != null && isValid(tx))
 63    {
 64    // test for exceptions.
 65  418575 if (retval instanceof Throwable)
 66    {
 67  0 tx.setRollbackOnly(); // no exception, regular return
 68    }
 69    else
 70    {
 71    // only add the modification to the modification list if we are using pessimistic locking.
 72    // Optimistic locking calls *should* not make it this far down the interceptor chain, but just
 73    // in case a method has been invoked that the OptimisticNodeInterceptor knows nothing about, it will
 74    // filter down here.
 75   
 76  418575 if (!configuration.isNodeLockingOptimistic() && MethodDeclarations.isCrudMethod(m.getMethodId()))
 77    {
 78    // if method is a CRUD (Create/Remove/Update/Delete) method: add it to the modification
 79    // list, otherwise skip (e.g. get() is not added)
 80    // add the modification to the TX's modification list. this is used to later
 81    // (on TX commit) send all modifications done in this TX to all members
 82  166191 GlobalTransaction gtx = ctx.getGlobalTransaction();
 83  166191 if (gtx == null)
 84    {
 85  0 if (log.isDebugEnabled())
 86    {
 87  0 log.debug("didn't find GlobalTransaction for " + tx + "; won't add modification to transaction list");
 88    }
 89    }
 90    else
 91    {
 92  166191 Option o = ctx.getOptionOverrides();
 93  166191 if (o != null && o.isCacheModeLocal())
 94    {
 95  17 log.debug("Not adding method to modification list since cache mode local is set.");
 96    }
 97    else
 98    {
 99  166174 cache.getTransactionTable().addModification(gtx, m);
 100    }
 101  166191 if (cache.getCacheLoaderManager() != null)
 102  40973 cache.getTransactionTable().addCacheLoaderModification(gtx, m);
 103    }
 104    }
 105    }
 106    }
 107   
 108  1566988 if (retval instanceof Throwable)
 109    {
 110  4 throw (Throwable) retval;
 111    }
 112   
 113  1566988 return retval;
 114    }
 115    }