1 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 23 public abstract class StateTransferFactory 24 { 25 private static final short RV_200 = Version.getVersionShort("2.0.0"); 26 27 34 public static StateTransferGenerator 35 getStateTransferGenerator(CacheImpl cache) 36 { 37 short version = cache.getConfiguration().getReplicationVersion(); 38 39 41 if (version < RV_200 && version > 0) throw new IllegalStateException ("State transfer with cache replication version < 2.0.0 not supported"); 43 else 44 return new DefaultStateTransferGenerator(cache); } 46 47 public static StateTransferIntegrator getStateTransferIntegrator(ObjectInputStream in, Fqn fqn, CacheImpl cache) 48 throws Exception 49 { 50 short version = 0; 51 try 52 { 53 version = in.readShort(); 54 } 55 catch (IOException io) 56 { 57 try 59 { 60 in.close(); 61 } 62 catch (IOException ignored) {} 63 throw new IllegalStateException ("Stream corrupted ", io); 64 } 65 66 68 if (version < RV_200 && version > 0) throw new IllegalStateException ("State transfer with cache replication version < 2.0.0 not supported"); 70 else 71 return new DefaultStateTransferIntegrator(fqn, cache); } 73 74 } 75 | Popular Tags |