Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 74   Methods: 2
NCLOC: 41   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
StateTransferFactory.java 50% 84.6% 100% 78.9%
coverage coverage
 1    /*
 2    * JBoss, the OpenSource J2EE webOS
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7    package org.jboss.cache.statetransfer;
 8   
 9    import org.jboss.cache.CacheImpl;
 10    import org.jboss.cache.Fqn;
 11    import org.jboss.cache.Version;
 12   
 13    import java.io.IOException;
 14    import java.io.ObjectInputStream;
 15   
 16    /**
 17    * Factory class able to create {@link StateTransferGenerator} and
 18    * {@link StateTransferIntegrator} instances.
 19    *
 20    * @author <a href="brian.stansberry@jboss.com">Brian Stansberry</a>
 21    * @version $Revision: 1.14 $
 22    */
 23    public abstract class StateTransferFactory
 24    {
 25    private static final short RV_200 = Version.getVersionShort("2.0.0");
 26   
 27    /**
 28    * Gets the StateTransferGenerator able to handle the given cache instance.
 29    *
 30    * @param cache the cache
 31    * @return the {@link StateTransferGenerator}
 32    * @throws IllegalStateException if the cache's ReplicationVersion is < 2.0.0
 33    */
 34  728 public static StateTransferGenerator
 35    getStateTransferGenerator(CacheImpl cache)
 36    {
 37  728 short version = cache.getConfiguration().getReplicationVersion();
 38   
 39    // Compiler won't let me use a switch
 40   
 41  728 if (version < RV_200 && version > 0) // <= 0 is actually a version > 15.31.63
 42  0 throw new IllegalStateException("State transfer with cache replication version < 2.0.0 not supported");
 43    else
 44  728 return new DefaultStateTransferGenerator(cache); // current default
 45    }
 46   
 47  734 public static StateTransferIntegrator getStateTransferIntegrator(ObjectInputStream in, Fqn fqn, CacheImpl cache)
 48    throws Exception
 49    {
 50  734 short version = 0;
 51  734 try
 52    {
 53  734 version = (Short) cache.getMarshaller().objectFromObjectStream(in);
 54    }
 55    catch (IOException io)
 56    {
 57    // something is wrong with this stream, close it
 58  4 try
 59    {
 60  4 in.close();
 61    }
 62    catch (IOException ignored) {}
 63  4 throw new IllegalStateException("Stream corrupted ", io);
 64    }
 65   
 66    // Compiler won't let me use a switch
 67   
 68  730 if (version < RV_200 && version > 0) // <= 0 is actually a version > 15.31.63
 69  0 throw new IllegalStateException("State transfer with cache replication version < 2.0.0 not supported");
 70    else
 71  730 return new DefaultStateTransferIntegrator(fqn, cache); // current default
 72    }
 73   
 74    }