Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 83   Methods: 5
NCLOC: 54   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SerializableObjectHandler.java 50% 93.8% 100% 91.3%
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.impl;
 9   
 10    import java.util.HashMap;
 11    import java.util.Map;
 12   
 13    import org.apache.commons.logging.Log;
 14    import org.apache.commons.logging.LogFactory;
 15    import org.jboss.cache.Cache;
 16    import org.jboss.cache.CacheException;
 17    import org.jboss.cache.CacheSPI;
 18    import org.jboss.cache.Fqn;
 19   
 20    /**
 21    * Handle Serializable object cache management.
 22    *
 23    * @author Ben Wang
 24    * @version $Id: SerializableObjectHandler.java,v 1.4 2007/06/28 00:56:06 jgreene Exp $
 25    */
 26    class SerializableObjectHandler
 27    {
 28    private Cache<Object, Object> cache;
 29    private PojoCacheImpl pojoCache;
 30    private InternalHelper internal_;
 31    private final Log log_ = LogFactory.getLog(SerializableObjectHandler.class);
 32   
 33  499 public SerializableObjectHandler(PojoCacheImpl cache, InternalHelper internal)
 34    {
 35  499 pojoCache = cache;
 36  499 this.cache = pojoCache.getCache();
 37  499 internal_ = internal;
 38    }
 39   
 40  61 Object get(Fqn fqn, Class clazz, PojoInstance pojoInstance)
 41    throws CacheException
 42    {
 43  61 Object obj = internal_.get(fqn, InternalConstant.SERIALIZED);
 44  61 return obj;
 45    }
 46   
 47   
 48  3497 boolean put(Fqn fqn, Object obj)
 49    throws CacheException
 50    {
 51    // Note that JBoss Serialization can serialize any type now.
 52  3497 if (log_.isDebugEnabled())
 53    {
 54  0 log_.debug("put(): obj (" + obj.getClass() + ") is non-advisable but serialize it anyway. "
 55    + "Note that if it is non-serializable we require to use JBoss Serialization.");
 56    }
 57   
 58  3497 putIntoCache(fqn, obj);
 59  3497 return true;
 60    }
 61   
 62  3497 private void putIntoCache(Fqn fqn, Object obj)
 63    throws CacheException
 64    {
 65  3497 Map map = new HashMap();
 66   
 67    // Special optimization here.
 68  3497 PojoInstance pojoInstance = new PojoInstance();
 69  3497 pojoInstance.set(obj);
 70  3497 pojoInstance.setPojoClass(obj.getClass());
 71  3497 map.put(PojoInstance.KEY, pojoInstance);
 72    // Note that we will only have one key in this fqn.
 73  3497 map.put(InternalConstant.SERIALIZED, obj);
 74  3497 internal_.put(fqn, map);
 75    }
 76   
 77  3061 @SuppressWarnings({"CanBeStatic"})
 78    void remove()
 79    {
 80    // No need to do anything here since we will do clean up afterwards.
 81    }
 82   
 83    }