Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 106   Methods: 9
NCLOC: 70   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AbstractCollectionInterceptor.java 50% 64.7% 66.7% 62.5%
coverage coverage
 1    /*
 2    * JBoss, Home of Professional Open Source
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7   
 8    package org.jboss.cache.pojo.interceptors.dynamic;
 9   
 10    import org.jboss.aop.joinpoint.Invocation;
 11    import org.jboss.cache.Fqn;
 12    import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException;
 13    import org.jboss.cache.pojo.impl.PojoCacheImpl;
 14    import org.jboss.cache.pojo.impl.PojoInstance;
 15    import org.jboss.cache.pojo.util.ObjectUtil;
 16   
 17    /**
 18    * Abstract base class for collection interceptor.
 19    *
 20    * @author Ben Wang
 21    * @version $Id: AbstractCollectionInterceptor.java,v 1.4 2007/06/26 22:23:51 jgreene Exp $
 22    */
 23    @SuppressWarnings({"CanBeFinal"})
 24    public abstract class AbstractCollectionInterceptor implements BaseInterceptor
 25    {
 26    Fqn fqn;
 27    PojoCacheImpl cache;
 28   
 29    private boolean attached_ = true;
 30    private PojoInstance pojoInstance_;
 31   
 32  1748 AbstractCollectionInterceptor(PojoCacheImpl cache, Fqn fqn)
 33    {
 34  1748 this.fqn = fqn;
 35  1748 this.cache = cache;
 36    }
 37   
 38  20149 @SuppressWarnings({"CanBeFinal"})
 39    public Fqn getFqn()
 40    {
 41  20149 return fqn;
 42    }
 43   
 44  0 @SuppressWarnings({"CanBeFinal"})
 45    public void setFqn(Fqn fqn)
 46    {
 47  0 this.fqn = fqn;
 48    }
 49   
 50  0 @SuppressWarnings({"CanBeFinal"})
 51    public PojoInstance getAopInstance()
 52    {
 53  0 return pojoInstance_;
 54    }
 55   
 56  1672 public void setAopInstance(PojoInstance pojoInstance)
 57    {
 58  1672 this.pojoInstance_ = pojoInstance;
 59    }
 60   
 61    /**
 62    * Attaching the Collection to PojoCache.
 63    */
 64  0 public void attach(Fqn fqn, boolean copyToCache)
 65    {
 66    // This is a hook to allow re-attching the Collection without specifying the fqn.
 67  0 if (fqn != null)
 68    {
 69  0 setFqn(fqn);
 70    }
 71  0 attached_ = true;
 72    // Reattach anything in-memory to cache
 73    }
 74   
 75  1332 public void detach(boolean removeFromCache)
 76    {
 77  1332 attached_ = false;
 78    // Detach by tranferring the cache content to in-memory copy
 79    }
 80   
 81  5116 public boolean isAttached()
 82    {
 83  5116 return attached_;
 84    }
 85   
 86    // Verify an attached collection is truly attached
 87  5116 public void verifyAttached(Object target)
 88    {
 89    // If locally detached, we use the local in-memory copy
 90  5116 if (! isAttached())
 91  0 return;
 92   
 93  5116 if (cache.getCache().get(fqn, PojoInstance.KEY) != null)
 94  5115 return;
 95   
 96  1 String identity = ObjectUtil.identityString(target);
 97  1 throw new PojoCacheAlreadyDetachedException(identity + " has possibly been detached remotely. Internal id: " + fqn);
 98    }
 99   
 100    abstract void setInMemoryCopy(Object obj);
 101    abstract Object getInMemoryCopy();
 102    abstract void setCacheCopy(Object obj);
 103    abstract Object getCacheCopy();
 104    abstract void setCurrentCopy(Object obj);
 105    public abstract Object getCurrentCopy();
 106    }